diff --git a/apps/lightswitch/README.md b/apps/lightswitch/README.md index 46c383a92..c17a6a4ed 100644 --- a/apps/lightswitch/README.md +++ b/apps/lightswitch/README.md @@ -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__ diff --git a/apps/lightswitch/settings.js b/apps/lightswitch/settings.js index 5ac70bc28..aff45a444 100644 --- a/apps/lightswitch/settings.js +++ b/apps/lightswitch/settings.js @@ -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, diff --git a/apps/lightswitch/widget.js b/apps/lightswitch/widget.js index 8ba139d4a..922875216 100644 --- a/apps/lightswitch/widget.js +++ b/apps/lightswitch/widget.js @@ -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);