BTN improvement

pull/2041/head
Hank 2022-07-12 13:51:20 +02:00
parent 29e2387e4a
commit 1a5e7794f6
1 changed files with 36 additions and 57 deletions

View File

@ -232,31 +232,10 @@ function resetDrinksFn() {
});
}
function bjsGetButtonState() {
let btn1 = BTN1.read();
let btn2 = BTN2.read();
let btn3 = BTN3.read();
let btn4 = BTN4.read();
let btn5 = BTN5.read();
if (BTN1.read()) {
addDrink();
}
if (BTN2.read()) {
resetDrinksFn();
}
if (BTN3.read()) {
removeDrink();
}
if (BTN4.read()) {
previousDrink();
}
if (BTN5.read()) {
nextDrink();
}
}
function initDragEvents() {
if (BANGLEJS2) {
Bangle.on("drag", e => {
if (!drag) { // start dragging
drag = {x: e.x, y: e.y};
@ -288,16 +267,16 @@ function initDragEvents() {
}
}
}
});
} else {
setWatch(addDrink, BTN1, { repeat: true, debounce:50 });
setWatch(removeDrink, BTN3, { repeat: true, debounce:50 });
setWatch(previousDrink, BTN4, { repeat: true, debounce:50 });
setWatch(nextDrink, BTN5, { repeat: true, debounce:50 });
}
);
}
if (!BANGLEJS2) {
setInterval(bjsGetButtonState, 100); // 10 Hz
}
loadMySettings();
showDrinks();