Skip to content

Commit bc032b8

Browse files
author
thyttan
committed
Merge branch 'twenties' into app-loader
2 parents 3e4923f + 1aa4222 commit bc032b8

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

apps/twenties/boot.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
var isTwentiesInstalled = true; // Used to clear the alarms set by `twenties` if it is uninstalled. See `twenties.setup.js`.
12
{
23
let alarms = require("sched").getAlarms();
34
if (!alarms.find(a => a.appid == "twenties")) { // Only set up alarms if they aren't already.

apps/twenties/setup.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
{ // this code is called from `twenties.boot.js` in a scope where the `alarms` variable is defined.
22

33
const NUMBER_OF_ALARMS_TO_SCHEDULE = (17 - 8) * 3; // start at 8 o'clock, end at 17 o'clock. Fire every 1/3 of an hour.
4+
const J́S_BUZZ_OR_DELETE_ALARMS = `{
5+
if (!isTwentiesInstalled) {
6+
let alarms = require("sched").getAlarms();
7+
alarms = alarms.filter((alarm) => {alarm.appid === "twenties"});
8+
alarms.forEach(alarm => {
9+
require("sched").setAlarm(alarm.id, undefined);
10+
});
11+
require("sched").reload();
12+
} else {Bangle.buzz()}
13+
}`
414
for (let i = 0; i < NUMBER_OF_ALARMS_TO_SCHEDULE + 1; i++) {
515
for (let j = 0; j < 2; j++) {
616
alarms.push({
@@ -10,10 +20,7 @@
1020
t: 8 * 3600000 + i * 20 * 60000 + j * 20 * 1000,
1121
dow: 0b0111110,
1222
hidden: true,
13-
js: "Bangle.buzz()" // OPTIONAL - a JS command to execute when the alarm activates (*instead* of loading 'sched.js')
14-
// when this code is run, you're responsible for setting alarm.on=false (or removing the alarm)
15-
// hack that let's us repeat without writing out the day strings in the menu scroller - which was heavy on the watch with so many alarms. Testing to evaluate effectiveness.
16-
// TODO: Does this still make it so alarms are only fired on weekdays?
23+
js: J́S_BUZZ_OR_DELETE_ALARMS
1724
});
1825
}
1926
}

0 commit comments

Comments
 (0)