InfiniTimeOrg / InfiniSim

Simulator for InfiniTime user interface without needing a PineTime
GNU General Public License v3.0
164 stars 66 forks source link

timers: Fix restarting timer from a timer #85

Closed Riksu9000 closed 1 year ago

Riksu9000 commented 1 year ago

Running xTimerChangePeriod and xTimerStart on the expired timer from a callback function returns successfully, but doesn't actually set the timer.

This bug causes this code to behave differently in the simulator than the watch. https://github.com/Riksu9000/InfiniTime/commit/e16e889e0c17ab8c772bdb13b002962ef5391b61

NeroBurner commented 1 year ago

It's been a while since I created this simulator timer. Could you explain to me how the timer-running setting to false is fixing a callback? I'm just curious how the flow would be for a broken vs a now fixed timer

Riksu9000 commented 1 year ago

It seems I was wrong initially and the issue is much simpler. The function always ends with setting timer->running to false, then next time the timer_callback_wrapper function is called, it checks the running variable and returns before calling the callback function. Moving this up allows the callback function to change the running state without it getting overridden.