Fix settings wrapping code for new menu system

master
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 Widgets now shown on Alarm screen
0.13: Alarm widget state now updates when setting/resetting an alarm 0.13: Alarm widget state now updates when setting/resetting an alarm
0.14: Order of 'back' menu item 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' }, '': { 'title': /*LANG*/'Alarm' },
/*LANG*/'< Back' : showMainMenu, /*LANG*/'< Back' : showMainMenu,
/*LANG*/'Hours': { /*LANG*/'Hours': {
value: hrs, value: hrs, min : 0, max : 23, wrap : true,
onchange: function(v){if (v<0)v=23;if (v>23)v=0;hrs=v;this.value=v;} // no arrow fn -> preserve 'this' onchange: v => hrs=v;
}, },
/*LANG*/'Minutes': { /*LANG*/'Minutes': {
value: mins, value: mins, min : 0, max : 59, wrap : true,
onchange: function(v){if (v<0)v=59;if (v>59)v=0;mins=v;this.value=v;} // no arrow fn -> preserve 'this' onchange: v => mins=v;
}, },
/*LANG*/'Enabled': { /*LANG*/'Enabled': {
value: en, value: en,
@ -138,12 +138,12 @@ function editTimer(alarmIndex) {
const menu = { const menu = {
'': { 'title': /*LANG*/'Timer' }, '': { 'title': /*LANG*/'Timer' },
/*LANG*/'Hours': { /*LANG*/'Hours': {
value: hrs, value: hrs, min : 0, max : 23, wrap : true,
onchange: function(v){if (v<0)v=23;if (v>23)v=0;hrs=v;this.value=v;} // no arrow fn -> preserve 'this' onchange: v => hrs=v;
}, },
/*LANG*/'Minutes': { /*LANG*/'Minutes': {
value: mins, value: mins, min : 0, max : 59, wrap : true,
onchange: function(v){if (v<0)v=59;if (v>59)v=0;mins=v;this.value=v;} // no arrow fn -> preserve 'this' onchange: v => mins=v;
}, },
/*LANG*/'Enabled': { /*LANG*/'Enabled': {
value: en, value: en,

View File

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

View File

@ -1,2 +1,3 @@
0.01: Add a number to match to turn off alarm 0.01: Add a number to match to turn off alarm
0.02: Respect Quiet Mode 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 = { const menu = {
'': { 'title': 'Alarms' }, '': { 'title': 'Alarms' },
'Hours': { /*LANG*/'Hours': {
value: hrs, value: hrs, min : 0, max : 23, wrap : true,
onchange: function(v){if (v<0)v=23;if (v>23)v=0;hrs=v;this.value=v;} // no arrow fn -> preserve 'this' onchange: v => hrs=v;
}, },
'Minutes': { /*LANG*/'Minutes': {
value: mins, value: mins, min : 0, max : 59, wrap : true,
onchange: function(v){if (v<0)v=59;if (v>59)v=0;mins=v;this.value=v;} // no arrow fn -> preserve 'this' onchange: v => mins=v;
}, },
'Enabled': { /*LANG*/'Enabled': {
value: en, value: en,
format: v=>v?"On":"Off", format: v=>v?"On":"Off",
onchange: v=>en=v onchange: v=>en=v
}, },
'Repeat': { /*LANG*/'Repeat': {
value: en, value: en,
format: v=>v?"Yes":"No", format: v=>v?"Yes":"No",
onchange: v=>repeat=v onchange: v=>repeat=v
}, },
'Auto snooze': { /*LANG*/'Auto snooze': {
value: as, value: as,
format: v=>v?"Yes":"No", format: v=>v?"Yes":"No",
onchange: v=>as=v onchange: v=>as=v

View File

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

View File

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

View File

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

View File

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