alarm 0.18: Cope with >1 identical alarm at once (#1667)
parent
3c28c0c9c9
commit
2c36071a37
|
|
@ -16,3 +16,4 @@
|
||||||
0.15: Fix hour/minute wrapping code for new menu system
|
0.15: Fix hour/minute wrapping code for new menu system
|
||||||
0.16: Adding alarm library
|
0.16: Adding alarm library
|
||||||
0.17: Moving alarm internals to 'sched' library
|
0.17: Moving alarm internals to 'sched' library
|
||||||
|
0.18: Cope with >1 identical alarm at once (#1667)
|
||||||
|
|
|
||||||
|
|
@ -45,12 +45,22 @@ function showMainMenu() {
|
||||||
/*LANG*/'New Timer': ()=>editTimer(-1)
|
/*LANG*/'New Timer': ()=>editTimer(-1)
|
||||||
};
|
};
|
||||||
alarms.forEach((alarm,idx)=>{
|
alarms.forEach((alarm,idx)=>{
|
||||||
var txt; // a leading space is currently required (JS error in Espruino 2v12)
|
var type,txt; // a leading space is currently required (JS error in Espruino 2v12)
|
||||||
if (alarm.timer)
|
if (alarm.timer) {
|
||||||
txt = /*LANG*/"Timer"+" "+formatTime(alarm.timer);
|
type = /*LANG*/"Timer";
|
||||||
else
|
txt = " "+formatTime(alarm.timer);
|
||||||
txt = /*LANG*/"Alarm"+" "+formatTime(alarm.t);
|
} else {
|
||||||
|
type = /*LANG*/"Alarm";
|
||||||
|
txt = " "+formatTime(alarm.t);
|
||||||
|
}
|
||||||
if (alarm.rp) txt += "\0"+atob("FBaBAAABgAAcAAHn//////wAHsABzAAYwAAMAADAAAAAAwAAMAADGAAzgAN4AD//////54AAOAABgAA=");
|
if (alarm.rp) txt += "\0"+atob("FBaBAAABgAAcAAHn//////wAHsABzAAYwAAMAADAAAAAAwAAMAADGAAzgAN4AD//////54AAOAABgAA=");
|
||||||
|
// rename duplicate alarms
|
||||||
|
if (menu[type+txt]) {
|
||||||
|
var n = 2;
|
||||||
|
while (menu[type+" "+n+txt]) n++;
|
||||||
|
txt = type+" "+n+txt;
|
||||||
|
} else txt = type+txt;
|
||||||
|
// add to menu
|
||||||
menu[txt] = {
|
menu[txt] = {
|
||||||
value : "\0"+atob(alarm.on?"EhKBAH//v/////////////5//x//j//H+eP+Mf/A//h//z//////////3//g":"EhKBAH//v//8AA8AA8AA8AA8AA8AA8AA8AA8AA8AA8AA8AA8AA8AA///3//g"),
|
value : "\0"+atob(alarm.on?"EhKBAH//v/////////////5//x//j//H+eP+Mf/A//h//z//////////3//g":"EhKBAH//v//8AA8AA8AA8AA8AA8AA8AA8AA8AA8AA8AA8AA8AA8AA///3//g"),
|
||||||
onchange : function() {
|
onchange : function() {
|
||||||
|
|
@ -84,7 +94,7 @@ function editAlarm(alarmIndex, alarm) {
|
||||||
var a = {
|
var a = {
|
||||||
t : 12*3600000, // 12 o clock default
|
t : 12*3600000, // 12 o clock default
|
||||||
on : true,
|
on : true,
|
||||||
rp : true,
|
rp : false, // repeat not the default
|
||||||
as : false,
|
as : false,
|
||||||
dow : 0b1111111,
|
dow : 0b1111111,
|
||||||
last : 0,
|
last : 0,
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
"id": "alarm",
|
"id": "alarm",
|
||||||
"name": "Alarm & Timer",
|
"name": "Alarm & Timer",
|
||||||
"shortName": "Alarms",
|
"shortName": "Alarms",
|
||||||
"version": "0.17",
|
"version": "0.18",
|
||||||
"description": "Set alarms and timers on your Bangle",
|
"description": "Set alarms and timers on your Bangle",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
"tags": "tool,alarm,widget",
|
"tags": "tool,alarm,widget",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue