Create boot.js

master
RKBoss6 2025-07-10 16:53:53 -04:00 committed by GitHub
parent ef5ae344d8
commit d9850bcde1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 30 additions and 0 deletions

30
apps/backlite/boot.js Normal file
View File

@ -0,0 +1,30 @@
//Set LCD to zero through settings every reboot
let s = require("Storage").readJSON("setting.json", 1) || {};
s.brightness = 0; // Set brightness to 70% (value from 0 to 1)
require("Storage").writeJSON("setting.json", s);
let unlockedWithLongPress = false;
const longPressTime=300; //(ms)
Bangle.on('lock', function(isLocked) {
if (!isLocked) {
// Just unlocked — give a short delay and check if BTN1 is still pressed
setTimeout(() => {
if (digitalRead(BTN1)) {
unlockedWithLongPress = true;
Bangle.setLCDBrightness(0.1);
setTimeout(()=>{
Bangle.setLCDBrightness(0);
},Bangle.getOptions().lcdTimeout);
} else {
Bangle.setLCDBrightness(0);
}
}, longPressTime); // Slight delay to allow unlock to settle
}
});