multitimer: allow one-shot alarms (delete after)

pull/2781/head
Rob Pilling 2023-05-29 12:00:48 +01:00
parent 855f196fd3
commit 6edcae393c
5 changed files with 24 additions and 10 deletions

View File

@ -1,3 +1,4 @@
0.01: Initial version
0.02: Update for time_utils module
0.03: Use default Bangle formatter for booleans
0.04: Add "Oneshot" setting to delete an alarm/timer after it sounds

View File

@ -2,6 +2,7 @@
With this app, you can set timers and chronographs (stopwatches) and watch them count down/up in real time. You can also set alarms - swipe left or right to switch between the three functions.
"Hard mode" is also available for timers and alarms. It will double the number of buzz counts and you will have to swipe the screen five to eight times correctly - make a mistake, and you will need to start over.
"Oneshot" can be set on timers and alarms to have it delete itself once it's sounded.
## WARNING
* Editing timers in another app (such as the default Alarm app) is not recommended. Editing alarms should not be a problem (in theory).

View File

@ -105,7 +105,13 @@ function showAlarm(alarm) {
alarm.t = alarm.ot;
delete alarm.ot;
}
if (!alarm.rp) alarm.on = false;
if (!alarm.rp) {
alarm.on = false;
if (alarm.data.oneshot) {
const i = alarms.indexOf(alarm);
if (i >= 0) alarms.splice(i, 1);
}
}
}
//reset timer value
if (alarm.timer) alarm.timer = alarm.data.ot;

View File

@ -228,8 +228,7 @@ function editTimer(idx, a) {
else a = timers[idx];
}
if (!a.data) {
a.data = {};
a.data.hm = false;
a.data = { hm: false, oneshot: false };
}
var t = decodeTime(a.timer);
@ -291,10 +290,14 @@ function editTimer(idx, a) {
}
},
"Hard Mode": {
value: a.data.hm,
value: !!a.data.hm,
onchange: v => a.data.hm = v
},
"Vibrate": require("buzz_menu").pattern(a.vibrate, v => a.vibrate = v),
"Oneshot": {
value: !!a.data.oneshot,
onchange: v => a.data.oneshot = v
},
"Msg": {
value: !a.msg ? "" : a.msg.length > 6 ? a.msg.substring(0, 6)+"..." : a.msg,
//menu glitch? setTimeout required here
@ -556,8 +559,7 @@ function editAlarm(idx, a) {
else a = require("sched").newDefaultAlarm();
}
if (!a.data) {
a.data = {};
a.data.hm = false;
a.data = { hm: false, oneshot: false };
}
var t = decodeTime(a.t);
@ -582,8 +584,8 @@ function editAlarm(idx, a) {
var menu = {
"": { "title": "Alarm" },
"< Back": () => {
if (a.data.hm == true) a.js = "(require('Storage').read('multitimer.alarm.js') !== undefined) ? load('multitimer.alarm.js') : load('sched.js')";
if (a.data.hm == false && a.js) delete a.js;
if (a.data.hm || a.data.oneshot) a.js = "(require('Storage').read('multitimer.alarm.js') !== undefined) ? load('multitimer.alarm.js') : load('sched.js')";
else if (a.js) delete a.js;
if (idx >= 0) alarms[alarmIdx[idx]] = a;
else alarms.push(a);
require("sched").setAlarms(alarms);
@ -617,10 +619,14 @@ function editAlarm(idx, a) {
onchange: () => editDOW(a.dow, d=>{a.dow=d;editAlarm(idx,a);})
},
"Hard Mode": {
value: a.data.hm,
value: !!a.data.hm,
onchange: v => a.data.hm = v
},
"Vibrate": require("buzz_menu").pattern(a.vibrate, v => a.vibrate = v),
"Oneshot": {
value: !!a.data.oneshot,
onchange: v => a.data.oneshot = v
},
"Auto Snooze": {
value: a.as,
onchange: v => a.as = v

View File

@ -1,7 +1,7 @@
{
"id": "multitimer",
"name": "Multi Timer",
"version": "0.03",
"version": "0.04",
"description": "Set timers and chronographs (stopwatches) and watch them count down in real time. Pause, create, edit, and delete timers and chronos, and add custom labels/messages. Also sets alarms.",
"icon": "app.png",
"screenshots": [