mirror of https://github.com/espruino/BangleApps
ok the buzzing *might* work now
parent
560a784be8
commit
9d42114acb
|
@ -21,3 +21,4 @@
|
||||||
1.19: added longer delay before resetting accelHandler
|
1.19: added longer delay before resetting accelHandler
|
||||||
1.20: removed all traces of accel b/c I've given up
|
1.20: removed all traces of accel b/c I've given up
|
||||||
1.21: added a drawWidgets command to see if I have the padding right
|
1.21: added a drawWidgets command to see if I have the padding right
|
||||||
|
1.22: ok the buzzing *might* work now
|
||||||
|
|
|
@ -15,7 +15,6 @@ function drawMenu() {
|
||||||
|
|
||||||
g.clear();
|
g.clear();
|
||||||
g.setFont ("Vector", 40);
|
g.setFont ("Vector", 40);
|
||||||
Bangle.drawWidgets();
|
|
||||||
|
|
||||||
g.drawString ((" " + stringArr [0]).slice (-3), 5, 10);
|
g.drawString ((" " + stringArr [0]).slice (-3), 5, 10);
|
||||||
g.drawString ((" " + stringArr [1]).slice (-3), 5, 50);
|
g.drawString ((" " + stringArr [1]).slice (-3), 5, 50);
|
||||||
|
@ -80,12 +79,40 @@ function touchHandler (button, xy) {
|
||||||
drawMenu();
|
drawMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function accelHandler (xyz) {
|
||||||
|
|
||||||
|
if (xyz.diff >= 0.3) {
|
||||||
|
|
||||||
|
menu = false;
|
||||||
|
//rollDice();
|
||||||
|
//mutex (rollDice);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let lock = false;
|
||||||
|
function mutex (functionRef) {
|
||||||
|
|
||||||
|
if (lock) {
|
||||||
|
|
||||||
|
return Promise.reject (new Error ("mutex is busy"));
|
||||||
|
}
|
||||||
|
|
||||||
|
lock = true;
|
||||||
|
return new Promise (() => {
|
||||||
|
|
||||||
|
functionRef.then (() => {
|
||||||
|
|
||||||
|
lock = false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function voidFn() {
|
function voidFn() {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function rollDice (timeoutFunctionRef) {
|
function rollDice() {
|
||||||
|
|
||||||
resultsArr = new Uint8Array (8);
|
resultsArr = new Uint8Array (8);
|
||||||
for (i = 0; i < 8; i++) {
|
for (i = 0; i < 8; i++) {
|
||||||
|
@ -115,15 +142,12 @@ function rollDice (timeoutFunctionRef) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vibrate (timeoutFunctionRef);
|
return vibrate();
|
||||||
}
|
}
|
||||||
|
|
||||||
function vibrate (timeoutFunctionRef) {
|
function vibrate() {
|
||||||
|
|
||||||
Bangle.buzz(50, 0.5).then (() => {
|
return Bangle.buzz(50, 0.5);
|
||||||
|
|
||||||
setTimeout (timeoutFunctionRef, 150);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function random (max) {
|
function random (max) {
|
||||||
|
@ -133,9 +157,10 @@ function random (max) {
|
||||||
|
|
||||||
drawMenu();
|
drawMenu();
|
||||||
Bangle.on ('touch', touchHandler);
|
Bangle.on ('touch', touchHandler);
|
||||||
|
Bangle.on ('accel', accelHandler);
|
||||||
setWatch (function() {
|
setWatch (function() {
|
||||||
|
|
||||||
menu = false;
|
menu = false;
|
||||||
rollDice (voidFn);
|
//rollDice();
|
||||||
|
mutex (rollDice);
|
||||||
}, BTN, {repeat: true, edge: "falling", debounce: 10});
|
}, BTN, {repeat: true, edge: "falling", debounce: 10});
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{ "id": "multidice",
|
{ "id": "multidice",
|
||||||
"name": "multiple dice roller",
|
"name": "multiple dice roller",
|
||||||
"shortName":"multidice",
|
"shortName":"multidice",
|
||||||
"version":"1.21",
|
"version":"1.22",
|
||||||
"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