From dbbb16b69f84e33d32d7c06f5b6f3c1f8b8d8174 Mon Sep 17 00:00:00 2001 From: Pavel Machek Date: Thu, 21 Nov 2024 23:33:28 +0100 Subject: [PATCH] skyspy: use touch handling from the library, cleanups --- apps/skyspy/skyspy.app.js | 55 +++++++++------------------------------ 1 file changed, 13 insertions(+), 42 deletions(-) diff --git a/apps/skyspy/skyspy.app.js b/apps/skyspy/skyspy.app.js index 6acebb3a9..44e933c34 100644 --- a/apps/skyspy/skyspy.app.js +++ b/apps/skyspy/skyspy.app.js @@ -218,6 +218,8 @@ let ui = { h: 152, w: 176, last_b: 0, + topLeft: function() { this.drawMsg("Unimpl"); }, + topRight: function() { this.drawMsg("Unimpl"); }, touchHandler: function(d) { let x = Math.floor(d.x); let y = Math.floor(d.y); @@ -229,18 +231,15 @@ let ui = { print("touch", x, y, this.h, this.w); - /* - if ((xthis.h/2) && (ythis.w/2)) { + if ((xthis.w/2) && (ythis.y2/2)) { print("prev"); this.prevScreen(); } - if ((x>this.h/2) && (y>this.w/2)) { + if ((x>this.w/2) && (y>this.y2/2)) { print("next"); this.nextScreen(); } @@ -473,46 +472,18 @@ function markGps() { gps_display.updateGps(); } -gps_quality.resetAlt(); - ui.init(); ui.numScreens = 3; -ui.drawBusy(); - -var last_b = 0; -function touchHandler(d) { - let x = Math.floor(d.x); - let y = Math.floor(d.y); - - if (d.b != 1 || last_b != 0) { - last_b = d.b; - return; - } - last_b = d.b; - - if ((xui.y2/2) && (yui.w/2)) - ui.prevScreen(); - if ((x>ui.y2/2) && (y>ui.w/2)) - ui.nextScreen(); -} - -ui.init(); gps.init(); +gps_quality.resetAlt(); fmt.init(); -Bangle.on("drag", touchHandler); +ui.topLeft = () => { ui.drawMsg("Clock\nadjust"); adj_time = 1; }; +ui.topRight = () => { ui.drawMsg("Alt\nadjust"); adj_alt = 1; }; + +Bangle.on("drag", (b) => ui.touchHandler(b)); Bangle.setUI({ mode : "custom", - swipe : ui.onSwipe, clock : 0 });