]> git.earman.xyz Git - sensor-watch.git/commitdiff
Better hundreds handling
authorDaniel Bergman <danber@gmail.com>
Sat, 28 Jun 2025 15:50:08 +0000 (17:50 +0200)
committerDaniel Bergman <danber@gmail.com>
Sat, 28 Jun 2025 15:50:08 +0000 (17:50 +0200)
watch-faces/complication/sunrise_sunset_face.c

index 8a26a2e39fa57ef76bce9fa3397e1903223cd241..5003cd9cd7745e29a53dd890f6440e265220da3c 100644 (file)
@@ -239,6 +239,7 @@ static void _sunrise_sunset_face_update_settings_display(movement_event_t event,
         case 0:
             return;
         case 1:
+            // Latitude
             watch_display_text_with_fallback(WATCH_POSITION_TOP_LEFT, "LAT", "LA");
             if (watch_get_lcd_type() == WATCH_LCD_TYPE_CUSTOM) {
                 watch_set_decimal_if_available();
@@ -262,12 +263,13 @@ static void _sunrise_sunset_face_update_settings_display(movement_event_t event,
             }
             break;
         case 2:
+            // Longitude
             watch_display_text_with_fallback(WATCH_POSITION_TOP_LEFT, "LON", "LO");
             if (watch_get_lcd_type() == WATCH_LCD_TYPE_CUSTOM) {
                 watch_set_decimal_if_available();
                 // Handle leading 1 for longitudes >99
-                if (state->working_longitude.tens > 9) watch_set_pixel(0, 22);
-                watch_display_character('0' + state->working_longitude.tens % 10, 4);
+                if (state->working_longitude.hundreds == 1) watch_set_pixel(0, 22);
+                watch_display_character('0' + state->working_longitude.tens, 4);
                 watch_display_character('0' + state->working_longitude.ones, 5);
                 watch_display_character('0' + state->working_longitude.tenths, 6);
                 watch_display_character('0' + state->working_longitude.hundredths, 7);
@@ -326,7 +328,14 @@ static void _sunrise_sunset_face_advance_digit(sunrise_sunset_state_t *state) {
             case 2: // longitude
                 switch (state->active_digit) {
                     case 0:
-                        state->working_longitude.tens = (state->working_longitude.tens + 1) % 18;
+                        // Increase tens and handle carry-over to hundreds
+                        state->working_longitude.tens++;
+                        if (state->working_longitude.tens >= 10) {
+                            state->working_longitude.tens = 0;
+                            state->working_longitude.hundreds++;
+                        }
+
+                        // Reset if we've gone over ±180
                         if (abs(_sunrise_sunset_face_latlon_from_struct(state->working_longitude)) > 18000) {
                             state->working_longitude.hundreds = 0;
                             state->working_longitude.tens = 0;