Fix settings wrapping code for new menu system

pull/1502/head
Gordon Williams 2022-02-23 16:11:34 +00:00
parent 2f571f9600
commit a452887ba6
9 changed files with 32 additions and 30 deletions

View File

@ -13,3 +13,4 @@
Widgets now shown on Alarm screen
0.13: Alarm widget state now updates when setting/resetting an alarm
0.14: Order of 'back' menu item
0.15: Fix hour/minute wrapping code for new menu system

View File

@ -73,12 +73,12 @@ function editAlarm(alarmIndex) {
'': { 'title': /*LANG*/'Alarm' },
/*LANG*/'< Back' : showMainMenu,
/*LANG*/'Hours': {
value: hrs,
onchange: function(v){if (v<0)v=23;if (v>23)v=0;hrs=v;this.value=v;} // no arrow fn -> preserve 'this'
value: hrs, min : 0, max : 23, wrap : true,
onchange: v => hrs=v;
},
/*LANG*/'Minutes': {
value: mins,
onchange: function(v){if (v<0)v=59;if (v>59)v=0;mins=v;this.value=v;} // no arrow fn -> preserve 'this'
value: mins, min : 0, max : 59, wrap : true,
onchange: v => mins=v;
},
/*LANG*/'Enabled': {
value: en,
@ -138,12 +138,12 @@ function editTimer(alarmIndex) {
const menu = {
'': { 'title': /*LANG*/'Timer' },
/*LANG*/'Hours': {
value: hrs,
onchange: function(v){if (v<0)v=23;if (v>23)v=0;hrs=v;this.value=v;} // no arrow fn -> preserve 'this'
value: hrs, min : 0, max : 23, wrap : true,
onchange: v => hrs=v;
},
/*LANG*/'Minutes': {
value: mins,
onchange: function(v){if (v<0)v=59;if (v>59)v=0;mins=v;this.value=v;} // no arrow fn -> preserve 'this'
value: mins, min : 0, max : 59, wrap : true,
onchange: v => mins=v;
},
/*LANG*/'Enabled': {
value: en,

View File

@ -2,7 +2,7 @@
"id": "alarm",
"name": "Default Alarm & Timer",
"shortName": "Alarms",
"version": "0.14",
"version": "0.15",
"description": "Set and respond to alarms and timers",
"icon": "app.png",
"tags": "tool,alarm,widget",

View File

@ -1,2 +1,3 @@
0.01: Add a number to match to turn off alarm
0.02: Respect Quiet Mode
0.03: Fix hour/minute wrapping code for new menu system

View File

@ -56,25 +56,25 @@ function editAlarm(alarmIndex) {
}
const menu = {
'': { 'title': 'Alarms' },
'Hours': {
value: hrs,
onchange: function(v){if (v<0)v=23;if (v>23)v=0;hrs=v;this.value=v;} // no arrow fn -> preserve 'this'
/*LANG*/'Hours': {
value: hrs, min : 0, max : 23, wrap : true,
onchange: v => hrs=v;
},
'Minutes': {
value: mins,
onchange: function(v){if (v<0)v=59;if (v>59)v=0;mins=v;this.value=v;} // no arrow fn -> preserve 'this'
/*LANG*/'Minutes': {
value: mins, min : 0, max : 59, wrap : true,
onchange: v => mins=v;
},
'Enabled': {
/*LANG*/'Enabled': {
value: en,
format: v=>v?"On":"Off",
onchange: v=>en=v
},
'Repeat': {
/*LANG*/'Repeat': {
value: en,
format: v=>v?"Yes":"No",
onchange: v=>repeat=v
},
'Auto snooze': {
/*LANG*/'Auto snooze': {
value: as,
format: v=>v?"Yes":"No",
onchange: v=>as=v

View File

@ -2,7 +2,7 @@
"id": "hardalarm",
"name": "Hard Alarm",
"shortName": "HardAlarm",
"version": "0.02",
"version": "0.03",
"description": "Make sure you wake up! Count to the right number to turn off the alarm",
"icon": "app.png",
"tags": "tool,alarm,widget",

View File

@ -1 +1,2 @@
0.01: New App!
0.02: Fix settings wrapping code for new menu system

View File

@ -2,7 +2,7 @@
"id": "tabata",
"name": "Tabata",
"shortName": "Tabata - Control High-Intensity Interval Training",
"version": "0.01",
"version": "0.02",
"description": "Control high-intensity interval training (according to tabata: https://en.wikipedia.org/wiki/Tabata_method).",
"icon": "tabata.png",
"tags": "workout,health",

View File

@ -30,18 +30,17 @@ function showMainMenu() {
},
'Pause sec.': {
value: settings.pause,
onchange: function(v){
if (v<0)v=MAX_SECONDS;
if (v>MAX_SECONDS)v=0;
min : 0, max : MAX_SECONDS, wrap : true,
onchange: v => {
settings.pause=v;
this.value=v;
saveSettingsDebounce();
}
},
'Trainig sec.': {
value: settings.training,
onchange: function(v){if (v<0)v=MAX_SECONDS;if (v>MAX_SECONDS)v=0;settings.training=v;
this.value=v;
min : 0, max : MAX_SECONDS, wrap : true,
onchange: v => {
settings.training=v;
saveSettingsDebounce();
}
},
@ -61,8 +60,8 @@ function startTabata() {
g.clear();
Bangle.setLCDMode("doublebuffered");
g.flip();
var pause = settings.pause,
training = settings.training,
var pause = settings.pause,
training = settings.training,
round = 1,
active = true,
clearBtn1, clearBtn2, clearBtn3, timer;
@ -86,7 +85,7 @@ function startTabata() {
exitTraining();
return;
}
if (active) {
drawCountDown(round, training, active);
training--;
@ -117,7 +116,7 @@ function drawCountDown(round, count, active) {
g.setFontAlign(0,0);
g.setFont("6x8", 2);
g.drawString("Round " + round + "/" + settings.rounds,120,6);
g.drawString("Round " + round + "/" + settings.rounds,120,6);
g.setFont("6x8", 6);
g.drawString("" + count,120,80);