toggled the acceleration handler to prevent infinite buzz loop

pull/2623/head
Le~Kat 2023-02-25 07:52:26 -05:00
parent ec1c534b0d
commit 379af91545
3 changed files with 127 additions and 112 deletions

View File

@ -4,3 +4,4 @@
1.02: added vibration when dice is rolled
1.03: vibration caused the accelerometer to never stop
1.04: decreased vibration strength
1.05: toggled the acceleration handler to prevent infinite buzz loop

View File

@ -79,6 +79,20 @@ function touchHandler (button, xy) {
drawMenu();
}
function accelHandler (xyz) {
if (xyz.diff >= 0.4) {
menu = false;
rollDice();
}
}
function voidFn() {
return;
}
function rollDice() {
resultsArr = new Uint8Array (8);
@ -108,8 +122,6 @@ function rollDice() {
g.drawString ((" " + resultsArr [i]).slice (-3), 96, 10 + 40 * (i - 4));
}
}
Bangle.buzz (200, 0.1);
}
function random (max) {
@ -117,13 +129,15 @@ function random (max) {
return Math.round (Math.random() * (max - 1) + 1);
}
function vibrate() {
Bangle.on ('accel', voidFn);
Bangle.buzz (200, 0.1).then(
Bangle.on ('accel', accelHandler)
);
}
drawMenu();
Bangle.on ('touch', touchHandler);
Bangle.on ('accel', function (xyz) {
if (xyz.diff >= 0.4) {
menu = false;
rollDice();
}
});
Bangle.on ('accel', accelHandler);

View File

@ -1,7 +1,7 @@
{ "id": "multidice",
"name": "multiple dice roller",
"shortName":"multidice",
"version":"1.04",
"version":"1.05",
"description": "roll anywhere from 1-8 dice at the same time",
"icon": "app.png",
"tags": "tool,game",