Skip to content

Commit

Permalink
Merge pull request #3061 from nxdefiant/master
Browse files Browse the repository at this point in the history
scicalc: Switch swipe handling
  • Loading branch information
gfwilliams authored Oct 27, 2023
2 parents fbfb087 + d06f9bd commit a6a6e5f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
1 change: 1 addition & 0 deletions apps/scicalc/ChangeLog
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion apps/scicalc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 9 additions & 5 deletions apps/scicalc/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
Expand All @@ -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);
2 changes: 1 addition & 1 deletion apps/scicalc/metadata.json
Original file line number Diff line number Diff line change
@@ -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" } ],
Expand Down

0 comments on commit a6a6e5f

Please sign in to comment.