forked from FOSS/BangleApps
toggled the acceleration handler to prevent infinite buzz loop
parent
d64609aa92
commit
1e46b479e2
|
@ -4,3 +4,4 @@
|
||||||
1.02: added vibration when dice is rolled
|
1.02: added vibration when dice is rolled
|
||||||
1.03: vibration caused the accelerometer to never stop
|
1.03: vibration caused the accelerometer to never stop
|
||||||
1.04: decreased vibration strength
|
1.04: decreased vibration strength
|
||||||
|
1.05: toggled the acceleration handler to prevent infinite buzz loop
|
||||||
|
|
|
@ -79,6 +79,20 @@ function touchHandler (button, xy) {
|
||||||
drawMenu();
|
drawMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function accelHandler (xyz) {
|
||||||
|
|
||||||
|
if (xyz.diff >= 0.4) {
|
||||||
|
|
||||||
|
menu = false;
|
||||||
|
rollDice();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function voidFn() {
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
function rollDice() {
|
function rollDice() {
|
||||||
|
|
||||||
resultsArr = new Uint8Array (8);
|
resultsArr = new Uint8Array (8);
|
||||||
|
@ -108,8 +122,6 @@ function rollDice() {
|
||||||
g.drawString ((" " + resultsArr [i]).slice (-3), 96, 10 + 40 * (i - 4));
|
g.drawString ((" " + resultsArr [i]).slice (-3), 96, 10 + 40 * (i - 4));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Bangle.buzz (200, 0.1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function random (max) {
|
function random (max) {
|
||||||
|
@ -117,13 +129,15 @@ function random (max) {
|
||||||
return Math.round (Math.random() * (max - 1) + 1);
|
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();
|
drawMenu();
|
||||||
Bangle.on ('touch', touchHandler);
|
Bangle.on ('touch', touchHandler);
|
||||||
Bangle.on ('accel', function (xyz) {
|
Bangle.on ('accel', accelHandler);
|
||||||
|
|
||||||
if (xyz.diff >= 0.4) {
|
|
||||||
|
|
||||||
menu = false;
|
|
||||||
rollDice();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{ "id": "multidice",
|
{ "id": "multidice",
|
||||||
"name": "multiple dice roller",
|
"name": "multiple dice roller",
|
||||||
"shortName":"multidice",
|
"shortName":"multidice",
|
||||||
"version":"1.04",
|
"version":"1.05",
|
||||||
"description": "roll anywhere from 1-8 dice at the same time",
|
"description": "roll anywhere from 1-8 dice at the same time",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
"tags": "tool,game",
|
"tags": "tool,game",
|
||||||
|
|
Loading…
Reference in New Issue