joeycastillo / Sensor-Watch

A board replacement for the classic Casio F-91W wristwatch
Other
1.03k stars 210 forks source link

Use slower "fast ticks" (8 Hz instead of 128 Hz) to detect button press and light duration #294

Open alesgenova opened 9 months ago

alesgenova commented 9 months ago

Every time a button is pressed, the light turns on, or a sound is playing, Movement enters a 128 Hz fast tick mode.

The cb_fast_tick() function is called 128 times per second. In this function we do among other things some checks on the time a button is held down or the amount of time left on an alarm playback.

With this PR I propose to lower the frequency of the fast tick mode to 8 Hz (the frequency is adjustable by changing FAST_TICK_FREQUENCY). This way we will reduce the invocation of cb_fast_tick() by over an order of magnitude.

We potentially lose a little bit of accuracy (up to 0.125s at 8 Hz) in the amount of time needed for a button longpress (0.5s +/- 0.125), or the light duration (1s +/- 0.125), but I think this inaccuracies are not noticeable.

Another consequence of this PR is that the 128 Hz mode is no longer reserved by Movement, and any face can now request this tick frequency.

wryun commented 9 months ago

:+1: seems like a good thing to me.

wryun commented 6 months ago

I've been using this on my watch without issue.