Zap user if not responding to main alarm
This commit is contained in:
@@ -12,6 +12,12 @@ Trigalarm is meant to be adapted to your needs, and you should adjust its settin
|
||||
|
||||
Perhaps the most unique, Trigalarm features optional [Pavlok](https://pavlok.com/pages/how-it-works) API integration to punish you via minor electrocution if you fall back asleep, force-quit the app, or attempt to overwrite your active alarm cycle.
|
||||
|
||||
## Learn the Lingo
|
||||
- Main alarm
|
||||
- The first alarm that goes off; comes with continuous vibration and does not disarm Trigalarm when solved. If Pavlok integration is enabled, this alarm can zap the user after a configurable amount of time if they do not respond. Solving this alarm will schedule an awareness alarm.
|
||||
- Awareness alarm
|
||||
- Any subsequent alarm after the main alarm has been solved; comes with only one brief vibration to indicate to the user it has opened. It has a configurable time limit it must be solved within to disarm Trigalarm. If the time limit expires, it will begin vibrations (and optionally Pavlok zaps), and once solved, it will schedule another awareness alarm.
|
||||
|
||||
## Tips & Tricks
|
||||
- When you successfully disarm the alarm, you are prompted with the options to either exit and keep the same alarm time for tomorrow, or to select a new time. If choosing the latter, whatever time you select will assume you mean tomorrow. This avoids situations where you wake up at 6 on a Friday, set an alarm intended for 9 on Saturday, and end up with your wrist buzzing in three hours!
|
||||
- If you are stuck waiting for an awareness alarm or there is a bug that schedules an alarm incorrectly, there is a "Reset Alarm" button in the phone-side settings that will set your alarm to 00:00.
|
||||
|
||||
+2
-1
@@ -36,8 +36,9 @@
|
||||
"PKJS_ALARM_RESET",
|
||||
"PKJS_PAVLOK_ENABLE",
|
||||
"PKJS_PAVLOK_ZAP_MIN",
|
||||
"PKJS_PAVLOK_ZAP_STEP",
|
||||
"PKJS_PAVLOK_ZAP_MAX",
|
||||
"PKJS_PAVLOK_ZAP_STEP",
|
||||
"PKJS_PAVLOK_ZAP_MAIN_DELAY",
|
||||
"PKJS_PAVLOK_ZAP_INTERVAL",
|
||||
"PKJS_PAVLOK_ZAP",
|
||||
"PKJS_AWARENESS_TIME_GAP",
|
||||
|
||||
+26
-9
@@ -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
@@ -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
@@ -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."
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user