Skip to content

Commit aad797d

Browse files
authored
Merge pull request #3946 from RKBoss6/backlite-update
[BackLite] Fix settings bug
2 parents 0769af1 + 663480b commit aad797d

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

apps/backlite/ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
0.01: New app! (settings, boot.js).
2+
0.02: Fix settings defaulting brightness to 0

apps/backlite/boot.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
//Set LCD to zero every reboot
1212
let s = require("Storage").readJSON("setting.json", 1) || {};
1313
s.brightness = 0;
14-
if (!("lcdTimeout" in s)) s.lcdTimeout = 5; // fallback so logic doesn't break
1514
require("Storage").writeJSON("setting.json", s);
16-
15+
//remove large settings object from memory
16+
delete s;
1717
const longPressTime=400; //(ms)
1818

1919
Bangle.on('lock', function(isLocked) {

apps/backlite/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "backlite",
33
"name": "BackLite",
4-
"version": "0.01",
4+
"version": "0.02",
55
"description": "Conserves battery life by turning the backlight on only on a long press of the button from a locked state. **Requires the latest settings update (v0.80)**",
66
"icon": "icon.png",
77
"type": "bootloader",

apps/backlite/settings.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
(function(back) {
22
var FILE = "BackLite.settings.json";
3-
// Load settings
4-
var settings = Object.assign({
5-
brightness: 0.3,
6-
}, require('Storage').readJSON(FILE, true) || {});
3+
4+
var settings = require("Storage").readJSON(FILE, 1) || {};
5+
6+
if (!isFinite(settings.brightness)) settings.brightness = 0.3;
77

88
function writeSettings() {
9-
require('Storage').writeJSON(FILE, settings);
9+
require("Storage").writeJSON(FILE, settings);
1010
}
1111

12-
// Show the menu
1312
E.showMenu({
1413
"" : { "title" : "BackLite" },
15-
'Brightness': {
16-
value: 0.3|settings.brightness,
14+
"< Back": back, // fallback if run standalone
15+
"Brightness": {
16+
value: settings.brightness,
1717
min: 0.1, max: 1,
1818
step: 0.1,
1919
onchange: v => {

0 commit comments

Comments
 (0)