Merge pull request #471 from m0n5t3r/master

Add auto-snooze option to alarms
pull/475/head
Gordon Williams 2020-06-02 07:53:17 +01:00 committed by GitHub
commit 2bbecfc7f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 2 deletions

View File

@ -140,7 +140,7 @@
"name": "Default Alarm",
"shortName":"Alarms",
"icon": "app.png",
"version":"0.08",
"version":"0.09",
"description": "Set and respond to alarms",
"tags": "tool,alarm,widget",
"storage": [

View File

@ -6,3 +6,4 @@
0.06: Change 'New Alarm' to 'Save', allow Deletion of Alarms
0.07: Don't overwrite existing settings on app update
0.08: Make alarm scheduling more reliable
0.09: Add per alarm auto-snooze option

View File

@ -24,9 +24,14 @@ function showAlarm(alarm) {
}).then(function(sleep) {
buzzCount = 0;
if (sleep) {
if(alarm.ohr===undefined) alarm.ohr = alarm.hr;
alarm.hr += 10/60; // 10 minutes
} else {
alarm.last = (new Date()).getDate();
if (alarm.ohr!==undefined) {
alarm.hr = alarm.ohr;
delete alarm.ohr;
}
if (!alarm.rp) alarm.on = false;
}
require("Storage").write("alarm.json",JSON.stringify(alarms));
@ -38,6 +43,10 @@ function showAlarm(alarm) {
Bangle.buzz(100).then(function() {
if (buzzCount--)
setTimeout(buzz, 3000);
else if(alarm.as) { // auto-snooze
buzzCount = 10;
setTimeout(buzz, 600000);
}
});
},100);
});

View File

@ -8,6 +8,7 @@ var alarms = require("Storage").readJSON("alarm.json",1)||[];
msg : "Eat chocolate",
last : 0, // last day of the month we alarmed on - so we don't alarm twice in one day!
rp : true, // repeat
as : true, // auto snooze
}
];*/
@ -50,6 +51,7 @@ function editAlarm(alarmIndex) {
mins = Math.round((a.hr-hrs)*60);
en = a.on;
repeat = a.rp;
as = a.as;
}
const menu = {
'': { 'title': 'Alarms' },
@ -70,6 +72,11 @@ function editAlarm(alarmIndex) {
value: en,
format: v=>v?"Yes":"No",
onchange: v=>repeat=v
},
'Auto snooze': {
value: en,
format: v=>v?"Yes":"No",
onchange: v=>as=v
}
};
function getAlarm() {
@ -81,7 +88,7 @@ function editAlarm(alarmIndex) {
// Save alarm
return {
on : en, hr : hr,
last : day, rp : repeat
last : day, rp : repeat, as: as
};
}
menu["> Save"] = function() {