10 months 4 weeks ago - 10 months 4 weeks ago#7519by Ian
A quick explanation of the failure mode.
I was reading millis() as a signed long value, but really it is an unsigned value.
After 2^31 milliseconds (=24days 10.5 hours or so) it rolls over to -2^31, a large negative number.
There is a function which knows the end time of the "temporary display" mode (date, LDR reading etc) which is usually set for 5 seconds in the future when you press the button. This is initialised to 0 and then moves forward each time you use temporary display mode. When time moves on, the check "millis < tempdisplayend" becomes false and the display reverts to normal time mode.
When we roll over, millis suddenly becomes much smaller than tempdisplayend, so the display gets stuck in temp mode.
all refrerences to time variables are now unsigned long
When we finish temp display mode, we set the tempdisplayend time to 0
I also made some little changes to the backlight cycling code to make the cycles give stronger primary shades.
Last Edit: 10 months 4 weeks ago by Ian. Reason: clarity
I have one clock (V49) which has frozen after around 50 days. Can't say the exact number of days but it's close to 50. It's done it twice now (in about 100 days), so there seems to be a pattern.
After a restart it's ok again.