Merge pull request #2219 from thyttan/calculator

[Calculator] Exit with short press to BTN1 on Bangle.js 2
pull/2224/head
Gordon Williams 2022-11-04 08:14:37 +00:00 committed by GitHub
commit 395ceeb089
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 19 deletions

View File

@ -3,3 +3,4 @@
0.03: Support for different screen sizes and touchscreen
0.04: Display current operation on LHS
0.05: Grid positioning and swipe controls to switch between numbers, operators and special (for Bangle.js 2)
0.06: Bangle.js 2: Exit with a short press of the physical button

View File

@ -402,6 +402,7 @@ if (process.env.HWVERSION==1) {
swipeEnabled = false;
drawGlobal();
} else { // touchscreen?
setWatch(_ => {load();}, BTN1, {edge:'falling'}); // Exit with a short press to physical button
selected = "NONE";
swipeEnabled = true;
prepareScreen(numbers, numbersGrid, COLORS.DEFAULT);
@ -419,26 +420,20 @@ if (process.env.HWVERSION==1) {
}
}
});
var lastX = 0, lastY = 0;
Bangle.on('drag', (e) => {
if (!e.b) {
if (lastX > 50) { // right
drawSpecials();
} else if (lastX < -50) { // left
drawOperators();
} else if (lastY > 50) { // down
drawNumbers();
} else if (lastY < -50) { // up
drawNumbers();
}
lastX = 0;
lastY = 0;
} else {
lastX = lastX + e.dx;
lastY = lastY + e.dy;
Bangle.on('swipe', (LR, UD) => {
if (LR == 1) { // right
drawSpecials();
}
if (LR == -1) { // left
drawOperators();
}
if (UD == 1) { // down
drawNumbers();
}
if (UD == -1) { // up
drawNumbers();
}
});
}
displayOutput(0);

View File

@ -2,7 +2,7 @@
"id": "calculator",
"name": "Calculator",
"shortName": "Calculator",
"version": "0.05",
"version": "0.06",
"description": "Basic calculator reminiscent of MacOs's one. Handy for small calculus.",
"icon": "calculator.png",
"screenshots": [{"url":"screenshot_calculator.png"}],