From eb0d809a610945ac89efc30b8f942e6e51acfada Mon Sep 17 00:00:00 2001 From: sir-indy <53864146+sir-indy@users.noreply.github.com> Date: Wed, 6 Apr 2022 12:49:59 +0100 Subject: [PATCH] Update fuzzyw.app.js --- apps/fuzzyw/fuzzyw.app.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/apps/fuzzyw/fuzzyw.app.js b/apps/fuzzyw/fuzzyw.app.js index 494e45124..e4fa71070 100644 --- a/apps/fuzzyw/fuzzyw.app.js +++ b/apps/fuzzyw/fuzzyw.app.js @@ -10,6 +10,18 @@ if (settings.language == 'System') { let fuzzy_string = fuzzy_strings[settings.language]; +let timeout = 2.5*60; +let drawTimeout; + +function queueDraw(seconds) { + let millisecs = seconds * 1000; + if (drawTimeout) clearTimeout(drawTimeout); + drawTimeout = setTimeout(function() { + drawTimeout = undefined; + draw(); + }, millisecs - (Date.now() % millisecs)); +} + const h = g.getHeight(); const w = g.getWidth(); let align_mode = 0; @@ -42,11 +54,11 @@ function draw() { g.clearRect(0, 24, w, h-24); g.setColor(g.theme.fg); g.drawString(g.wrapString(time_string, w).join("\n"), align_pos, h/2); + queueDraw(timeout); } g.clear(); draw(); -setInterval(draw, 10000); // refresh every 10s // Stop updates when LCD is off, restart when on Bangle.on('lcdPower',on=>{