simpletimer: Fix buzz that doesn't stop (fix #521)

pull/543/head
Gordon Williams 2020-07-30 10:15:25 +01:00
parent 9582c84708
commit c4e62a3819
3 changed files with 10 additions and 8 deletions

View File

@ -1695,7 +1695,7 @@
"id": "simpletimer",
"name": "Timer",
"icon": "app.png",
"version": "0.04",
"version": "0.05",
"description": "Simple timer, useful when playing board games or cooking",
"tags": "timer",
"readme": "README.md",

View File

@ -1,4 +1,5 @@
0.01: Initial version
0.02: Reset with gesture
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)

View File

@ -84,10 +84,10 @@ const stateMap = {
startTimer();
},
started: () => {
reset(setValue);
resetTimer(setValue);
},
stopped: () => {
reset(setValue);
resetTimer(setValue);
}
};
@ -105,8 +105,9 @@ function drawLabels() {
g.drawString(`reset (re)start`, 230, 120);
}
function reset(value) {
function resetTimer(value) {
clearIntervals();
VIBRATE.reset(); // turn off vibration (clearIntervals stops the buzz turning off)
counter = value;
setValue = value;
drawLabels();
@ -133,7 +134,7 @@ function addWatch() {
);
setWatch(
() => {
reset(0);
resetTimer(0);
},
BTN3,
{
@ -160,8 +161,8 @@ function addWatch() {
});
}
Bangle.on("aiGesture", gesture => {
if (gesture === "swipeleft" && state === "stopped") reset(0);
if (gesture === "swipeleft" && state === "stopped") resetTimer(0);
});
reset(saved.counter || 0);
resetTimer(saved.counter || 0);
addWatch();