Better hundreds handling

This commit is contained in:
Daniel Bergman 2025-06-28 17:50:08 +02:00
parent 182db67aeb
commit 0234f7a391

View 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;