Move input handling inside setUI (Bangle2)

pull/2242/head
thyttan 2022-11-07 11:04:52 +01:00 committed by GitHub
parent b468ac3498
commit cd5367977f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 30 additions and 28 deletions

View File

@ -3,6 +3,8 @@
* *
* Original Author: Frederic Rousseau https://github.com/fredericrous * Original Author: Frederic Rousseau https://github.com/fredericrous
* Created: April 2020 * Created: April 2020
*
* Contributors: thyttan https://github.com/thyttan
*/ */
g.clear(); g.clear();
@ -402,29 +404,27 @@ if (process.env.HWVERSION==1) {
swipeEnabled = false; swipeEnabled = false;
drawGlobal(); drawGlobal();
} else { // touchscreen? } 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; swipeEnabled = true;
prepareScreen(numbers, numbersGrid, COLORS.DEFAULT); prepareScreen(numbers, numbersGrid, COLORS.DEFAULT);
prepareScreen(operators, operatorsGrid, COLORS.OPERATOR); prepareScreen(operators, operatorsGrid, COLORS.OPERATOR);
prepareScreen(specials, specialsGrid, COLORS.SPECIAL); prepareScreen(specials, specialsGrid, COLORS.SPECIAL);
drawNumbers(); drawNumbers();
Bangle.on('touch',(n,e)=>{
Bangle.setUI({
mode : 'custom',
back : load, // Clicking physical button or pressing upper left corner turns off (where red back button would be)
touch : (n,e)=>{
for (var key in screen) { for (var key in screen) {
if (typeof screen[key] == "undefined") break; if (typeof screen[key] == "undefined") break;
var r = screen[key].xy; var r = screen[key].xy;
if (e.x>=r[0] && e.y>=r[1] && if (e.x>=r[0] && e.y>=r[1] && e.x<r[2] && e.y<r[3]) {
e.x<r[2] && e.y<r[3]) {
//print("Press "+key); //print("Press "+key);
buttonPress(""+key); buttonPress(""+key);
} }
} }
}); },
Bangle.on('swipe', (LR, UD) => { swipe : (LR, UD) => {
if (LR == 1) { // right if (LR == 1) { // right
drawSpecials(); drawSpecials();
} }
@ -437,7 +437,9 @@ if (process.env.HWVERSION==1) {
if (UD == -1) { // up if (UD == -1) { // up
drawNumbers(); drawNumbers();
} }
}
}); });
} }
displayOutput(0); displayOutput(0);