1
0
Fork 0

Merge pull request #2510 from Kedlub/alarmevent

Emit events on alarm snooze/dismiss and new app
master
Gordon Williams 2023-01-19 11:11:48 +00:00 committed by GitHub
commit 57f5f92334
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 38 additions and 1 deletions

1
apps/alarmqm/ChangeLog Normal file
View File

@ -0,0 +1 @@
0.01: New App!

BIN
apps/alarmqm/app.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

20
apps/alarmqm/boot.js Normal file
View File

@ -0,0 +1,20 @@
(function () {
function dismissAlarm(alarm) {
// Run only for alarms, not timers
if (!alarm.timer) {
if ("qmsched" in WIDGETS) {
require("qmsched").setMode(0);
} else {
// Code from qmsched.js, so we can work without it
require("Storage").writeJSON(
"setting.json",
Object.assign(require("Storage").readJSON("setting.json", 1) || {}, {
quiet: 0,
})
);
}
}
}
Bangle.on("alarmDismiss", dismissAlarm);
})();

View File

@ -0,0 +1,13 @@
{ "id": "alarmqm",
"name": "Alarm Quiet Mode",
"shortName":"AlarmQM",
"version":"0.01",
"description": "Service that turns off quiet mode after alarm dismiss",
"icon": "app.png",
"tags": "quiet,alarm",
"supports" : ["BANGLEJS2"],
"type": "bootloader",
"storage": [
{"name":"alarmqm.boot.js","url":"boot.js"}
]
}

View File

@ -20,3 +20,4 @@
0.17: Fix midnight in local timezone (alarms wouldn't always fire as expected in timezone != 0)
0.18: Update clock_info to avoid a redraw
0.19: Update clock_info to refresh periodically on active alarms/timers
0.20: Alarm dismiss and snooze events

View File

@ -1,7 +1,7 @@
{
"id": "sched",
"name": "Scheduler",
"version": "0.19",
"version": "0.20",
"description": "Scheduling library for alarms and timers",
"icon": "app.png",
"type": "scheduler",

View File

@ -36,6 +36,7 @@ function showAlarm(alarm) {
alarm.ot = alarm.t;
}
alarm.t += settings.defaultSnoozeMillis;
Bangle.emit("alarmSnooze", alarm);
} else {
let del = alarm.del === undefined ? settings.defaultDeleteExpiredTimers : alarm.del;
if (del) {
@ -52,6 +53,7 @@ function showAlarm(alarm) {
alarm.on = false;
}
}
Bangle.emit("alarmDismiss", alarm);
}
// The updated alarm is still a member of 'alarms'