From 0234f7a3918819d15f3a566d96f7126a8d24f4d8 Mon Sep 17 00:00:00 2001 From: Daniel Bergman Date: Sat, 28 Jun 2025 17:50:08 +0200 Subject: [PATCH] Better hundreds handling --- watch-faces/complication/sunrise_sunset_face.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/watch-faces/complication/sunrise_sunset_face.c b/watch-faces/complication/sunrise_sunset_face.c index 8a26a2e3..5003cd9c 100644 --- a/watch-faces/complication/sunrise_sunset_face.c +++ b/watch-faces/complication/sunrise_sunset_face.c @@ -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;