Timeline for Getting a stateless time-based index out of overflowing timer
Current License: CC BY-SA 3.0
6 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Aug 6, 2019 at 9:46 | vote | accept | Daniël van den Berg | ||
Jul 21, 2016 at 4:15 | comment | added | Daniël van den Berg | @hobbs overnight I figured why I wanted to do it how I wanted it in the first place, I tries to keep it stateless as much as possible. | |
Jul 20, 2016 at 18:24 | comment | added | hobbs | (your basic intuition is valid, and commonly used in game programming, control systems, etc. — instead of relying on code running at a fixed time step, you make it do the right thing based on how long it's been since it last ran. You just need to adapt it appropriately to the constraints you're working under.) | |
Jul 20, 2016 at 18:21 | comment | added | hobbs |
@DaniëlvandenBerg you can still deal with that (if there's any genuine reason to) by having your event handler notice when millis() increases by more than MILLISECONDS_PER_ENTRY at a go, and increasing the index more than once. As long as you check the clock at least once per 49 days, that won't become unstable.
|
|
Jul 20, 2016 at 17:00 | comment | added | Daniël van den Berg |
I guess I can deviate from my idea of using millis() as an index, but the main reason why I wanted to do this was for stability reasons. Using millis() as index would make it so that the program would keep functioning just fine if it were halted for a while. I'll look into your suggestion though.
|
|
Jul 20, 2016 at 14:56 | history | answered | kkrambo | CC BY-SA 3.0 |