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",
|
"author": "RandyTheSilly",
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"alarm",
|
"alarm",
|
||||||
"math",
|
"math",
|
||||||
"trigonometry",
|
"trigonometry",
|
||||||
"trig",
|
"trig",
|
||||||
"triangle",
|
"triangle",
|
||||||
"pavlok",
|
"pavlok",
|
||||||
"shock",
|
"shock",
|
||||||
"zap"
|
"zap"
|
||||||
],
|
],
|
||||||
"capabilities": [
|
"capabilities": [
|
||||||
"configurable"
|
"configurable"
|
||||||
],
|
],
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@rebble/clay": "^1.1.0"
|
"@rebble/clay": "^1.1.0"
|
||||||
},
|
},
|
||||||
"pebble": {
|
"pebble": {
|
||||||
"displayName": "Trigalarm",
|
"displayName": "Trigalarm",
|
||||||
@@ -32,83 +32,91 @@
|
|||||||
"watchface": false
|
"watchface": false
|
||||||
},
|
},
|
||||||
"messageKeys": [
|
"messageKeys": [
|
||||||
"PKJS_READY",
|
"PKJS_READY",
|
||||||
"PKJS_ALARM_RESET",
|
"PKJS_ALARM_RESET",
|
||||||
"PKJS_TRIANGLE_COUNT",
|
"PKJS_TRIANGLE_COUNT",
|
||||||
"PKJS_TRIANGLE_SECS_MIN",
|
"PKJS_TRIANGLE_SECS_MIN",
|
||||||
"PKJS_TRIANGLE_SECS_STEP",
|
"PKJS_TRIANGLE_SECS_STEP",
|
||||||
"PKJS_PAVLOK_ENABLE",
|
"PKJS_PAVLOK_ENABLE",
|
||||||
"PKJS_PAVLOK_ZAP_INTENSITY",
|
"PKJS_PAVLOK_ZAP_INTENSITY",
|
||||||
"PKJS_PAVLOK_ZAP"
|
"PKJS_PAVLOK_ZAP"
|
||||||
],
|
],
|
||||||
"resources": {
|
"resources": {
|
||||||
"media": [
|
"media": [
|
||||||
{
|
{
|
||||||
"file": "clock25.png",
|
"file": "clock25.png",
|
||||||
"memoryFormat": "Smallest",
|
"memoryFormat": "Smallest",
|
||||||
"name": "CLOCK25",
|
"name": "CLOCK25",
|
||||||
"spaceOptimization": "storage",
|
"spaceOptimization": "storage",
|
||||||
"type": "bitmap",
|
"type": "bitmap",
|
||||||
"menuIcon": true
|
"menuIcon": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"file": "clock35.png",
|
"file": "clock35.png",
|
||||||
"memoryFormat": "Smallest",
|
"memoryFormat": "Smallest",
|
||||||
"name": "CLOCK35",
|
"name": "CLOCK35",
|
||||||
"spaceOptimization": "storage",
|
"spaceOptimization": "storage",
|
||||||
"type": "bitmap"
|
"type": "bitmap"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"file": "x.png",
|
"file": "x.png",
|
||||||
"memoryFormat": "Smallest",
|
"memoryFormat": "Smallest",
|
||||||
"name": "X",
|
"name": "X",
|
||||||
"spaceOptimization": "storage",
|
"spaceOptimization": "storage",
|
||||||
"type": "bitmap"
|
"type": "bitmap"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"file": "check.png",
|
"file": "check.png",
|
||||||
"memoryFormat": "Smallest",
|
"memoryFormat": "Smallest",
|
||||||
"name": "CHECK",
|
"name": "CHECK",
|
||||||
"spaceOptimization": "storage",
|
"spaceOptimization": "storage",
|
||||||
"type": "bitmap"
|
"type": "bitmap"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"characterRegex": "[:0-9]",
|
"characterRegex": "[:0-9]",
|
||||||
"file": "lecoish_mono_bold_20.bdf",
|
"file": "lecoish_mono_bold_20.bdf",
|
||||||
"name": "FONT_LECOISH_MONO_BOLD_20",
|
"name": "FONT_LECOISH_MONO_BOLD_20",
|
||||||
"type": "font"
|
"type": "font"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"characterRegex": "[:0-9]",
|
"characterRegex": "[:0-9]",
|
||||||
"file": "lecoish_mono_bold_40.bdf",
|
"file": "lecoish_mono_bold_40.bdf",
|
||||||
"name": "FONT_LECOISH_MONO_BOLD_40",
|
"name": "FONT_LECOISH_MONO_BOLD_40",
|
||||||
"type": "font",
|
"type": "font",
|
||||||
"targetPlatforms": [
|
"targetPlatforms": [
|
||||||
"emery"
|
"emery"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"characterRegex": "[:0-9]",
|
"characterRegex": "[:0-9]",
|
||||||
"file": "lecoish_mono_bold_60.bdf",
|
"file": "lecoish_mono_bold_60.bdf",
|
||||||
"name": "FONT_LECOISH_MONO_BOLD_60",
|
"name": "FONT_LECOISH_MONO_BOLD_60",
|
||||||
"type": "font",
|
"type": "font",
|
||||||
"targetPlatforms": [
|
"targetPlatforms": [
|
||||||
"gabbro"
|
"gabbro"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"characterRegex": "[sincostaeθ=¯¹0123456789]",
|
"characterRegex": "[sincostae\u03b8=\u00af\u00b90123456789]",
|
||||||
"file": "mansalva_regular.ttf",
|
"file": "mansalva_regular.ttf",
|
||||||
"name": "FONT_MANSALVA_REGULAR_22",
|
"name": "FONT_MANSALVA_REGULAR_22",
|
||||||
"type": "font"
|
"type": "font"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"characterRegex": "[()]",
|
"characterRegex": "[()]",
|
||||||
"file": "mansalva_regular.ttf",
|
"file": "mansalva_regular.ttf",
|
||||||
"name": "FONT_MANSALVA_REGULAR_50",
|
"name": "FONT_MANSALVA_REGULAR_50",
|
||||||
"type": "font"
|
"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 uint8_t s_countdown_int = 0;
|
||||||
static bool s_continuous_zap_on_first_triangle;
|
static bool s_continuous_zap_on_first_triangle;
|
||||||
static char s_countdown_buf[4];
|
static char s_countdown_buf[4];
|
||||||
static char s_progress_buf[6];
|
static char s_progress_buf[8];
|
||||||
|
|
||||||
// constants
|
// constants
|
||||||
//// shared (setter+alarm)
|
//// 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));
|
scroll_layer_set_content_size(s_status_scroll_layer, GSize(bounds.size.w, max_size.h));
|
||||||
return;
|
return;
|
||||||
case STATUS_CONFIRMATION: {
|
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);
|
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);
|
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);
|
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: {
|
case WAKE_ALARM: {
|
||||||
target = compute_alarm_time(the_time.HourWIP, the_time.MinuteWIP);
|
target = compute_alarm_time(the_time.HourWIP, the_time.MinuteWIP);
|
||||||
wakeup_cancel_all();
|
wakeup_cancel_all();
|
||||||
status = wakeup_schedule_simple_robust(target, SECONDS_PER_MINUTE, schedule_reason);
|
status = wakeup_schedule_simple_robust(target, schedule_reason);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case WAKE_RECOVERY_ALARM:
|
case WAKE_RECOVERY_ALARM:
|
||||||
target = time(NULL) + 15;
|
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
|
// 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) {
|
if (status < 0) {
|
||||||
push_status_window(STATUS_FAILURE);
|
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);
|
app_glance_add_slice(session, slice);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mostly stolen from https://github.com/SeaPea/GentleWake;
|
// Originally stolen from https://github.com/SeaPea/GentleWake (simplified by me for SDK 4.44+);
|
||||||
// A slightly more robust wakeup scheduler that retries on certain errors and
|
// A slightly more robust wakeup scheduler that retries on errors
|
||||||
// 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, WakeupReason wakeup_reason) {
|
||||||
WakeupId wakeup_schedule_simple_robust(time_t wakeup_time, int8_t retry_diff, WakeupReason wakeup_reason) {
|
|
||||||
WakeupId result = 0;
|
WakeupId result = 0;
|
||||||
uint8_t try_count = 0;
|
|
||||||
|
|
||||||
result = wakeup_schedule(wakeup_time, wakeup_reason, true);
|
result = wakeup_schedule(wakeup_time, wakeup_reason, true);
|
||||||
|
|
||||||
if (result < 0) {
|
if (result < 0) {
|
||||||
// If result is negative, something went wrong, so make sure all wakeups for this app are cancelled and try again
|
// If result is negative, something went wrong, so make sure all wakeups for this app are cancelled and try again
|
||||||
wakeup_cancel_all();
|
wakeup_cancel_all();
|
||||||
|
|
||||||
result = wakeup_schedule(wakeup_time, wakeup_reason, true);
|
result = wakeup_schedule(wakeup_time, wakeup_reason, true);
|
||||||
|
|
||||||
if (result == E_RANGE) {
|
// As of SDK 4.44, E_RANGE result no longer needs handled, as it now only reports wakeups scheduled by THIS app;
|
||||||
// E_RANGE means some other app has the same wakeup time +/- 1 minute, so try to set
|
// we call wakeup_cancel_all() above, so E_RANGE will never be encountered
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result >= 0) {
|
if (result >= 0) {
|
||||||
|
|||||||
+1
-1
@@ -16,4 +16,4 @@ typedef struct TheTime {
|
|||||||
|
|
||||||
extern struct TheTime the_time;
|
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