From 7ae0e8093b4a12303d3548d27c90d1ac4098ae5c Mon Sep 17 00:00:00 2001 From: inhof009 <141580984+inhof009@users.noreply.github.com> Date: Wed, 9 Aug 2023 08:34:06 -0400 Subject: [PATCH] Update app.js Added button interaction. 1 press for refresh data, double press for launcher. --- apps/usgs/app.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/apps/usgs/app.js b/apps/usgs/app.js index e0b515018..e6f2efa1e 100644 --- a/apps/usgs/app.js +++ b/apps/usgs/app.js @@ -63,5 +63,27 @@ function displayData(dataStreams) { seconds.toString().padStart(2,"0"); E.showMessage(string,timeString); } +function handleButton() { + switch(nPress) { + case 1: + fetchStartup(); + break; + case 2: + Bangle.showLauncher(); + break; + default: + Bangle.buzz(50); + } + nPress=0; +} fetchStartup(); + +nPress = 0; +tPress = 0; + +setWatch(() => { + nPress++; + clearTimeout(tPress); + tPress = setTimeout(() => {handleButton();}, 500); + }, (process.env.HWVERSION==2) ? BTN1 : BTN2, {repeat: true, edge: "rising"});