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);