#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);
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);
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 {
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 {
_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) {
_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);
}
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) {
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;
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_