It occurred to me that while the low 8 bits of millis() is +/-1,
that every 1024 micros, millis() does change by 1 or 2.
So if in a non-blocked void loop() with global byte prevMs,
byte nowMs = millis();
if ( prevMs != nowMs )
{
// do the every 1024 usec event
prevMs = nowMs;
}
no subtract required!
I should change my fast debounce to 1024us intervals!
...prevents the compiler from promoting to int before comparing (AVR processors). That should save, I think, four machine instructions.
This is a place where the "optimizing" compiler can't take my more efficient choice then? It's right up there with 16-bit bools where 8-bit saves RAM to represent 1 bit of data!
int int int int int int int int int int int int int int int int int int int int
misses the h every time!