Merge PR #428 - fix issues in sunrise/sunset

Takes zero into account, allowing the sunrise/sunset watch face
to work with no presets defined.

Also resolves a warning during compilation of the sunrise/sunset face.

Reviewed-by: Matheus Afonso Martins Moreira <matheus@matheusmoreira.com>
GitHub-Pull-Request: https://github.com/joeycastillo/Sensor-Watch/pull/428
This commit is contained in:
Matheus Afonso Martins Moreira 2024-08-28 23:01:48 -03:00
commit dea05663b0

View file

@ -49,7 +49,7 @@ static void _sunrise_sunset_face_update(movement_settings_t *settings, sunrise_s
double rise, set, minutes, seconds;
bool show_next_match = false;
movement_location_t movement_location;
if (state->longLatToUse == 0)
if (state->longLatToUse == 0 || _location_count <= 1)
movement_location = (movement_location_t) watch_get_backup_data(1);
else{
movement_location.bit.latitude = longLatPresets[state->longLatToUse].latitude;
@ -359,7 +359,7 @@ bool sunrise_sunset_face_loop(movement_event_t event, movement_settings_t *setti
_sunrise_sunset_face_update_location_register(state);
}
_sunrise_sunset_face_update_settings_display(event, context);
} else if (_location_count == 1) {
} else if (_location_count <= 1) {
movement_illuminate_led();
}
if (state->page == 0) {
@ -368,7 +368,7 @@ bool sunrise_sunset_face_loop(movement_event_t event, movement_settings_t *setti
}
break;
case EVENT_LIGHT_LONG_PRESS:
if (_location_count == 1) break;
if (_location_count <= 1) break;
else if (!state->page) movement_illuminate_led();
break;
case EVENT_LIGHT_BUTTON_UP: