Merge pull request #3943 from bobrippling/feat/counter2-always-on

counter2: always-unlocked option
master
Rob Pilling 2025-08-01 08:37:41 +01:00 committed by GitHub
commit b7daabbd00
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 21 additions and 7 deletions

View File

@ -4,3 +4,4 @@
0.04: Fix lint warnings
0.05: Fix on not reading counter defaults in Settings
0.06: Added ability to display only one counter and fast-scrolling
0.07: Add option to keep unlocked

View File

@ -7,12 +7,19 @@ var s = Object.assign({
fullscreen:true,
buzz: true,
colortext: true,
keepunlocked: false,
}, require('Storage').readJSON("counter2.json", true) || {});
var sGlob = Object.assign({
timeout: 10,
}, require('Storage').readJSON("setting.json", true) || {});
const lockTimeout = s.keepunlocked ? 0 : 1000;
if (s.keepunlocked) {
Bangle.setOptions({lockTimeout});
Bangle.setLocked(false);
}
const f1 = (s.colortext) ? "#f00" : "#fff";
const f2 = (s.colortext) ? "#00f" : "#fff";
const b1 = (s.colortext) ? g.theme.bg : "#f00";
@ -80,7 +87,7 @@ function updateScreen() {
Bangle.on('lock', e => {
drag = undefined;
var timeOutTimer = sGlob.timeout * 1000;
Bangle.setOptions({backlightTimeout: timeOutTimer, lockTimeout: timeOutTimer});
Bangle.setOptions({backlightTimeout: timeOutTimer, lockTimeout});
if (dragtimeout) clearTimeout(dragtimeout);
fastupdateoccurring = false;
});
@ -102,7 +109,7 @@ Bangle.on("drag", e => {
drag = undefined;
if (dragtimeout) {
let timeOutTimer = 1000;
Bangle.setOptions({backlightTimeout: timeOutTimer, lockTimeout: timeOutTimer});
Bangle.setOptions({backlightTimeout: timeOutTimer, lockTimeout});
clearTimeout(dragtimeout);
}
fastupdateoccurring = false;
@ -134,7 +141,7 @@ function resetcounter(which) {
fastupdateoccurring = false;
if (dragtimeout) {
let timeOutTimer = 1000;
Bangle.setOptions({backlightTimeout: timeOutTimer, lockTimeout: timeOutTimer});
Bangle.setOptions({backlightTimeout: timeOutTimer, lockTimeout});
clearTimeout(dragtimeout);
}
if (which == null) {
@ -152,7 +159,6 @@ function resetcounter(which) {
ignoreonce = true;
}
updateScreen();
setWatch(function() {
@ -163,6 +169,6 @@ setWatch(function() {
}
}
var timeOutTimer = sGlob.timeout * 1000;
Bangle.setOptions({backlightTimeout: timeOutTimer, lockTimeout: timeOutTimer});
Bangle.setOptions({backlightTimeout: timeOutTimer, lockTimeout});
load();
}, BTN1, {repeat:true, edge:"falling"});

View File

@ -1,7 +1,7 @@
{
"id": "counter2",
"name": "Counter2",
"version": "0.06",
"version": "0.07",
"description": "Dual Counter",
"readme":"README.md",
"icon": "counter2-icon.png",

View File

@ -70,10 +70,17 @@
onchange: v => {
settings.buzz = v;
writeSettings();
},
};
appMenu['Keep unlocked'] = {
value: settings.keepunlocked,
onchange: v => {
settings.keepunlocked = v;
writeSettings();
},
};
E.showMenu(appMenu);
}
showMainMenu();
})
})