From 1d6887a4dff0f11475cc1bf21d62c59e07b75a94 Mon Sep 17 00:00:00 2001 From: Marco H Date: Sun, 12 Jun 2022 21:17:52 +0200 Subject: [PATCH] Do not check new values if alarm is shown --- apps/widbaroalarm/widget.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/widbaroalarm/widget.js b/apps/widbaroalarm/widget.js index d8eb43995..e1516b6f1 100644 --- a/apps/widbaroalarm/widget.js +++ b/apps/widbaroalarm/widget.js @@ -2,6 +2,7 @@ let medianPressure; let threeHourAvrPressure; let currentPressures = []; + let stop = false; // semaphore const LOG_FILE = "widbaroalarm.log.json"; const SETTINGS_FILE = "widbaroalarm.json"; @@ -34,6 +35,7 @@ function showAlarm(body, key) { if (body == undefined) return; + stop = true; E.showPrompt(body, { title: "Pressure alarm", @@ -56,6 +58,7 @@ // save timestamp of the future so that we do not warn again for the same event until then saveSetting(key, tsNow + 60 * setting('pauseDelayMin')); } + stop = false; load(); }); @@ -64,7 +67,10 @@ Bangle.buzz(); } - setTimeout(load, 20000); + setTimeout(function() { + stop = false; + load(); + }, 20000); } @@ -191,6 +197,7 @@ turn off barometer power */ function check() { + if (stop) return; const MEDIANLENGTH = 20; Bangle.setBarometerPower(true, "widbaroalarm"); Bangle.on('pressure', function(e) {