joeycastillo / Sensor-Watch

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

Fix simulator and hardware divergence in callback handling #252

Closed nategraf closed 10 months ago

nategraf commented 1 year ago

When using the simulator, I encountered cases where the light would become stuck on, and the watch would be unresponsive. In particular, this would occur when pressing the light button on the sunrise sunset watch face.

I appears that this is caused by a divergence in out the callback mask is intepretted by the hardware interface, and in the simulator in the following function.

void watch_rtc_disable_matching_periodic_callbacks(uint8_t mask)

In particular, a mask of 0xFE is intended to disable all except the 128hz cvallback at index 0, but instead disables all except the 1hz callback at index 7 in the simulator.

Based on by reading through and debugging the code in the simulator, this should fix a divergence between then hardware and simulator, but I am not 100% I am correct here. I see that @a2 originally included this code in https://github.com/joeycastillo/Sensor-Watch/pull/43, so I'd love your eyes here.

nategraf commented 1 year ago

@a2 and/or @joeycastillo do you have a moment to look at this PR?