diff --git a/apps/calculator/ChangeLog b/apps/calculator/ChangeLog index a08a0f5a7..f3ce3a928 100644 --- a/apps/calculator/ChangeLog +++ b/apps/calculator/ChangeLog @@ -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 diff --git a/apps/calculator/app.js b/apps/calculator/app.js index 40953254e..571a5b27f 100644 --- a/apps/calculator/app.js +++ b/apps/calculator/app.js @@ -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); diff --git a/apps/calculator/metadata.json b/apps/calculator/metadata.json index e78e4d54f..536a6955e 100644 --- a/apps/calculator/metadata.json +++ b/apps/calculator/metadata.json @@ -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"}],