mirror of
https://github.com/firewalkwithm3/Sensor-Watch.git
synced 2024-11-22 19:20:30 +08:00
Added ability to add presets to the sunrise and sunset face
This commit is contained in:
parent
226cda748c
commit
a7c0fb7dfd
|
@ -37,6 +37,8 @@
|
|||
#include <emscripten.h>
|
||||
#endif
|
||||
|
||||
static const uint8_t _location_count = sizeof(longLatPresets) / sizeof(long_lat_presets_t);
|
||||
|
||||
static void _sunrise_sunset_set_expiration(sunrise_sunset_state_t *state, watch_date_time next_rise_set) {
|
||||
uint32_t timestamp = watch_utility_date_time_to_unix_time(next_rise_set, 0);
|
||||
state->rise_set_expires = watch_utility_date_time_from_unix_time(timestamp + 60, 0);
|
||||
|
@ -46,7 +48,13 @@ static void _sunrise_sunset_face_update(movement_settings_t *settings, sunrise_s
|
|||
char buf[14];
|
||||
double rise, set, minutes, seconds;
|
||||
bool show_next_match = false;
|
||||
movement_location_t movement_location = (movement_location_t) watch_get_backup_data(1);
|
||||
movement_location_t movement_location;
|
||||
if (state->longLatToUse == 0)
|
||||
movement_location = (movement_location_t) watch_get_backup_data(1);
|
||||
else{
|
||||
movement_location.bit.latitude = longLatPresets[state->longLatToUse].latitude;
|
||||
movement_location.bit.longitude = longLatPresets[state->longLatToUse].longitude;
|
||||
}
|
||||
|
||||
if (movement_location.reg == 0) {
|
||||
watch_display_string("RI no Loc", 0);
|
||||
|
@ -109,7 +117,7 @@ static void _sunrise_sunset_face_update(movement_settings_t *settings, sunrise_s
|
|||
if (watch_utility_convert_to_12_hour(&scratch_time)) watch_set_indicator(WATCH_INDICATOR_PM);
|
||||
else watch_clear_indicator(WATCH_INDICATOR_PM);
|
||||
}
|
||||
sprintf(buf, "rI%2d%2d%02d ", scratch_time.unit.day, scratch_time.unit.hour, scratch_time.unit.minute);
|
||||
sprintf(buf, "rI%2d%2d%02d%s", scratch_time.unit.day, scratch_time.unit.hour, scratch_time.unit.minute,longLatPresets[state->longLatToUse].name);
|
||||
watch_display_string(buf, 0);
|
||||
return;
|
||||
} else {
|
||||
|
@ -136,7 +144,7 @@ static void _sunrise_sunset_face_update(movement_settings_t *settings, sunrise_s
|
|||
if (watch_utility_convert_to_12_hour(&scratch_time)) watch_set_indicator(WATCH_INDICATOR_PM);
|
||||
else watch_clear_indicator(WATCH_INDICATOR_PM);
|
||||
}
|
||||
sprintf(buf, "SE%2d%2d%02d ", scratch_time.unit.day, scratch_time.unit.hour, scratch_time.unit.minute);
|
||||
sprintf(buf, "SE%2d%2d%02d%s", scratch_time.unit.day, scratch_time.unit.hour, scratch_time.unit.minute, longLatPresets[state->longLatToUse].name);
|
||||
watch_display_string(buf, 0);
|
||||
return;
|
||||
} else {
|
||||
|
@ -351,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 {
|
||||
} else if (_location_count == 1) {
|
||||
movement_illuminate_led();
|
||||
}
|
||||
if (state->page == 0) {
|
||||
|
@ -359,6 +367,16 @@ bool sunrise_sunset_face_loop(movement_event_t event, movement_settings_t *setti
|
|||
_sunrise_sunset_face_update(settings, state);
|
||||
}
|
||||
break;
|
||||
case EVENT_LIGHT_LONG_PRESS:
|
||||
if (_location_count == 1) break;
|
||||
else if (!state->page) movement_illuminate_led();
|
||||
break;
|
||||
case EVENT_LIGHT_BUTTON_UP:
|
||||
if (state->page == 0) {
|
||||
state->longLatToUse = (state->longLatToUse + 1) % _location_count;
|
||||
_sunrise_sunset_face_update(settings, state);
|
||||
}
|
||||
break;
|
||||
case EVENT_ALARM_BUTTON_UP:
|
||||
if (state->page) {
|
||||
_sunrise_sunset_face_advance_digit(state);
|
||||
|
@ -369,13 +387,19 @@ bool sunrise_sunset_face_loop(movement_event_t event, movement_settings_t *setti
|
|||
}
|
||||
break;
|
||||
case EVENT_ALARM_LONG_PRESS:
|
||||
if (state->page == 0) {
|
||||
if (state->page == 0 && state->longLatToUse == 0) {
|
||||
state->page++;
|
||||
state->active_digit = 0;
|
||||
watch_clear_display();
|
||||
movement_request_tick_frequency(4);
|
||||
_sunrise_sunset_face_update_settings_display(event, context);
|
||||
}
|
||||
else{
|
||||
state->active_digit = 0;
|
||||
state->page = 0;
|
||||
_sunrise_sunset_face_update_location_register(state);
|
||||
_sunrise_sunset_face_update(settings, state);
|
||||
}
|
||||
break;
|
||||
case EVENT_TIMEOUT:
|
||||
if (watch_get_backup_data(1) == 0) {
|
||||
|
|
|
@ -53,6 +53,7 @@ typedef struct {
|
|||
uint8_t active_digit;
|
||||
bool location_changed;
|
||||
watch_date_time rise_set_expires;
|
||||
uint8_t longLatToUse;
|
||||
sunrise_sunset_lat_lon_settings_t working_latitude;
|
||||
sunrise_sunset_lat_lon_settings_t working_longitude;
|
||||
} sunrise_sunset_state_t;
|
||||
|
@ -70,4 +71,18 @@ void sunrise_sunset_face_resign(movement_settings_t *settings, void *context);
|
|||
NULL, \
|
||||
})
|
||||
|
||||
typedef struct {
|
||||
char name[2];
|
||||
int16_t latitude;
|
||||
int16_t longitude;
|
||||
} long_lat_presets_t;
|
||||
|
||||
static const long_lat_presets_t longLatPresets[] =
|
||||
{
|
||||
{ .name = " "}, // Default, the long and lat get replaced by what's set in the watch
|
||||
// { .name = "Ny", .latitude = 4072, .longitude = -7401 }, // New York City, NY
|
||||
// { .name = "LA", .latitude = 3405, .longitude = -11824 }, // New York City, NY
|
||||
// { .name = "dE", .latitude = 4221, .longitude = -8305 }, // Detroit, MI
|
||||
};
|
||||
|
||||
#endif // SUNRISE_SUNSET_FACE_H_
|
||||
|
|
Loading…
Reference in a new issue