Small improvement to ISR(TIMER2_OVF_vect)
During coding for my project I found a possible bug in the ISR handler from TIMER2_OVF_vect. It might be harmless in current code design, but it may create strange bugs for persons that add their own Eventfunctions:
Code:
for(byte eventID = 0; eventID < EVENTFUNC_SIZE; eventID++){ First, because of missing initialization of eventFuncCounts, it will fire each (!) eventFuncs[eventID]() at a random time after startup => not very nice. Second, after eventFuncCountss[eventID] reaches 0, it will fire the event every ms until a new time is set by addevent => even worse! Idea for improvement widthout affecting other existing code: Let eventFuncCounts[eventID] roll over after reaching 0 and define 65535 as "event execution disabled". Code:
for(byte eventID = 0; eventID < EVENTFUNC_SIZE; eventID++){ Code:
for(byte eventID = 0; eventID < EVENTFUNC_SIZE; eventID++){ Edit: Mistake from my side, it will not execute an event more than once.. But rest of it may be useful ;) |
All times are GMT -4. The time now is 02:49 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Content Relevant URLs by vBSEO 3.5.2
All content copyright EcoModder.com