From 64bff4303f508954f42b33530c9bdfaf336fe321 Mon Sep 17 00:00:00 2001 From: Le~Kat Date: Sat, 25 Feb 2023 13:16:33 -0500 Subject: [PATCH] made changes to when accelHandler gets overwritten, temporarily disabled button usage --- apps/multidice/ChangeLog | 1 + apps/multidice/app.js | 39 +++++++++++++++++------------------- apps/multidice/metadata.json | 2 +- 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/apps/multidice/ChangeLog b/apps/multidice/ChangeLog index ff191cf13..651233c63 100644 --- a/apps/multidice/ChangeLog +++ b/apps/multidice/ChangeLog @@ -16,3 +16,4 @@ 1.14: made the delay needlessly long to see if it even does anything 1.15: moved accel & vibration commands to the accelHandler function 1.16: enabled button usage & temporarily disabled acceleration +1.17: made changes to when accelHandler gets overwritten, temporarily disabled button usage diff --git a/apps/multidice/app.js b/apps/multidice/app.js index 0893fe470..3789dc04b 100644 --- a/apps/multidice/app.js +++ b/apps/multidice/app.js @@ -81,22 +81,16 @@ 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.on ('accel', voidFn); // temporarily disable more acceleration events - Bangle.buzz(50, 0.5).then (() => { + menu = false; + rollDice (function() { - setTimeout (function() { // wait 50ms *after* the buzzing has stopped - - Bangle.on ('accel', accelHandler); - }, 50); + Bangle.on ('accel', accelHandler); // re-enable acceleration events }); } - - Bangle.on ('accel', accelHandler); // re-enable acceleration events } function voidFn() { @@ -104,7 +98,7 @@ function voidFn() { return; } -function rollDice() { +function rollDice (timeoutFunctionRef) { resultsArr = new Uint8Array (8); for (i = 0; i < 8; i++) { @@ -133,6 +127,16 @@ function rollDice() { g.drawString ((" " + resultsArr [i]).slice (-3), 96, 10 + 40 * (i - 4)); } } + + vibrate (timeoutFunctionRef); +} + +function vibrate (timeoutFunctionRef) { + + Bangle.buzz(50, 0.5).then (() => { + + setTimeout (timeoutFunctionRef, 50); + }); } function random (max) { @@ -142,17 +146,10 @@ function random (max) { drawMenu(); Bangle.on ('touch', touchHandler); -//Bangle.on ('accel', accelHandler); -setWatch (function() { +Bangle.on ('accel', accelHandler); +/*setWatch (function() { menu = false; rollDice(); - Bangle.buzz(50, 0.5).then (() => { - - setTimeout (function() { // wait 50ms *after* the buzzing has stopped - - //Bangle.on ('accel', accelHandler); - }, 50); - }); -}, BTN, {repeat: true, edge: "falling", debounce: 10}); +}, BTN, {repeat: true, edge: "falling", debounce: 10});*/ diff --git a/apps/multidice/metadata.json b/apps/multidice/metadata.json index 9b2148682..8a78fe22a 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.16", + "version":"1.17", "description": "roll anywhere from 1-8 dice at the same time", "icon": "app.png", "tags": "tool,game",