scicalc: Switch swipe handling

As discussed in #3054

- Use Swipe up/down to switch between screens, left to delete, right to
calculate result
- Also use Bangle.setUI()
pull/3061/head
Erik Andresen 2023-10-27 15:39:11 +02:00
parent 3b59bead01
commit d06f9bdc6e
4 changed files with 12 additions and 7 deletions

View File

@ -1,2 +1,3 @@
0.01: New App!
0.02: Swiping up has now the same effect as hitting the "<" button.
0.03: Use Swipe up/down to switch between screens, left to delete, right to calculate result

View File

@ -5,7 +5,7 @@ by the JS interpreter.
## Usage
Buttons are arranged on 3 separate screens, swiping left or right switches between them. Swiping down has the same effect as hitting the "=" button. Swiping up has the same effect as hitting the "<" button.
Buttons are arranged on 3 separate screens, swiping up or down switches between them. Swiping right has the same effect as hitting the "=" button. Swiping left has the same effect as hitting the "<" button.
## Features

View File

@ -70,7 +70,7 @@ function compute() {
console.log(processInp(inputStr));
try { res = eval(processInp(inputStr)); }
catch(e) { res = "error"; }
inputStr = res === undefined ? '' : res;
inputStr = res === undefined ? '' : res.toString();
qResult = true;
updateDisp(inputStr, 19);
}
@ -99,7 +99,7 @@ function touchHandler(e, d) {
updateDisp(inputStr, 32);
}
function swipeHandler(e,d) {
function swipeHandler(d,e) {
curPage -= e;
if (curPage>buttons.length-1) curPage = 0;
if (curPage<0) curPage = buttons.length-1;
@ -112,8 +112,12 @@ function swipeHandler(e,d) {
}
}
Bangle.on("touch", touchHandler);
Bangle.on("swipe", swipeHandler);
setWatch(() => load(), BTN, { repeat: false, edge: "falling" });
Bangle.setUI({
mode : "custom",
touch : touchHandler,
swipe : swipeHandler,
btn : () => load(),
});
g.clear();
drawPage(curPage);

View File

@ -1,7 +1,7 @@
{ "id": "scicalc",
"name": "Scientific Calculator",
"shortName":"SciCalc",
"version":"0.02",
"version":"0.03",
"description": "Scientific calculator",
"icon": "scicalc.png",
"screenshots" : [ { "url":"scicalc_screenshot1.png" }, { "url":"scicalc_screenshot2.png" }, { "url":"scicalc_screenshot3.png" } ],