Merge pull request #3846 from storm64/lightswitch

[lightswitch] Add setLCDPower
master
thyttan 2025-05-07 22:11:16 +02:00 committed by GitHub
commit c298a36aba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 10 additions and 3 deletions

View File

@ -8,3 +8,4 @@
0.08: Ensure boot code doesn't allocate and leave a gloval variable named 'settings' 0.08: Ensure boot code doesn't allocate and leave a gloval variable named 'settings'
0.09: Handle lightswitch logic running before its widget has loaded 0.09: Handle lightswitch logic running before its widget has loaded
0.10: Minor code improvements 0.10: Minor code improvements
0.11: Fix issue where backlight is not turned on.

View File

@ -10,13 +10,17 @@ exports = {
unlockSide: "", unlockSide: "",
tapSide: "right", tapSide: "right",
tapOn: "always", tapOn: "always",
isOn: true
}, require("Storage").readJSON("lightswitch.json", true) || {}); }, require("Storage").readJSON("lightswitch.json", true) || {});
// cache lock status // cache lock status
var locked = Bangle.isLocked(); var locked = Bangle.isLocked();
// check to unlock // check to unlock
if (locked && data.dir === w.unlockSide) Bangle.setLocked(); if (locked && data.dir === w.unlockSide) {
Bangle.setLocked();
if (w.isOn) Bangle.setLCDPower(true);
}
// check to flash // check to flash
if (data.dir === w.tapSide && (w.tapOn === "always" || locked === (w.tapOn === "locked"))) require("lightswitch.js").flash(); if (data.dir === w.tapSide && (w.tapOn === "always" || locked === (w.tapOn === "locked"))) require("lightswitch.js").flash();
@ -38,13 +42,14 @@ exports = {
isOn: true isOn: true
}, require("Storage").readJSON("lightswitch.json", true) || {}); }, require("Storage").readJSON("lightswitch.json", true) || {});
// chack if locked, backlight off or actual value lower then minimal flash value // check if locked, backlight off or actual value lower then minimal flash value
if (Bangle.isLocked() || !w.isOn || w.value < w.minFlash) { if (Bangle.isLocked() || !w.isOn || w.value < w.minFlash) {
// set inner bulb and brightness // set inner bulb and brightness
var setBrightness = function(w, value) { var setBrightness = function(w, value) {
if (w.drawInnerBulb) w.drawInnerBulb(value); if (w.drawInnerBulb) w.drawInnerBulb(value);
Bangle.setLCDBrightness(value); Bangle.setLCDBrightness(value);
Bangle.setLCDPower(true);
}; };
// override timeout if defined // override timeout if defined

View File

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

View File

@ -121,6 +121,7 @@
} else { } else {
// activate backlight // activate backlight
this.isOn = true; this.isOn = true;
Bangle.setLCDPower(true);
// redraw complete widget icon // redraw complete widget icon
this.drawIcon(false); this.drawIcon(false);
} }