diff --git a/apps/counter2/ChangeLog b/apps/counter2/ChangeLog index 76543fa12..7db1936fa 100644 --- a/apps/counter2/ChangeLog +++ b/apps/counter2/ChangeLog @@ -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 diff --git a/apps/counter2/app.js b/apps/counter2/app.js index 01b16a72a..b8493da7e 100644 --- a/apps/counter2/app.js +++ b/apps/counter2/app.js @@ -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"}); diff --git a/apps/counter2/metadata.json b/apps/counter2/metadata.json index 11cc9776f..85d2d1a99 100644 --- a/apps/counter2/metadata.json +++ b/apps/counter2/metadata.json @@ -1,7 +1,7 @@ { "id": "counter2", "name": "Counter2", - "version": "0.06", + "version": "0.07", "description": "Dual Counter", "readme":"README.md", "icon": "counter2-icon.png", diff --git a/apps/counter2/settings.js b/apps/counter2/settings.js index 32c6a2009..622c3c69e 100644 --- a/apps/counter2/settings.js +++ b/apps/counter2/settings.js @@ -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(); - }) \ No newline at end of file + })