From e6e2d622fbe3e0208a2fcc174160828a4c491c47 Mon Sep 17 00:00:00 2001 From: Le~Kat Date: Sat, 25 Feb 2023 12:48:47 -0500 Subject: [PATCH] moved accel & vibration commands to the accelHandler function --- apps/multidice/ChangeLog | 1 + apps/multidice/app.js | 23 +++++++++++------------ apps/multidice/metadata.json | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/apps/multidice/ChangeLog b/apps/multidice/ChangeLog index d8a684575..2e6b8c622 100644 --- a/apps/multidice/ChangeLog +++ b/apps/multidice/ChangeLog @@ -14,3 +14,4 @@ 1.12: issue with app calling roll function too many times at startup 1.13: added a delay after the buzzer stops to prevent multi-rolling 1.14: made the delay needlessly long to see if it even does anything +1.15: moved accel & vibration commands to the accelHandler function diff --git a/apps/multidice/app.js b/apps/multidice/app.js index 271b7bad3..6dddf1e19 100644 --- a/apps/multidice/app.js +++ b/apps/multidice/app.js @@ -35,9 +35,6 @@ function touchHandler (button, xy) { return; } - rollDice(); - return; - if (xy.x <= 87) { // left if (xy.y <= 43) { @@ -84,11 +81,22 @@ function touchHandler (button, xy) { function accelHandler (xyz) { + Bangle.on ('accel', voidFn); // temporarily disable more acceleration events if (xyz.diff >= 0.3) { menu = false; rollDice(); + + Bangle.buzz(50, 0.5).then (() => { + + setTimeout (function() { // wait 50ms *after* the buzzing has stopped + + Bangle.on ('accel', accelHandler); + }, 50); + }); } + + Bangle.on ('accel', accelHandler); // re-enable acceleration events } function voidFn() { @@ -125,15 +133,6 @@ function rollDice() { g.drawString ((" " + resultsArr [i]).slice (-3), 96, 10 + 40 * (i - 4)); } } - - Bangle.on ('accel', voidFn); - Bangle.buzz(50, 0.5).then (() => { - - setTimeout (function() { // wait 50ms *after* the buzzing has stopped - - Bangle.on ('accel', accelHandler); - }, 1000); - }); } function random (max) { diff --git a/apps/multidice/metadata.json b/apps/multidice/metadata.json index 2bcf4d2eb..7eb1c1607 100644 --- a/apps/multidice/metadata.json +++ b/apps/multidice/metadata.json @@ -1,7 +1,7 @@ { "id": "multidice", "name": "multiple dice roller", "shortName":"multidice", - "version":"1.14", + "version":"1.15", "description": "roll anywhere from 1-8 dice at the same time", "icon": "app.png", "tags": "tool,game",