1
0
Fork 0

skyspy: use touch handling from the library, cleanups

master
Pavel Machek 2024-11-21 23:33:28 +01:00
parent f5d88c8edc
commit dbbb16b69f
1 changed files with 13 additions and 42 deletions

View File

@ -218,6 +218,8 @@ let ui = {
h: 152, h: 152,
w: 176, w: 176,
last_b: 0, last_b: 0,
topLeft: function() { this.drawMsg("Unimpl"); },
topRight: function() { this.drawMsg("Unimpl"); },
touchHandler: function(d) { touchHandler: function(d) {
let x = Math.floor(d.x); let x = Math.floor(d.x);
let y = Math.floor(d.y); let y = Math.floor(d.y);
@ -229,18 +231,15 @@ let ui = {
print("touch", x, y, this.h, this.w); print("touch", x, y, this.h, this.w);
/* if ((x<this.w/2) && (y<this.y2/2))
if ((x<this.h/2) && (y<this.w/2)) { this.topLeft();
} if ((x>this.w/2) && (y<this.y2/2))
if ((x>this.h/2) && (y<this.w/2)) { this.topRight();
} if ((x<this.w/2) && (y>this.y2/2)) {
*/
if ((x<this.h/2) && (y>this.w/2)) {
print("prev"); print("prev");
this.prevScreen(); this.prevScreen();
} }
if ((x>this.h/2) && (y>this.w/2)) { if ((x>this.w/2) && (y>this.y2/2)) {
print("next"); print("next");
this.nextScreen(); this.nextScreen();
} }
@ -473,46 +472,18 @@ function markGps() {
gps_display.updateGps(); gps_display.updateGps();
} }
gps_quality.resetAlt();
ui.init(); ui.init();
ui.numScreens = 3; 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 ((x<ui.y2/2) && (y<ui.w/2)) {
ui.drawMsg("Clock\nadjust");
adj_time = 1;
}
if ((x>ui.y2/2) && (y<ui.w/2)) {
ui.drawMsg("Alt\nadjust");
adj_alt = 1;
}
if ((x<ui.y2/2) && (y>ui.w/2))
ui.prevScreen();
if ((x>ui.y2/2) && (y>ui.w/2))
ui.nextScreen();
}
ui.init();
gps.init(); gps.init();
gps_quality.resetAlt();
fmt.init(); 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({ Bangle.setUI({
mode : "custom", mode : "custom",
swipe : ui.onSwipe,
clock : 0 clock : 0
}); });