lightswitch: tap-to-lock setting

pull/2543/head
Rob Pilling 2023-01-29 22:48:23 +00:00
parent 1a97f2bf41
commit fe9572bdbe
3 changed files with 16 additions and 2 deletions

View File

@ -51,6 +51,8 @@ All touch and drag inputs related to this widget are cached/masked to prevent ac
* __Min Value__
_1%_ / _2%_ / _..._ / __10%__ / _..._ / _100%_
Set the minimal level of brightness you can change to.
* __Tap to lock__
Tapping the widget locks the screen, rather than toggling brightness.
#### Unlock - Set double tap side to unlock:
* __TapSide__

View File

@ -10,6 +10,7 @@
oversize: 20,
dragDelay: 500,
minValue: 0.1,
tapToLock: false,
unlockSide: "",
tapSide: "right",
tapOn: "always",
@ -119,6 +120,11 @@
max: 100,
step: 1
},
tapToLock: {
title: ["on", "off"],
value: [true, false],
drawWidgets: false
},
unlockSide: {
title: ["off", "left", "right", "top", "bottom", "front", "back"],
value: ["", "left", "right", "top", "bottom", "front", "back"]
@ -154,6 +160,7 @@
"Oversize": getEntry("oversize"),
"Drag Delay": getEntry("dragDelay"),
"Min Value": getEntry("minValue"),
"Tap to lock": getEntry("tapToLock"),
"-- Unlock": 0,
"TapSide": getEntry("unlockSide"),
"-- Flash": 0,

View File

@ -7,6 +7,7 @@
oversize: 20,
dragDelay: 500,
minValue: 0.1,
tapToLock: false,
unlockSide: "",
tapSide: "right",
tapOn: "always",
@ -208,8 +209,12 @@
w.dragStatus = "off";
}, w.dragDelay, w);
}
// switch backlight
w.changeValue();
if (w.tapToLock) {
Bangle.setLocked(true);
} else {
// switch backlight
w.changeValue();
}
// masks this touch event by messing up the event handler
// see https://github.com/espruino/Espruino/issues/2151
Bangle.removeListener("touch", w.touchListener);