simpletimer: Fix buzz error, remove '+' when timer running and add 'back' text (fix #577)
parent
ba4eab2a3e
commit
315e7c6bc1
|
|
@ -1718,7 +1718,7 @@
|
||||||
"id": "simpletimer",
|
"id": "simpletimer",
|
||||||
"name": "Timer",
|
"name": "Timer",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
"version": "0.05",
|
"version": "0.06",
|
||||||
"description": "Simple timer, useful when playing board games or cooking",
|
"description": "Simple timer, useful when playing board games or cooking",
|
||||||
"tags": "timer",
|
"tags": "timer",
|
||||||
"readme": "README.md",
|
"readme": "README.md",
|
||||||
|
|
|
||||||
|
|
@ -3,3 +3,4 @@
|
||||||
0.03: BTN2 to open launcher
|
0.03: BTN2 to open launcher
|
||||||
0.04: Remember last set time
|
0.04: Remember last set time
|
||||||
0.05: Fix buzz that doesn't stop (fix #521)
|
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 counter = 0;
|
||||||
let setValue = 0;
|
let setValue = 0;
|
||||||
let counterInterval;
|
let counterInterval, alarmInterval;
|
||||||
let state;
|
let state;
|
||||||
let saved = require("Storage").readJSON("simpletimer.json",true) || {};
|
let saved = require("Storage").readJSON("simpletimer.json",true) || {};
|
||||||
|
|
||||||
|
|
@ -19,7 +19,8 @@ function outOfTime() {
|
||||||
g.drawString("Time UP!", 120, 50);
|
g.drawString("Time UP!", 120, 50);
|
||||||
counter = setValue;
|
counter = setValue;
|
||||||
buzzAndBeep();
|
buzzAndBeep();
|
||||||
setInterval(() => {
|
if (alarmInterval) clearInterval(alarmInterval);
|
||||||
|
alarmInterval = setInterval(() => {
|
||||||
g.clearRect(0, 70, 220, 160);
|
g.clearRect(0, 70, 220, 160);
|
||||||
setTimeout(draw, 200);
|
setTimeout(draw, 200);
|
||||||
}, 400);
|
}, 400);
|
||||||
|
|
@ -55,7 +56,9 @@ function countDown() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearIntervals() {
|
function clearIntervals() {
|
||||||
clearInterval();
|
if (alarmInterval) clearInterval(alarmInterval);
|
||||||
|
if (counterInterval) clearInterval(counterInterval);
|
||||||
|
alarmInterval = undefined;
|
||||||
counterInterval = undefined;
|
counterInterval = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -93,16 +96,21 @@ const stateMap = {
|
||||||
|
|
||||||
function changeState() {
|
function changeState() {
|
||||||
if (stateMap[state]) stateMap[state]();
|
if (stateMap[state]) stateMap[state]();
|
||||||
|
drawLabels();
|
||||||
|
draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawLabels() {
|
function drawLabels() {
|
||||||
g.clear();
|
g.clear();
|
||||||
g.setFontAlign(-1, 0);
|
g.setFontAlign(-1, 0);
|
||||||
g.setFont("6x8", 7);
|
g.setFont("6x8", 7);
|
||||||
|
if (state != "started") // only when not runnung
|
||||||
g.drawString(`+ +`, 35, 180);
|
g.drawString(`+ +`, 35, 180);
|
||||||
g.setFontAlign(0, 0, 3);
|
g.setFontAlign(0, 0, 3);
|
||||||
g.setFont("6x8", 1);
|
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) {
|
function resetTimer(value) {
|
||||||
|
|
@ -130,8 +138,7 @@ function addWatch() {
|
||||||
{
|
{
|
||||||
repeat: false,
|
repeat: false,
|
||||||
edge: "falling",
|
edge: "falling",
|
||||||
},
|
});
|
||||||
);
|
|
||||||
setWatch(
|
setWatch(
|
||||||
() => {
|
() => {
|
||||||
resetTimer(0);
|
resetTimer(0);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue