joeycastillo / Sensor-Watch

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

Support leading zero representation for 24h clock #299

Open glines opened 9 months ago

glines commented 9 months ago

This adds a mode to display 24h clock with leading zero rather than with the 24h indicator. For instance, "6:00 24h" appears as "06:00" with this mode enabled. (Finally! After all these years, I no longer need to squint to check if my watch says "24h" or if I accidentally bumped the alarm button and it says "PM"!)

The new mode is "hidden" behind the existing 24h option. Switch between leading-zero mode and the default with long-press of alarm button when viewing the screen with 24h setting. With leading-zero mode enabled, the options screen displays "024h". Otherwise, the existing 24h option works as before, so the change should not be disruptive to existing users.

This change occupies an additional global preferences bit, but I'm hoping this feature is popular enough to justify the cost. (If some day it does not fit in the BKUP register and needs to be stored elsewhere, I don't mind.)

Impact to performance should be minimal, as the bit only needs to be checked once every hour.

The only thing I'm not super happy about is all of the additional format strings. If there's a way to manually force the display to show a leading zero without using a format string, please let me know and I will rewrite this patch.

glines commented 8 months ago

I revised this patch to call watch_display_string("0", 4) after updating the display, rather than using multiple nearly identical format strings. This approach is much easier to follow and maintain IMO.

I expanded this patch to add leading zero support to any watch face I could find that reads the clock_mode_24h bit. I don't use all of these watch faces myself, so my testing is limited on some of them. I made sure they at least compile and display 12h and 24h time properly in the simulator.

glines commented 8 months ago

Fixed small bug, 24h indicator was not shown in the alarm face. (this is a bug in the current implementation, not a regression from this patch)