From 351ce5f891b7d4db87a7360f2c9e2592537a1dca Mon Sep 17 00:00:00 2001 From: thyttan <6uuxstm66@mozmail.com⁩> Date: Mon, 7 Nov 2022 00:07:27 +0100 Subject: [PATCH 1/3] exit by pressing upper left corner of screen --- apps/calculator/ChangeLog | 1 + apps/calculator/README.md | 8 ++++++++ apps/calculator/app.js | 4 ++++ apps/calculator/metadata.json | 2 +- 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/apps/calculator/ChangeLog b/apps/calculator/ChangeLog index f3ce3a928..2e1ace7bf 100644 --- a/apps/calculator/ChangeLog +++ b/apps/calculator/ChangeLog @@ -4,3 +4,4 @@ 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 +0.07: Bangle.js 2: Exit by pressing upper left corner of the screen diff --git a/apps/calculator/README.md b/apps/calculator/README.md index b25d355bf..8681965f2 100644 --- a/apps/calculator/README.md +++ b/apps/calculator/README.md @@ -12,12 +12,20 @@ Basic calculator reminiscent of MacOs's one. Handy for small calculus. ## Controls +Bangle.js 1 - UP: BTN1 - DOWN: BTN3 - LEFT: BTN4 - RIGHT: BTN5 - SELECT: BTN2 +Bangle.js 2 +- Swipes to change visible buttons +- Click physical button exit +- Press upper left corner of screen to exit (where the red back button would be) ## Creator + +## Contributors +[thyttan](https://github.com/thyttan) diff --git a/apps/calculator/app.js b/apps/calculator/app.js index 571a5b27f..f31b591ad 100644 --- a/apps/calculator/app.js +++ b/apps/calculator/app.js @@ -402,6 +402,10 @@ if (process.env.HWVERSION==1) { swipeEnabled = false; drawGlobal(); } else { // touchscreen? + Bangle.setUI({ // Pressing upper left corner turns off (where red back button would be) + mode : 'custom', + back : load + }); setWatch(_ => {load();}, BTN1, {edge:'falling'}); // Exit with a short press to physical button selected = "NONE"; swipeEnabled = true; diff --git a/apps/calculator/metadata.json b/apps/calculator/metadata.json index 536a6955e..1674b7843 100644 --- a/apps/calculator/metadata.json +++ b/apps/calculator/metadata.json @@ -2,7 +2,7 @@ "id": "calculator", "name": "Calculator", "shortName": "Calculator", - "version": "0.06", + "version": "0.07", "description": "Basic calculator reminiscent of MacOs's one. Handy for small calculus.", "icon": "calculator.png", "screenshots": [{"url":"screenshot_calculator.png"}], From cd5367977fe7caf1fb4442824220b082220344c4 Mon Sep 17 00:00:00 2001 From: thyttan <97237430+thyttan@users.noreply.github.com> Date: Mon, 7 Nov 2022 11:04:52 +0100 Subject: [PATCH 2/3] Move input handling inside setUI (Bangle2) --- apps/calculator/app.js | 58 ++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/apps/calculator/app.js b/apps/calculator/app.js index f31b591ad..d9a89a989 100644 --- a/apps/calculator/app.js +++ b/apps/calculator/app.js @@ -3,6 +3,8 @@ * * Original Author: Frederic Rousseau https://github.com/fredericrous * Created: April 2020 + * + * Contributors: thyttan https://github.com/thyttan */ g.clear(); @@ -402,42 +404,42 @@ if (process.env.HWVERSION==1) { swipeEnabled = false; drawGlobal(); } else { // touchscreen? - Bangle.setUI({ // Pressing upper left corner turns off (where red back button would be) - mode : 'custom', - back : load - }); - setWatch(_ => {load();}, BTN1, {edge:'falling'}); // Exit with a short press to physical button - selected = "NONE"; + selected = "NONE"; swipeEnabled = true; prepareScreen(numbers, numbersGrid, COLORS.DEFAULT); prepareScreen(operators, operatorsGrid, COLORS.OPERATOR); prepareScreen(specials, specialsGrid, COLORS.SPECIAL); drawNumbers(); - Bangle.on('touch',(n,e)=>{ - for (var key in screen) { - if (typeof screen[key] == "undefined") break; - var r = screen[key].xy; - if (e.x>=r[0] && e.y>=r[1] && - e.x{ + for (var key in screen) { + if (typeof screen[key] == "undefined") break; + var r = screen[key].xy; + if (e.x>=r[0] && e.y>=r[1] && e.x { + if (LR == 1) { // right + drawSpecials(); + } + if (LR == -1) { // left + drawOperators(); + } + if (UD == 1) { // down + drawNumbers(); + } + if (UD == -1) { // up + drawNumbers(); } } }); - 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); From 51a6377b71d2169a49b8b1b5f91934b139fc961c Mon Sep 17 00:00:00 2001 From: thyttan <97237430+thyttan@users.noreply.github.com> Date: Mon, 7 Nov 2022 11:20:03 +0100 Subject: [PATCH 3/3] add one word --- apps/calculator/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/calculator/README.md b/apps/calculator/README.md index 8681965f2..62f6cef24 100644 --- a/apps/calculator/README.md +++ b/apps/calculator/README.md @@ -21,7 +21,7 @@ Bangle.js 1 Bangle.js 2 - Swipes to change visible buttons -- Click physical button exit +- Click physical button to exit - Press upper left corner of screen to exit (where the red back button would be) ## Creator