feat: Add timed buzzing alerts to stopwatches
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
|
||||
let watchState = STATE_IDLE;
|
||||
|
||||
let stopWatch = require("Storage").readJSON("mystopwatch.json", true) || {start1: null, elapsed1: null, start2: null, elapsed2: null};
|
||||
let stopWatch = require("Storage").readJSON("mystopwatch.json", true) || {start1: null, elapsed1: null, buzz1: null, start2: null, elapsed2: null, buzzed2: null};
|
||||
let saveStopWatch = function() {
|
||||
require("Storage").writeJSON("mystopwatch.json", stopWatch);
|
||||
}
|
||||
@@ -37,6 +37,14 @@
|
||||
let Tt1 = (stopWatch.elapsed1 || 0);
|
||||
if (stopWatch.start1) {
|
||||
Tt1 += Date.now() - stopWatch.start1;
|
||||
|
||||
const fifteenMinutes = 15 * 60 * 1000;
|
||||
let intervals = Math.floor(Tt1 / fifteenMinutes);
|
||||
if (intervals > (stopWatch.buzz1 || 0)) {
|
||||
stopWatch.buzz1 = intervals;
|
||||
Bangle.buzz();
|
||||
saveStopWatch();
|
||||
}
|
||||
}
|
||||
let Ttxt1 = timeToText(Tt1);
|
||||
|
||||
@@ -49,6 +57,13 @@
|
||||
let Tt2 = (stopWatch.elapsed2 || 0);
|
||||
if (stopWatch.start2) {
|
||||
Tt2 += Date.now() - stopWatch.start2;
|
||||
|
||||
const oneMinute = 60 * 1000;
|
||||
if (!stopWatch.buzzed2 && Tt2 >= oneMinute) {
|
||||
stopWatch.buzzed2 = true;
|
||||
Bangle.buzz();
|
||||
saveStopWatch();
|
||||
}
|
||||
}
|
||||
let Ttxt2 = timeToText(Tt2);
|
||||
|
||||
@@ -233,6 +248,7 @@
|
||||
let stopSW1 = function() {
|
||||
stopWatch.start1 = null;
|
||||
stopWatch.elapsed1 = null;
|
||||
stopWatch.buzz1 = null;
|
||||
saveStopWatch();
|
||||
|
||||
if (!stopWatch.start2) {
|
||||
@@ -260,6 +276,7 @@
|
||||
let stopSW2 = function() {
|
||||
stopWatch.start2 = null;
|
||||
stopWatch.elapsed2 = null;
|
||||
stopWatch.buzzed2 = null;
|
||||
saveStopWatch();
|
||||
|
||||
if (!stopWatch.start1) {
|
||||
|
||||
Reference in New Issue
Block a user