Skip to content
Draft
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/backlite/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
0.01: New app! (settings, boot.js).
0.02: Fix settings defaulting brightness to 0
0.03: When button is released, cancel long press check. (Remove false triggers)
6 changes: 3 additions & 3 deletions apps/backlite/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# BackLite
### This app needs the latest settings app update (v 0.80), to ensure that setting the brightness to `0` does not default to `1`.

BackLite is an app which greatly conserves battery life by only turning the backlight on when you long press the button from a locked state.

Modern watches have a dedicated button to turn the backlight on, so as not to waste battery in an already light environment. This app recreates that functionality for the Bangle.js, which only has one button.
#### This app needs settings v0.80 or later to ensure that setting the brightness to `0` does not default to `1`.

#### Warning: This app overwrites the LCD brightness setting in `Bangle.js LCD settings`. If it is changed, the app will basically lose functionality. It auto-fixes itself every boot, so if you change the brightness, just reboot :)
This app overwrites the LCD brightness setting in `Bangle.js LCD settings`. If it is changed, the app automatically fixes it every boot, so if you change the brightness, just reboot :)
# Usage
When you unlock with a press of the button, or any other way you unlock the watch, the backlight will not turn on, as most of the time you are able to read it, due to the transreflective display on the Bangle.js 2.

If you press and hold the button to unlock the watch (for around half a second), the backlight will turn on for 5 seconds - just enough to see what you need to see. After that, it will turn off again.
If you press and hold the button to unlock the watch (for around half a second), the backlight will turn on, and stay on until the watch locks.

Some apps like `Light Switch Widget` will prevent this app from working properly.
# Settings
Expand Down
16 changes: 13 additions & 3 deletions apps/backlite/boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,36 @@
//Set LCD to zero every reboot
let s = require("Storage").readJSON("setting.json", 1) || {};
s.brightness = 0;
if (!("lcdTimeout" in s)) s.lcdTimeout = 5; // fallback so logic doesn't break
require("Storage").writeJSON("setting.json", s);
//remove large settings object from memory
delete s;
s=null;
const longPressTime=400; //(ms)

var longPressTimer;
Bangle.on('lock', function(isLocked) {
Bangle.setLCDBrightness(0);

if (!isLocked) {
// Just unlocked — give a short delay and check if BTN1 is still pressed
setTimeout(() => {
longPressTimer=setTimeout(() => {
if (digitalRead(BTN1)) {
//set brightness until. locked.
Comment on lines +25 to 27
Copy link
Collaborator

@bobrippling bobrippling Oct 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't work, and if you press, release, and then press quickly, it still checks for the button and lights up the screen, even with the checks in place. @bobrippling do you have any idea why that could be?

I don't think my below suggestion is right unless there's a race between 'clearTimeout()` and the invocation of the timeout func.

If you add debug logs to both the timeout function (each arm of the if) and the setWatch callback, what gets printed?

Suggested change
longPressTimer=setTimeout(() => {
if (digitalRead(BTN1)) {
//set brightness until. locked.
longPressTimer=setTimeout(() => {
if (longPressTimer == null) {
// cancelled, ignore
return;
}
if (digitalRead(BTN1)) {
//set brightness until. locked.

Bangle.setLCDBrightness(getSettings().brightness);
} else {
Bangle.setLCDBrightness(0);
}
clearTimeout(longPressTimer)
}, longPressTime); // Slight delay to allow unlock to settle
}
});



setWatch(() => {
if (longPressTimer) {
clearTimeout(longPressTimer);
longPressTimer = null;
}
}, BTN1, { repeat:true, edge:'rising' });
}

4 changes: 2 additions & 2 deletions apps/backlite/metadata.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"id": "backlite",
"name": "BackLite",
"version": "0.02",
"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)**",
"version": "0.03",
"description": "Conserves battery life by turning the backlight on only on a long press of the button from a locked state. **Requires Settings app v0.80 or higher**",
"icon": "icon.png",
"type": "bootloader",
"tags": "system",
Expand Down