mirror of
https://git.wetfence.xyz/RandyTheSilly/Trigalarm.git
synced 2026-09-05 18:17:20 -04:00
Add zap repeat interval; flash countdown when expired
This commit is contained in:
+17
-3
@@ -62,6 +62,8 @@ static uint8_t s_solution_indices[3] = {8, 8, 8};
|
||||
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];
|
||||
static uint8_t s_zap_repeat_countdown = 0;
|
||||
static bool s_hide_countdown = true;
|
||||
static uint32_t s_vibe_segments[5];
|
||||
static VibePattern s_vibe_pattern;
|
||||
|
||||
@@ -189,9 +191,10 @@ static void apply_uint8_from_tuple(DictionaryIterator *iter, uint32_t key, void
|
||||
static void inbox_received_handler(DictionaryIterator *iter, void *context) {
|
||||
Tuple *ready_tuple = dict_find(iter, MESSAGE_KEY_PKJS_READY);
|
||||
if (ready_tuple) {
|
||||
return; // TODO use ready signal better
|
||||
return;
|
||||
}
|
||||
apply_uint8_from_tuple(iter, MESSAGE_KEY_PKJS_PAVLOK_ENABLE, &settings.PavlokEnabled);
|
||||
apply_uint8_from_tuple(iter, MESSAGE_KEY_PKJS_PAVLOK_ZAP_INTERVAL, &settings.PavlokIntervalSeconds);
|
||||
apply_uint8_from_tuple(iter, MESSAGE_KEY_PKJS_AWARENESS_TIME_GAP, &settings.AwarenessTimeGapMinutes);
|
||||
apply_uint8_from_tuple(iter, MESSAGE_KEY_PKJS_AWARENESS_TIME_LIMIT, &settings.AwarenessTimeLimitSeconds);
|
||||
apply_uint8_from_tuple(iter, MESSAGE_KEY_PKJS_AWARENESS_NUDGE_ENABLE, &settings.AwarenessNudgeEnabled);
|
||||
@@ -292,10 +295,19 @@ static void awareness_alarm_seconds_handler(struct tm *tick_time, TimeUnits unit
|
||||
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);
|
||||
if (s_awareness_countdown_int == 0) {
|
||||
send_zap(); // TODO implement repeat interval
|
||||
send_zap();
|
||||
s_zap_repeat_countdown = settings.PavlokIntervalSeconds;
|
||||
}
|
||||
} else {
|
||||
// TODO flash countdown txt layer every second
|
||||
if (s_zap_repeat_countdown > 0) {
|
||||
s_zap_repeat_countdown--;
|
||||
if (s_zap_repeat_countdown == 0) {
|
||||
send_zap();
|
||||
s_zap_repeat_countdown = settings.PavlokIntervalSeconds;
|
||||
}
|
||||
}
|
||||
layer_set_hidden(text_layer_get_layer(s_countdown_txt_layer), s_hide_countdown);
|
||||
s_hide_countdown = !s_hide_countdown;
|
||||
vibes_enqueue_custom_pattern(s_vibe_pattern);
|
||||
}
|
||||
}
|
||||
@@ -617,6 +629,7 @@ static void alarm_window_load() {
|
||||
if (s_alarm_reason == WAKE_AWARENESS_ALARM) {
|
||||
text_layer_set_font(s_countdown_txt_layer, s_font_lecoish_small);
|
||||
s_awareness_countdown_int = settings.AwarenessTimeLimitSeconds;
|
||||
s_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 {
|
||||
@@ -993,6 +1006,7 @@ static void init() {
|
||||
} else {
|
||||
settings.TutorialEnabled = true;
|
||||
settings.PavlokEnabled = false;
|
||||
settings.PavlokIntervalSeconds = 10;
|
||||
settings.AwarenessTimeGapMinutes = 9;
|
||||
settings.AwarenessTimeLimitSeconds = 30;
|
||||
settings.AwarenessNudgeEnabled = true;
|
||||
|
||||
Reference in New Issue
Block a user