Skip to content

Commit c298a36

Browse files
authored
Merge pull request espruino#3846 from storm64/lightswitch
[lightswitch] Add setLCDPower
2 parents 77e974a + e9d3c1d commit c298a36

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

apps/lightswitch/ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
0.08: Ensure boot code doesn't allocate and leave a gloval variable named 'settings'
99
0.09: Handle lightswitch logic running before its widget has loaded
1010
0.10: Minor code improvements
11+
0.11: Fix issue where backlight is not turned on.

apps/lightswitch/lib.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,17 @@ exports = {
1010
unlockSide: "",
1111
tapSide: "right",
1212
tapOn: "always",
13+
isOn: true
1314
}, require("Storage").readJSON("lightswitch.json", true) || {});
1415

1516
// cache lock status
1617
var locked = Bangle.isLocked();
1718

1819
// check to unlock
19-
if (locked && data.dir === w.unlockSide) Bangle.setLocked();
20+
if (locked && data.dir === w.unlockSide) {
21+
Bangle.setLocked();
22+
if (w.isOn) Bangle.setLCDPower(true);
23+
}
2024

2125
// check to flash
2226
if (data.dir === w.tapSide && (w.tapOn === "always" || locked === (w.tapOn === "locked"))) require("lightswitch.js").flash();
@@ -38,13 +42,14 @@ exports = {
3842
isOn: true
3943
}, require("Storage").readJSON("lightswitch.json", true) || {});
4044

41-
// chack if locked, backlight off or actual value lower then minimal flash value
45+
// check if locked, backlight off or actual value lower then minimal flash value
4246
if (Bangle.isLocked() || !w.isOn || w.value < w.minFlash) {
4347

4448
// set inner bulb and brightness
4549
var setBrightness = function(w, value) {
4650
if (w.drawInnerBulb) w.drawInnerBulb(value);
4751
Bangle.setLCDBrightness(value);
52+
Bangle.setLCDPower(true);
4853
};
4954

5055
// override timeout if defined

apps/lightswitch/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"id": "lightswitch",
33
"name": "Light Switch Widget",
44
"shortName": "Light Switch",
5-
"version": "0.10",
5+
"version": "0.11",
66
"description": "A fast way to switch LCD backlight on/off, change the brightness and show the lock status. All in one widget.",
77
"icon": "images/app.png",
88
"screenshots": [

apps/lightswitch/widget.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@
121121
} else {
122122
// activate backlight
123123
this.isOn = true;
124+
Bangle.setLCDPower(true);
124125
// redraw complete widget icon
125126
this.drawIcon(false);
126127
}

0 commit comments

Comments
 (0)