From 5dbf7205b01f52aa320c5fb0aaaba721c8f8658d Mon Sep 17 00:00:00 2001 From: thyttan <97237430+thyttan@users.noreply.github.com> Date: Thu, 3 Nov 2022 18:08:16 +0100 Subject: [PATCH 1/5] Exit with short press of BTN1 --- apps/calculator/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/calculator/app.js b/apps/calculator/app.js index 40953254e..c93b36e43 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); @@ -440,5 +441,4 @@ if (process.env.HWVERSION==1) { }); } - displayOutput(0); From 71d59896b1f3dffe6a88b6f9d3250532774ef976 Mon Sep 17 00:00:00 2001 From: thyttan <97237430+thyttan@users.noreply.github.com> Date: Thu, 3 Nov 2022 18:09:14 +0100 Subject: [PATCH 2/5] Update ChangeLog --- apps/calculator/ChangeLog | 1 + 1 file changed, 1 insertion(+) 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 From 1b73fadcb812ea381e87755cb2eecf894e2b9699 Mon Sep 17 00:00:00 2001 From: thyttan <97237430+thyttan@users.noreply.github.com> Date: Thu, 3 Nov 2022 18:09:32 +0100 Subject: [PATCH 3/5] Update metadata.json --- apps/calculator/metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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"}], From e57543bd48046d115c442cce718b695659817d9d Mon Sep 17 00:00:00 2001 From: thyttan <97237430+thyttan@users.noreply.github.com> Date: Thu, 3 Nov 2022 18:53:32 +0100 Subject: [PATCH 4/5] Update app.js --- apps/calculator/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/calculator/app.js b/apps/calculator/app.js index c93b36e43..3a8486452 100644 --- a/apps/calculator/app.js +++ b/apps/calculator/app.js @@ -402,7 +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 + setWatch(_ => {load();}, BTN1, {edge:"falling"}); // Exit with a short press to physical button selected = "NONE"; swipeEnabled = true; prepareScreen(numbers, numbersGrid, COLORS.DEFAULT); From 6d63552f4633d88f6040c03df47789df689f9600 Mon Sep 17 00:00:00 2001 From: thyttan <97237430+thyttan@users.noreply.github.com> Date: Thu, 3 Nov 2022 19:15:28 +0100 Subject: [PATCH 5/5] Change to swipe events from drag --- apps/calculator/app.js | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/apps/calculator/app.js b/apps/calculator/app.js index 3a8486452..571a5b27f 100644 --- a/apps/calculator/app.js +++ b/apps/calculator/app.js @@ -402,7 +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 + setWatch(_ => {load();}, BTN1, {edge:'falling'}); // Exit with a short press to physical button selected = "NONE"; swipeEnabled = true; prepareScreen(numbers, numbersGrid, COLORS.DEFAULT); @@ -420,23 +420,18 @@ 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(); } }); }