Skip to content

Commit b7daabb

Browse files
authored
Merge pull request #3943 from bobrippling/feat/counter2-always-on
counter2: always-unlocked option
2 parents 07ba704 + 40416fc commit b7daabb

File tree

4 files changed

+21
-7
lines changed

4 files changed

+21
-7
lines changed

apps/counter2/ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
0.04: Fix lint warnings
55
0.05: Fix on not reading counter defaults in Settings
66
0.06: Added ability to display only one counter and fast-scrolling
7+
0.07: Add option to keep unlocked

apps/counter2/app.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,19 @@ var s = Object.assign({
77
fullscreen:true,
88
buzz: true,
99
colortext: true,
10+
keepunlocked: false,
1011
}, require('Storage').readJSON("counter2.json", true) || {});
1112

1213
var sGlob = Object.assign({
1314
timeout: 10,
1415
}, require('Storage').readJSON("setting.json", true) || {});
1516

17+
const lockTimeout = s.keepunlocked ? 0 : 1000;
18+
if (s.keepunlocked) {
19+
Bangle.setOptions({lockTimeout});
20+
Bangle.setLocked(false);
21+
}
22+
1623
const f1 = (s.colortext) ? "#f00" : "#fff";
1724
const f2 = (s.colortext) ? "#00f" : "#fff";
1825
const b1 = (s.colortext) ? g.theme.bg : "#f00";
@@ -80,7 +87,7 @@ function updateScreen() {
8087
Bangle.on('lock', e => {
8188
drag = undefined;
8289
var timeOutTimer = sGlob.timeout * 1000;
83-
Bangle.setOptions({backlightTimeout: timeOutTimer, lockTimeout: timeOutTimer});
90+
Bangle.setOptions({backlightTimeout: timeOutTimer, lockTimeout});
8491
if (dragtimeout) clearTimeout(dragtimeout);
8592
fastupdateoccurring = false;
8693
});
@@ -102,7 +109,7 @@ Bangle.on("drag", e => {
102109
drag = undefined;
103110
if (dragtimeout) {
104111
let timeOutTimer = 1000;
105-
Bangle.setOptions({backlightTimeout: timeOutTimer, lockTimeout: timeOutTimer});
112+
Bangle.setOptions({backlightTimeout: timeOutTimer, lockTimeout});
106113
clearTimeout(dragtimeout);
107114
}
108115
fastupdateoccurring = false;
@@ -134,7 +141,7 @@ function resetcounter(which) {
134141
fastupdateoccurring = false;
135142
if (dragtimeout) {
136143
let timeOutTimer = 1000;
137-
Bangle.setOptions({backlightTimeout: timeOutTimer, lockTimeout: timeOutTimer});
144+
Bangle.setOptions({backlightTimeout: timeOutTimer, lockTimeout});
138145
clearTimeout(dragtimeout);
139146
}
140147
if (which == null) {
@@ -152,7 +159,6 @@ function resetcounter(which) {
152159
ignoreonce = true;
153160
}
154161

155-
156162
updateScreen();
157163

158164
setWatch(function() {
@@ -163,6 +169,6 @@ setWatch(function() {
163169
}
164170
}
165171
var timeOutTimer = sGlob.timeout * 1000;
166-
Bangle.setOptions({backlightTimeout: timeOutTimer, lockTimeout: timeOutTimer});
172+
Bangle.setOptions({backlightTimeout: timeOutTimer, lockTimeout});
167173
load();
168174
}, BTN1, {repeat:true, edge:"falling"});

apps/counter2/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "counter2",
33
"name": "Counter2",
4-
"version": "0.06",
4+
"version": "0.07",
55
"description": "Dual Counter",
66
"readme":"README.md",
77
"icon": "counter2-icon.png",

apps/counter2/settings.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,17 @@
7070
onchange: v => {
7171
settings.buzz = v;
7272
writeSettings();
73+
},
74+
};
75+
appMenu['Keep unlocked'] = {
76+
value: settings.keepunlocked,
77+
onchange: v => {
78+
settings.keepunlocked = v;
79+
writeSettings();
7380
},
7481
};
7582
E.showMenu(appMenu);
7683
}
7784

7885
showMainMenu();
79-
})
86+
})

0 commit comments

Comments
 (0)