furbrain / STIC

GNU General Public License v3.0
9 stars 5 forks source link

Device becomes unresponsive several months after first power on #13

Closed furbrain closed 7 months ago

furbrain commented 7 months ago

1-2 months after power on the device stops responding to the button presses to turn on

furbrain commented 7 months ago

This is due to circuitpython's time.monotonic() returning a float, which only has 22 bits of precision. As it represents time since power first applied to device (which is not reset by a reset!), this will start degrading to 1 second resolution after about 25 days. This means that the turn on code may stop working at this point (possibly 50 days), difficult to test.

Fix is to switch to supervisor.time_ms(), which is an int. This can wrap but would need an attempt to switch on at exactly the right moment. A second attempt would then be successful