I’ve got a bit of code that sometimes hangs:
It doesn’t go past here, but only sometimes. startMillis is set = to millis() by a button press in a previous gameMode.
Is this because millis is overflowing? Is there a elegant way to capture this or should I just use my own counter?
You could look at how the Arduboy2 library nextFrame() function uses the millis() timer. It properly handles timer overflows.
Also look at this:
I knew it was something simple, I was scratching my head on it. The only reason I posted it was I figure other people have run into it before might be worth talking about. Thanks!
It would be good to know what datatype you’re using for
startMillis. It should be at least
unsigned long (
uint32_t for AVR).
However, I’m wondering if something
millis() does is interfering with the timers the sound libraries are using.
well it was an int, so that would explain the behavior more. Is there some way to mark two solutions or should that be the correct one?
I’m still not entirely sure if overflow actually was the source of the problem, but if it is then @MLXXXp’s comment should be the solution because the linked tutorial tackles the problem of overflow in depth.
With great solution button comes great responsibility