Update boot to use its own block

master
RKBoss6 2025-07-21 21:17:51 -04:00 committed by GitHub
parent aae381e787
commit c588a254d0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 24 additions and 25 deletions

View File

@ -1,33 +1,32 @@
//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);
{
//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);
const longPressTime=400; //(ms)
let unlockedWithLongPress = false;
const longPressTime=400; //(ms)
Bangle.on('lock', function(isLocked) {
Bangle.on('lock', function(isLocked) {
Bangle.setLCDBrightness(0);
if (!isLocked) {
// Just unlocked — give a short delay and check if BTN1 is still pressed
setTimeout(() => {
if (digitalRead(BTN1)) {
unlockedWithLongPress = true;
//set brightness until. locked.
Bangle.setLCDBrightness(0.1);
setTimeout(()=>{
Bangle.setLCDBrightness(0);
},s.lcdTimeout*1000);
} else {
Bangle.setLCDBrightness(0);
}
}, longPressTime); // Slight delay to allow unlock to settle
}
});
});
}