From 660653858a309e21a765cc6d60e009bf9c2bc538 Mon Sep 17 00:00:00 2001 From: James Steinberg Date: Thu, 2 Nov 2023 03:31:44 -0400 Subject: [PATCH] hardalarm 1 btn --- apps/hardalarm/hardalarm.js | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/apps/hardalarm/hardalarm.js b/apps/hardalarm/hardalarm.js index e33bd39cc..a5b50f5dd 100644 --- a/apps/hardalarm/hardalarm.js +++ b/apps/hardalarm/hardalarm.js @@ -71,26 +71,30 @@ function showAlarm(alarm) { var currentGuess = 10; var randomNum = getRandomFromRange(0, 7, 13, 20); showNumberPicker(currentGuess, randomNum) - setWatch(o => { - if(!okClicked && currentGuess < 20) { - currentGuess = currentGuess + 1; - showNumberPicker(currentGuess, randomNum); + + let onSwipe = (x, y) => { + if (y == 1) { + if(!okClicked && currentGuess < 20) { + currentGuess = currentGuess + 1; + showNumberPicker(currentGuess, randomNum); + } } - }, BTN1, {repeat: true, edge: 'rising'}); + else if (y == -1) { + if(!okClicked && currentGuess > 0) { + currentGuess = currentGuess - 1; + showNumberPicker(currentGuess, randomNum); + } + } + }; + Bangle.on("swipe", onSwipe); + setWatch(o => { if(currentGuess == randomNum) { okClicked = true; showPrompt(msg, buzzCount, alarm); } - }, BTN2, {repeat: true, edge: 'rising'}); - - setWatch(o => { - if(!okClicked && currentGuess > 0) { - currentGuess = currentGuess - 1; - showNumberPicker(currentGuess, randomNum); - } - }, BTN3, {repeat: true, edge: 'rising'}); + }, BTN, {repeat: true, edge: 'rising'}); function buzz() { Bangle.buzz(500).then(()=>{