Migrate to SDK4.44+MV2
This commit is contained in:
1 parent
bf7a8a30b4
commit
d286450c92
4 files changed
+102
-104
No files matched your search
+92
-84
@@ -3,21 +3,21 @@
|
||||
"author": "RandyTheSilly",
|
||||
"version": "2.0.0",
|
||||
"keywords": [
|
||||
"alarm",
|
||||
"math",
|
||||
"trigonometry",
|
||||
"trig",
|
||||
"triangle",
|
||||
"pavlok",
|
||||
"shock",
|
||||
"zap"
|
||||
"alarm",
|
||||
"math",
|
||||
"trigonometry",
|
||||
"trig",
|
||||
"triangle",
|
||||
"pavlok",
|
||||
"shock",
|
||||
"zap"
|
||||
],
|
||||
"capabilities": [
|
||||
"configurable"
|
||||
"configurable"
|
||||
],
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@rebble/clay": "^1.1.0"
|
||||
"@rebble/clay": "^1.1.0"
|
||||
},
|
||||
"pebble": {
|
||||
"displayName": "Trigalarm",
|
||||
@@ -32,83 +32,91 @@
|
||||
"watchface": false
|
||||
},
|
||||
"messageKeys": [
|
||||
"PKJS_READY",
|
||||
"PKJS_ALARM_RESET",
|
||||
"PKJS_TRIANGLE_COUNT",
|
||||
"PKJS_TRIANGLE_SECS_MIN",
|
||||
"PKJS_TRIANGLE_SECS_STEP",
|
||||
"PKJS_PAVLOK_ENABLE",
|
||||
"PKJS_PAVLOK_ZAP_INTENSITY",
|
||||
"PKJS_PAVLOK_ZAP"
|
||||
"PKJS_READY",
|
||||
"PKJS_ALARM_RESET",
|
||||
"PKJS_TRIANGLE_COUNT",
|
||||
"PKJS_TRIANGLE_SECS_MIN",
|
||||
"PKJS_TRIANGLE_SECS_STEP",
|
||||
"PKJS_PAVLOK_ENABLE",
|
||||
"PKJS_PAVLOK_ZAP_INTENSITY",
|
||||
"PKJS_PAVLOK_ZAP"
|
||||
],
|
||||
"resources": {
|
||||
"media": [
|
||||
{
|
||||
"file": "clock25.png",
|
||||
"memoryFormat": "Smallest",
|
||||
"name": "CLOCK25",
|
||||
"spaceOptimization": "storage",
|
||||
"type": "bitmap",
|
||||
"menuIcon": true
|
||||
},
|
||||
{
|
||||
"file": "clock35.png",
|
||||
"memoryFormat": "Smallest",
|
||||
"name": "CLOCK35",
|
||||
"spaceOptimization": "storage",
|
||||
"type": "bitmap"
|
||||
},
|
||||
{
|
||||
"file": "x.png",
|
||||
"memoryFormat": "Smallest",
|
||||
"name": "X",
|
||||
"spaceOptimization": "storage",
|
||||
"type": "bitmap"
|
||||
},
|
||||
{
|
||||
"file": "check.png",
|
||||
"memoryFormat": "Smallest",
|
||||
"name": "CHECK",
|
||||
"spaceOptimization": "storage",
|
||||
"type": "bitmap"
|
||||
},
|
||||
{
|
||||
"characterRegex": "[:0-9]",
|
||||
"file": "lecoish_mono_bold_20.bdf",
|
||||
"name": "FONT_LECOISH_MONO_BOLD_20",
|
||||
"type": "font"
|
||||
},
|
||||
{
|
||||
"characterRegex": "[:0-9]",
|
||||
"file": "lecoish_mono_bold_40.bdf",
|
||||
"name": "FONT_LECOISH_MONO_BOLD_40",
|
||||
"type": "font",
|
||||
"targetPlatforms": [
|
||||
"emery"
|
||||
]
|
||||
},
|
||||
{
|
||||
"characterRegex": "[:0-9]",
|
||||
"file": "lecoish_mono_bold_60.bdf",
|
||||
"name": "FONT_LECOISH_MONO_BOLD_60",
|
||||
"type": "font",
|
||||
"targetPlatforms": [
|
||||
"gabbro"
|
||||
]
|
||||
},
|
||||
{
|
||||
"characterRegex": "[sincostaeθ=¯¹0123456789]",
|
||||
"file": "mansalva_regular.ttf",
|
||||
"name": "FONT_MANSALVA_REGULAR_22",
|
||||
"type": "font"
|
||||
},
|
||||
{
|
||||
"characterRegex": "[()]",
|
||||
"file": "mansalva_regular.ttf",
|
||||
"name": "FONT_MANSALVA_REGULAR_50",
|
||||
"type": "font"
|
||||
}
|
||||
{
|
||||
"file": "clock25.png",
|
||||
"memoryFormat": "Smallest",
|
||||
"name": "CLOCK25",
|
||||
"spaceOptimization": "storage",
|
||||
"type": "bitmap",
|
||||
"menuIcon": true
|
||||
},
|
||||
{
|
||||
"file": "clock35.png",
|
||||
"memoryFormat": "Smallest",
|
||||
"name": "CLOCK35",
|
||||
"spaceOptimization": "storage",
|
||||
"type": "bitmap"
|
||||
},
|
||||
{
|
||||
"file": "x.png",
|
||||
"memoryFormat": "Smallest",
|
||||
"name": "X",
|
||||
"spaceOptimization": "storage",
|
||||
"type": "bitmap"
|
||||
},
|
||||
{
|
||||
"file": "check.png",
|
||||
"memoryFormat": "Smallest",
|
||||
"name": "CHECK",
|
||||
"spaceOptimization": "storage",
|
||||
"type": "bitmap"
|
||||
},
|
||||
{
|
||||
"characterRegex": "[:0-9]",
|
||||
"file": "lecoish_mono_bold_20.bdf",
|
||||
"name": "FONT_LECOISH_MONO_BOLD_20",
|
||||
"type": "font"
|
||||
},
|
||||
{
|
||||
"characterRegex": "[:0-9]",
|
||||
"file": "lecoish_mono_bold_40.bdf",
|
||||
"name": "FONT_LECOISH_MONO_BOLD_40",
|
||||
"type": "font",
|
||||
"targetPlatforms": [
|
||||
"emery"
|
||||
]
|
||||
},
|
||||
{
|
||||
"characterRegex": "[:0-9]",
|
||||
"file": "lecoish_mono_bold_60.bdf",
|
||||
"name": "FONT_LECOISH_MONO_BOLD_60",
|
||||
"type": "font",
|
||||
"targetPlatforms": [
|
||||
"gabbro"
|
||||
]
|
||||
},
|
||||
{
|
||||
"characterRegex": "[sincostae\u03b8=\u00af\u00b90123456789]",
|
||||
"file": "mansalva_regular.ttf",
|
||||
"name": "FONT_MANSALVA_REGULAR_22",
|
||||
"type": "font"
|
||||
},
|
||||
{
|
||||
"characterRegex": "[()]",
|
||||
"file": "mansalva_regular.ttf",
|
||||
"name": "FONT_MANSALVA_REGULAR_50",
|
||||
"type": "font"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"usesPermissions": [
|
||||
{
|
||||
"name": "Internet",
|
||||
"parameters": {
|
||||
"domains": ["api.pavlok.com"]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -75,7 +75,7 @@ static uint8_t s_zap_cooldown;
|
||||
static uint8_t s_countdown_int = 0;
|
||||
static bool s_continuous_zap_on_first_triangle;
|
||||
static char s_countdown_buf[4];
|
||||
static char s_progress_buf[6];
|
||||
static char s_progress_buf[8];
|
||||
|
||||
// constants
|
||||
//// shared (setter+alarm)
|
||||
@@ -183,7 +183,7 @@ static void status_window_load(StatusWindowPurpose purpose) {
|
||||
scroll_layer_set_content_size(s_status_scroll_layer, GSize(bounds.size.w, max_size.h));
|
||||
return;
|
||||
case STATUS_CONFIRMATION: {
|
||||
static char s_status_confirmed_buffer[86];
|
||||
static char s_status_confirmed_buffer[88];
|
||||
snprintf(s_status_confirmed_buffer, sizeof(s_status_confirmed_buffer), "Alarm disarmed and re-set (%02u:%02u) successfully.\n\nSELECT: Exit\nBACK: Change alarm time", the_time.HourSet, the_time.MinuteSet);
|
||||
text_layer_set_text(s_status_txt_layer, s_status_confirmed_buffer);
|
||||
window_set_click_config_provider(s_status_window, status_confirmation_click_config_provider);
|
||||
@@ -246,13 +246,13 @@ static bool schedule_alarm(WakeupReason schedule_reason) {
|
||||
case WAKE_ALARM: {
|
||||
target = compute_alarm_time(the_time.HourWIP, the_time.MinuteWIP);
|
||||
wakeup_cancel_all();
|
||||
status = wakeup_schedule_simple_robust(target, SECONDS_PER_MINUTE, schedule_reason);
|
||||
status = wakeup_schedule_simple_robust(target, schedule_reason);
|
||||
break;
|
||||
}
|
||||
case WAKE_RECOVERY_ALARM:
|
||||
target = time(NULL) + 15;
|
||||
// no need to cancel alarms, as recovery alarms are short-lived and are expired by the time another is being scheduled
|
||||
status = wakeup_schedule_simple_robust(target, 15, schedule_reason);
|
||||
status = wakeup_schedule_simple_robust(target, schedule_reason);
|
||||
}
|
||||
if (status < 0) {
|
||||
push_status_window(STATUS_FAILURE);
|
||||
|
||||
+5
-15
@@ -16,29 +16,19 @@ static void glance_reload_callback(AppGlanceReloadSession *session, size_t limit
|
||||
app_glance_add_slice(session, slice);
|
||||
}
|
||||
|
||||
// Mostly stolen from https://github.com/SeaPea/GentleWake;
|
||||
// A slightly more robust wakeup scheduler that retries on certain errors and
|
||||
// can retry for a different wakeup time offset by retry_diff up to retry_max times
|
||||
WakeupId wakeup_schedule_simple_robust(time_t wakeup_time, int8_t retry_diff, WakeupReason wakeup_reason) {
|
||||
// Originally stolen from https://github.com/SeaPea/GentleWake (simplified by me for SDK 4.44+);
|
||||
// A slightly more robust wakeup scheduler that retries on errors
|
||||
WakeupId wakeup_schedule_simple_robust(time_t wakeup_time, WakeupReason wakeup_reason) {
|
||||
WakeupId result = 0;
|
||||
uint8_t try_count = 0;
|
||||
|
||||
result = wakeup_schedule(wakeup_time, wakeup_reason, true);
|
||||
|
||||
if (result < 0) {
|
||||
// If result is negative, something went wrong, so make sure all wakeups for this app are cancelled and try again
|
||||
wakeup_cancel_all();
|
||||
|
||||
result = wakeup_schedule(wakeup_time, wakeup_reason, true);
|
||||
|
||||
if (result == E_RANGE) {
|
||||
// E_RANGE means some other app has the same wakeup time +/- 1 minute, so try to set
|
||||
// the wakeup for a time up to (retry_diff * 8) minutes before/after.
|
||||
while (result == E_RANGE && try_count++ < 8) {
|
||||
wakeup_time += retry_diff;
|
||||
result = wakeup_schedule(wakeup_time, wakeup_reason, true);
|
||||
}
|
||||
}
|
||||
// As of SDK 4.44, E_RANGE result no longer needs handled, as it now only reports wakeups scheduled by THIS app;
|
||||
// we call wakeup_cancel_all() above, so E_RANGE will never be encountered
|
||||
}
|
||||
|
||||
if (result >= 0) {
|
||||
|
||||
+1
-1
@@ -16,4 +16,4 @@ typedef struct TheTime {
|
||||
|
||||
extern struct TheTime the_time;
|
||||
|
||||
WakeupId wakeup_schedule_simple_robust(time_t wakeup_time, int8_t retry_diff, WakeupReason wakeup_reason);
|
||||
WakeupId wakeup_schedule_simple_robust(time_t wakeup_time, WakeupReason wakeup_reason);
|
||||
Reference in new issue
Block a user