Skip to content

Commit 6ac5b76

Browse files
committed
sched 0.39: Allow a press of the button to stop/snooze the alarm when it's gone off (fix espruino#3753)
1 parent 94d1ceb commit 6ac5b76

6 files changed

Lines changed: 23 additions & 9 deletions

File tree

apps/sched/ChangeLog

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,5 @@
3838
0.35: If you use 2v28 (or above) firmware, you can long-press on the snooze button to gain finer control over snooze lengths.
3939
0.36: Make 'Unlock At Buzz' (unlocking the watch when the alarm goes off) default to true
4040
0.37: Ensure we always execute an alarm, even if it was >1 minute in the past. This fixes missed alarms when >1 alarm is scheduled next to each other (fix #2712)
41-
0.38: Fix timer going off immediately if it was long enough it went to the next day (#4220)
41+
0.38: Fix timer going off immediately if it was long enough it went to the next day (#4220)
42+
0.39: Allow a press of the button to stop/snooze the alarm when it's gone off

apps/sched/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ With sched version 0.35 or later, when an alarm or timer is triggered, and you h
2121
- `Unlock at Buzz` - If `Yes` the alarm/timer will unlock the watch
2222
- `Delete Expired Timers` - Default for whether expired timers are removed after firing.
2323
- `Default Auto Snooze` - Default _Auto Snooze_ value for newly created alarms (_Alarms_ only)
24+
- `Button Stops Alarm` - When the alarm screen is showing, pressing the button will stop the alarm (instead of snoozing it)
2425
- `Default Snooze` - Default _Snooze_ value for newly created alarms/timers
2526
- `Buzz Count` - The number of buzzes before the watch goes silent, or "forever" to buzz until stopped.
2627
- `Buzz Interval` - The interval between one buzz and the next

apps/sched/lib.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ exports.getSettings = function () {
106106
defaultSnoozeMillis: 600000, // 10 minutes
107107
defaultAutoSnooze: false,
108108
defaultDeleteExpiredTimers: true, // Always
109+
btnToStop: false, // pressing the button on the alarm screen will stop the alarm instead of snoozing it
109110
buzzCount: 10,
110111
buzzIntervalMillis: 3000, // 3 seconds
111112
defaultAlarmPattern: "==",

apps/sched/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "sched",
33
"name": "Scheduler",
4-
"version": "0.38",
4+
"version": "0.39",
55
"author": "gfwilliams",
66
"description": "Scheduling library for alarms and timers",
77
"icon": "app.png",

apps/sched/sched.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,7 @@ function showAlarm(alarm) {
7575

7676
let buzzCount = settings.buzzCount;
7777

78-
E.showPrompt(message, {
79-
title: alarm.timer ? /*LANG*/"TIMER!" : /*LANG*/"ALARM!",
80-
buttons: { /*LANG*/"Snooze": 1, /*LANG*/"Stop": 2 }, // default is sleep so it'll come back in some mins
81-
buttonsLong:{/*LANG*/"Snooze":3},
82-
}).then(function (sleep) {
78+
function stopOrSleep(sleep) {
8379
buzzCount = 0;
8480
//long press triggered
8581
if(sleep==3){
@@ -95,7 +91,7 @@ function showAlarm(alarm) {
9591
alarm.t = currentTime + settings.defaultSnoozeMillis;
9692
alarm.t %= 86400000;
9793
Bangle.emit("alarmSnooze", alarm);
98-
} else {
94+
} else { // sleep=2, stop the alarm
9995
let del = alarm.del === undefined ? settings.defaultDeleteExpiredTimers : alarm.del;
10096
if (del) {
10197
alarms.splice(alarmIndex, 1);
@@ -120,7 +116,14 @@ function showAlarm(alarm) {
120116
// so writing to array writes changes back directly
121117
require("sched").setAlarms(alarms);
122118
load();
123-
});
119+
}
120+
121+
E.showPrompt(message, {
122+
title: alarm.timer ? /*LANG*/"TIMER!" : /*LANG*/"ALARM!",
123+
buttons: { /*LANG*/"Snooze": 1, /*LANG*/"Stop": 2 }, // default is sleep so it'll come back in some mins
124+
buttonsLong:{/*LANG*/"Snooze":3},
125+
back: () => stopOrSleep(settings.btnToStop ? 2 : 1)
126+
}).then(stopOrSleep);
124127

125128
function buzz() {
126129
if (settings.unlockAtBuzz) {

apps/sched/settings.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@
3030
}
3131
},
3232

33+
/*LANG*/"Button Stops Alarm": {
34+
value: settings.btnToStop,
35+
onchange: v => {
36+
settings.btnToStop = v;
37+
require("sched").setSettings(settings);
38+
}
39+
},
40+
3341
/*LANG*/"Default Snooze": {
3442
value: settings.defaultSnoozeMillis / 60000,
3543
min: 5,

0 commit comments

Comments
 (0)