+void HandleNextEvent(int type/*= EVENT_MAIN*/)
+{
+ if (type == EVENT_MAIN)
+ {
+ double elapsedTime = eventList[nextEvent].eventTime;
+ void (* event)(void) = eventList[nextEvent].timerCallback;
+
+ for(uint32_t i=0; i<EVENT_LIST_SIZE; i++)
+ {
+ //We can skip the check & just subtract from everything, since the check is probably
+ //just as heavy as the code after and we won't use the elapsed time from an invalid event anyway.
+ // if (eventList[i].valid)
+ eventList[i].eventTime -= elapsedTime;
+ }
+
+ eventList[nextEvent].valid = false; // Remove event from list...
+ numberOfEvents--;
+
+ (*event)();
+ }
+ else
+ {
+ double elapsedTime = eventListJERRY[nextEventJERRY].eventTime;
+ void (* event)(void) = eventListJERRY[nextEventJERRY].timerCallback;
+
+ for(uint32_t i=0; i<EVENT_LIST_SIZE; i++)
+ {
+ //We can skip the check & just subtract from everything, since the check is probably
+ //just as heavy as the code after and we won't use the elapsed time from an invalid event anyway.
+ // if (eventList[i].valid)
+ eventListJERRY[i].eventTime -= elapsedTime;
+ }
+
+ eventListJERRY[nextEventJERRY].valid = false; // Remove event from list...
+ numberOfEvents--;
+
+ (*event)();
+ }