From 43f9ccdca0c414081e15ef688b48241bae9226b0 Mon Sep 17 00:00:00 2001 From: James Steinberg Date: Thu, 2 Nov 2023 03:33:11 -0400 Subject: [PATCH] formatting --- apps/hardalarm/hardalarm.js | 40 ++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/apps/hardalarm/hardalarm.js b/apps/hardalarm/hardalarm.js index a5b50f5dd..afec60abb 100644 --- a/apps/hardalarm/hardalarm.js +++ b/apps/hardalarm/hardalarm.js @@ -61,6 +61,25 @@ function showPrompt(msg, buzzCount, alarm) { }); } +function buzz() { + Bangle.buzz(500).then(()=>{ + setTimeout(()=>{ + Bangle.buzz(500).then(function() { + setTimeout(()=>{ + Bangle.buzz(2000).then(function() { + if (buzzCount--) + setTimeout(buzz, 2000); + else if(alarm.as) { // auto-snooze + buzzCount = 20; + setTimeout(buzz, 600000); // 10 minutes + } + }); + },100); + }); + },100); + }); +} + function showAlarm(alarm) { if ((require('Storage').readJSON('setting.json',1)||{}).quiet>1) return; // total silence var msg = formatTime(alarm.hr); @@ -96,27 +115,12 @@ function showAlarm(alarm) { } }, BTN, {repeat: true, edge: 'rising'}); - function buzz() { - Bangle.buzz(500).then(()=>{ - setTimeout(()=>{ - Bangle.buzz(500).then(function() { - setTimeout(()=>{ - Bangle.buzz(2000).then(function() { - if (buzzCount--) - setTimeout(buzz, 2000); - else if(alarm.as) { // auto-snooze - buzzCount = 20; - setTimeout(buzz, 600000); // 10 minutes - } - }); - },100); - }); - },100); - }); - } + buzz(); } + + // Check for alarms var day = (new Date()).getDate(); var hr = getCurrentHr()+10000; // get current time - 10s in future to ensure we alarm if we've started the app a tad early