diff --git a/apps.json b/apps.json index c9322b12a..3cafdae78 100644 --- a/apps.json +++ b/apps.json @@ -1718,7 +1718,7 @@ "id": "simpletimer", "name": "Timer", "icon": "app.png", - "version": "0.05", + "version": "0.06", "description": "Simple timer, useful when playing board games or cooking", "tags": "timer", "readme": "README.md", diff --git a/apps/simpletimer/ChangeLog b/apps/simpletimer/ChangeLog index e548d90fa..0a0d47126 100644 --- a/apps/simpletimer/ChangeLog +++ b/apps/simpletimer/ChangeLog @@ -3,3 +3,4 @@ 0.03: BTN2 to open launcher 0.04: Remember last set time 0.05: Fix buzz that doesn't stop (fix #521) +0.06: Fix buzz error, remove '+' when timer running and add 'back' text (fix #577) diff --git a/apps/simpletimer/app.js b/apps/simpletimer/app.js index 75c118980..f6332a8b7 100644 --- a/apps/simpletimer/app.js +++ b/apps/simpletimer/app.js @@ -1,6 +1,6 @@ let counter = 0; let setValue = 0; -let counterInterval; +let counterInterval, alarmInterval; let state; let saved = require("Storage").readJSON("simpletimer.json",true) || {}; @@ -19,7 +19,8 @@ function outOfTime() { g.drawString("Time UP!", 120, 50); counter = setValue; buzzAndBeep(); - setInterval(() => { + if (alarmInterval) clearInterval(alarmInterval); + alarmInterval = setInterval(() => { g.clearRect(0, 70, 220, 160); setTimeout(draw, 200); }, 400); @@ -55,7 +56,9 @@ function countDown() { } function clearIntervals() { - clearInterval(); + if (alarmInterval) clearInterval(alarmInterval); + if (counterInterval) clearInterval(counterInterval); + alarmInterval = undefined; counterInterval = undefined; } @@ -93,16 +96,21 @@ const stateMap = { function changeState() { if (stateMap[state]) stateMap[state](); + drawLabels(); + draw(); } function drawLabels() { g.clear(); g.setFontAlign(-1, 0); g.setFont("6x8", 7); - g.drawString(`+ +`, 35, 180); + if (state != "started") // only when not runnung + g.drawString(`+ +`, 35, 180); g.setFontAlign(0, 0, 3); g.setFont("6x8", 1); - g.drawString(`reset (re)start`, 230, 120); + g.drawString("Reset (re)start", 230, 120); + if (state != "started") // only when not runnung + g.drawString("Back", 230, 120); } function resetTimer(value) { @@ -130,8 +138,7 @@ function addWatch() { { repeat: false, edge: "falling", - }, - ); + }); setWatch( () => { resetTimer(0);