forked from FOSS/BangleApps
simpletimer: Fix buzz error, remove '+' when timer running and add 'back' text (fix #577)
parent
ba4eab2a3e
commit
315e7c6bc1
|
@ -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",
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue