Zap user if not responding to main alarm

This commit is contained in:
2026-08-27 13:40:49 -04:00
parent ba25924451
commit 23ff3c1941
6 changed files with 64 additions and 26 deletions
+26 -9
View File
@@ -61,9 +61,10 @@ static bool s_skip_current_day = false;
static WakeupReason s_alarm_reason;
static uint8_t s_solution_indices[3];
static uint8_t s_selected_indices[3] = {9, 9, 9};
static uint8_t s_main_countdown_till_zap;
static uint8_t s_awareness_countdown_int = 0;
static char s_awareness_countdown_buf[4];
static uint8_t s_awareness_zap_repeat_countdown = 0;
static uint8_t s_alarm_zap_repeat_countdown = 0;
static uint8_t s_awareness_zap_intensity = 0;
static bool s_hide_countdown = true;
static uint32_t s_vibe_segments[5];
@@ -296,8 +297,9 @@ static void inbox_received_handler(DictionaryIterator *iter, void *context) {
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_PAVLOK_ZAP_MIN, &settings.PavlokMin);
apply_uint8_from_tuple(iter, MESSAGE_KEY_PKJS_PAVLOK_ZAP_STEP, &settings.PavlokStep);
apply_uint8_from_tuple(iter, MESSAGE_KEY_PKJS_PAVLOK_ZAP_MAX, &settings.PavlokMax);
apply_uint8_from_tuple(iter, MESSAGE_KEY_PKJS_PAVLOK_ZAP_STEP, &settings.PavlokStep);
apply_uint8_from_tuple(iter, MESSAGE_KEY_PKJS_PAVLOK_ZAP_MAIN_DELAY, &settings.PavlokMainDelay);
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);
if (settings.PavlokMax <= settings.PavlokMin) {
@@ -329,6 +331,19 @@ static void send_zap(uint8_t intensity) {
////////////////////// ALARM //////////////////////
static void main_alarm_seconds_handler(struct tm *tick_time, TimeUnits units_changed) {
if (s_main_countdown_till_zap > 0) {
s_main_countdown_till_zap--;
if (s_main_countdown_till_zap == 0) {
send_zap(settings.PavlokMin);
s_alarm_zap_repeat_countdown = settings.PavlokIntervalSeconds;
}
} else if (s_alarm_zap_repeat_countdown > 0) {
s_alarm_zap_repeat_countdown--;
if (s_alarm_zap_repeat_countdown == 0) {
send_zap(settings.PavlokMin);
s_alarm_zap_repeat_countdown = settings.PavlokIntervalSeconds;
}
}
vibes_enqueue_custom_pattern(s_vibe_pattern);
}
@@ -339,14 +354,14 @@ static void awareness_alarm_seconds_handler(struct tm *tick_time, TimeUnits unit
text_layer_set_text(s_countdown_txt_layer, s_awareness_countdown_buf);
if (s_awareness_countdown_int == 0) {
send_zap(s_awareness_zap_intensity);
s_awareness_zap_repeat_countdown = settings.PavlokIntervalSeconds;
s_alarm_zap_repeat_countdown = settings.PavlokIntervalSeconds;
}
} else {
if (s_awareness_zap_repeat_countdown > 0) {
s_awareness_zap_repeat_countdown--;
if (s_awareness_zap_repeat_countdown == 0) {
if (s_alarm_zap_repeat_countdown > 0) {
s_alarm_zap_repeat_countdown--;
if (s_alarm_zap_repeat_countdown == 0) {
send_zap(s_awareness_zap_intensity);
s_awareness_zap_repeat_countdown = settings.PavlokIntervalSeconds;
s_alarm_zap_repeat_countdown = settings.PavlokIntervalSeconds;
}
}
layer_set_hidden(text_layer_get_layer(s_countdown_txt_layer), s_hide_countdown);
@@ -754,9 +769,9 @@ static void alarm_window_load() {
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);
s_alarm_zap_repeat_countdown = 0;
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);
@@ -766,6 +781,7 @@ static void alarm_window_load() {
tick_timer_service_subscribe(SECOND_UNIT, awareness_alarm_seconds_handler);
} else {
s_awareness_countdown_int = 0;
s_main_countdown_till_zap = settings.PavlokMainDelay;
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));
@@ -1067,8 +1083,9 @@ static void init() {
settings.PavlokEnabled = false;
settings.PavlokIntervalSeconds = 10;
settings.PavlokMin = 30;
settings.PavlokStep = 10;
settings.PavlokMax = 60;
settings.PavlokStep = 10;
settings.PavlokMainDelay = 60;
settings.AwarenessTimeGapMinutes = 9;
settings.AwarenessTimeLimitSeconds = 30;
}
+2 -1
View File
@@ -14,8 +14,9 @@ typedef struct AppSettings {
bool TutorialEnabled;
bool PavlokEnabled;
uint8_t PavlokMin;
uint8_t PavlokStep;
uint8_t PavlokMax;
uint8_t PavlokStep;
uint8_t PavlokMainDelay;
uint8_t PavlokIntervalSeconds;
uint8_t AwarenessTimeGapMinutes;
uint8_t AwarenessTimeLimitSeconds;
+24 -13
View File
@@ -40,18 +40,7 @@ module.exports = [
"max": 100,
"step": 5,
"label": "Zap Intensity (Base)",
"description": "% intensity of base zap. Used for awareness alarm zaps."
},
{
"id": "pavlok_zap_step",
"type": "slider",
"messageKey": "PKJS_PAVLOK_ZAP_STEP",
"defaultValue": 10,
"min": 0,
"max": 100,
"step": 5,
"label": "Zap Step",
"description": "% to increment base zap intensity after each failed awareness alarm; set to 0 to disable."
"description": "% intensity of base zap during alarms."
},
{
"id": "pavlok_zap_max",
@@ -64,6 +53,28 @@ module.exports = [
"label": "Zap Intensity (Max)",
"description": "% intensity of max zap; only takes effect if greater than base. Used for force exit/alarm overwrite penalties, as well as max value to step to in awareness alarms if zap step is enabled."
},
{
"id": "pavlok_zap_step",
"type": "slider",
"messageKey": "PKJS_PAVLOK_ZAP_STEP",
"defaultValue": 10,
"min": 0,
"max": 100,
"step": 5,
"label": "Zap Step",
"description": "% to increment base zap intensity after each failed awareness alarm; set to 0 to disable."
},
{
"id": "pavlok_zap_main_delay",
"type": "slider",
"messageKey": "PKJS_PAVLOK_ZAP_MAIN_DELAY",
"defaultValue": 60,
"min": 15,
"max": 120,
"step": 1,
"label": "Zap Main Alarm Delay",
"description": "Seconds into main alarm to start zaps."
},
{
"id": "pavlok_zap_interval",
"type": "slider",
@@ -73,7 +84,7 @@ module.exports = [
"max": 60,
"step": 1,
"label": "Zap Repeat Interval",
"description": "Seconds between zaps after awareness alarm counter expires."
"description": "Seconds between zaps during alarms."
}
]
},
+4 -2
View File
@@ -9,15 +9,17 @@ module.exports = function (minified) {
clayConfig.getItemById('pavlok_api_key').show();
clayConfig.getItemById('pavlok_test_beep').show();
clayConfig.getItemById('pavlok_zap_min').show();
clayConfig.getItemById('pavlok_zap_step').show();
clayConfig.getItemById('pavlok_zap_max').show();
clayConfig.getItemById('pavlok_zap_step').show();
clayConfig.getItemById('pavlok_zap_main_delay').show();
clayConfig.getItemById('pavlok_zap_interval').show();
} else {
clayConfig.getItemById('pavlok_api_key').hide();
clayConfig.getItemById('pavlok_test_beep').hide();
clayConfig.getItemById('pavlok_zap_min').hide();
clayConfig.getItemById('pavlok_zap_step').hide();
clayConfig.getItemById('pavlok_zap_max').hide();
clayConfig.getItemById('pavlok_zap_step').hide();
clayConfig.getItemById('pavlok_zap_main_delay').hide();
clayConfig.getItemById('pavlok_zap_interval').hide();
}
}