lightswitch 0.03: Settings page now uses built-in min/max/wrap (fix #1607)

master
Gordon Williams 2022-03-22 09:48:45 +00:00
parent 86e2ab5919
commit 2ba72f8954
3 changed files with 12 additions and 7 deletions

View File

@ -1,2 +1,3 @@
0.01: New App!
0.02: Add the option to enable touching the widget only on clock and settings.
0.03: Settings page now uses built-in min/max/wrap (fix #1607)

View File

@ -2,7 +2,7 @@
"id": "lightswitch",
"name": "Light Switch Widget",
"shortName": "Light Switch",
"version": "0.02",
"version": "0.03",
"description": "A fast way to switch LCD backlight on/off, change the brightness and show the lock status. All in one widget.",
"icon": "images/app.png",
"screenshots": [

View File

@ -44,9 +44,11 @@
// return entry for string value
return {
value: entry.value.indexOf(settings[key]),
min : 0,
max : entry.value.length-1,
wrap : true,
format: v => entry.title ? entry.title[v] : entry.value[v],
onchange: function(v) {
this.value = v = v >= entry.value.length ? 0 : v < 0 ? entry.value.length - 1 : v;
writeSetting(key, entry.value[v], entry.drawWidgets);
if (entry.exec) entry.exec(entry.value[v]);
}
@ -57,8 +59,10 @@
value: settings[key] * entry.factor,
step: entry.step,
format: v => v > 0 ? v + entry.unit : "off",
min : entry.min,
max : entry.max,
wrap : true,
onchange: function(v) {
this.value = v = v > entry.max ? entry.min : v < entry.min ? entry.max : v;
writeSetting(key, v / entry.factor, entry.drawWidgets);
},
};
@ -133,16 +137,16 @@
title: "Light Switch"
},
"< Back": () => back(),
"-- Widget --------": 0,
"-- Widget": 0,
"Bulb col": getEntry("colors"),
"Image": getEntry("image"),
"-- Control -------": 0,
"-- Control": 0,
"Touch": getEntry("touchOn"),
"Drag Delay": getEntry("dragDelay"),
"Min Value": getEntry("minValue"),
"-- Unlock --------": 0,
"-- Unlock": 0,
"TapSide": getEntry("unlockSide"),
"-- Flash ---------": 0,
"-- Flash": 0,
"TapSide ": getEntry("tapSide"),
"Tap": getEntry("tapOn"),
"Timeout": getEntry("tOut"),