Fix rare chance for main alarm to fully disarm if Trigalarm is left open for an unrealistically long period of time
This commit is contained in:
+26
-19
@@ -59,7 +59,7 @@ static uint8_t s_highlight_pos = 0;
|
||||
static bool s_skip_current_day = false;
|
||||
//// alarm
|
||||
static WakeupReason s_alarm_reason;
|
||||
static uint8_t s_solution_indices[3] = {8, 8, 8};
|
||||
static uint8_t s_solution_indices[3];
|
||||
static uint8_t s_selected_indices[3] = {9, 9, 9};
|
||||
static uint8_t s_awareness_countdown_int = 0;
|
||||
static char s_awareness_countdown_buf[4];
|
||||
@@ -653,23 +653,6 @@ static void alarm_window_load() {
|
||||
s_drop_window,
|
||||
(WindowHandlers){.load = drop_menu_window_load, .unload = drop_menu_window_unload});
|
||||
|
||||
// countdown
|
||||
s_countdown_txt_layer = text_layer_create(GRect(0, (s_small_top_bar_height / 2) - PBL_IF_ROUND_ELSE(6, 10), PBL_DISPLAY_WIDTH, s_small_top_bar_height));
|
||||
text_layer_set_background_color(s_countdown_txt_layer, GColorClear);
|
||||
text_layer_set_text_color(s_countdown_txt_layer, GColorWhite);
|
||||
text_layer_set_text_alignment(s_countdown_txt_layer, GTextAlignmentCenter);
|
||||
if (s_alarm_reason == WAKE_AWARENESS_ALARM || s_alarm_reason == WAKE_RECOVERY_AWARENESS_ALARM) {
|
||||
text_layer_set_font(s_countdown_txt_layer, s_font_lecoish_small);
|
||||
s_awareness_countdown_int = settings.AwarenessTimeLimitSeconds;
|
||||
s_awareness_zap_repeat_countdown = 0;
|
||||
snprintf(s_awareness_countdown_buf, sizeof(s_awareness_countdown_buf), "%03u", s_awareness_countdown_int);
|
||||
text_layer_set_text(s_countdown_txt_layer, s_awareness_countdown_buf);
|
||||
} else {
|
||||
text_layer_set_font(s_countdown_txt_layer, s_font_mansalva_small);
|
||||
text_layer_set_text(s_countdown_txt_layer, "🏁 hold select 🏁");
|
||||
}
|
||||
layer_add_child(window_layer, text_layer_get_layer(s_countdown_txt_layer));
|
||||
|
||||
// setup vibes
|
||||
s_vibe_segments[0] = (uint32_t)(s_triangle_layer->angle_A * 2);
|
||||
s_vibe_segments[1] = 200;
|
||||
@@ -681,10 +664,27 @@ static void alarm_window_load() {
|
||||
.num_segments = ARRAY_LENGTH(s_vibe_segments),
|
||||
};
|
||||
|
||||
// countdown
|
||||
s_countdown_txt_layer = text_layer_create(GRect(0, (s_small_top_bar_height / 2) - PBL_IF_ROUND_ELSE(6, 10), PBL_DISPLAY_WIDTH, s_small_top_bar_height));
|
||||
text_layer_set_background_color(s_countdown_txt_layer, GColorClear);
|
||||
text_layer_set_text_color(s_countdown_txt_layer, GColorWhite);
|
||||
text_layer_set_text_alignment(s_countdown_txt_layer, GTextAlignmentCenter);
|
||||
if (s_alarm_reason == WAKE_AWARENESS_ALARM || s_alarm_reason == WAKE_RECOVERY_AWARENESS_ALARM) {
|
||||
s_awareness_countdown_int = settings.AwarenessTimeLimitSeconds;
|
||||
s_awareness_zap_repeat_countdown = 0;
|
||||
text_layer_set_font(s_countdown_txt_layer, s_font_lecoish_small);
|
||||
snprintf(s_awareness_countdown_buf, sizeof(s_awareness_countdown_buf), "%03u", s_awareness_countdown_int);
|
||||
text_layer_set_text(s_countdown_txt_layer, s_awareness_countdown_buf);
|
||||
layer_add_child(window_layer, text_layer_get_layer(s_countdown_txt_layer));
|
||||
|
||||
schedule_alarm(WAKE_RECOVERY_AWARENESS_ALARM);
|
||||
tick_timer_service_subscribe(SECOND_UNIT, awareness_alarm_seconds_handler);
|
||||
} else {
|
||||
s_awareness_countdown_int = 0;
|
||||
text_layer_set_font(s_countdown_txt_layer, s_font_mansalva_small);
|
||||
text_layer_set_text(s_countdown_txt_layer, "🏁 hold select 🏁");
|
||||
layer_add_child(window_layer, text_layer_get_layer(s_countdown_txt_layer));
|
||||
|
||||
schedule_alarm(WAKE_RECOVERY_MAIN_ALARM);
|
||||
tick_timer_service_subscribe(SECOND_UNIT, main_alarm_seconds_handler);
|
||||
}
|
||||
@@ -950,8 +950,15 @@ static void setter_click_config_provider(void *ctx) {
|
||||
}
|
||||
|
||||
static void live_wakeup_handler_for_setter(WakeupId id, int32_t reason) {
|
||||
// reset values set in setter
|
||||
s_highlight_pos = 0;
|
||||
s_skip_current_day = false; // reset
|
||||
|
||||
// reset values potentially set by prior alarm
|
||||
s_skip_current_day = false;
|
||||
s_selected_indices[0] = 9;
|
||||
s_selected_indices[1] = 9;
|
||||
s_selected_indices[2] = 9;
|
||||
|
||||
window_stack_pop_all(false);
|
||||
push_alarm_window();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user