Skip to content

Commit dbbb16b

Browse files
committed
skyspy: use touch handling from the library, cleanups
1 parent f5d88c8 commit dbbb16b

File tree

1 file changed

+13
-42
lines changed

1 file changed

+13
-42
lines changed

apps/skyspy/skyspy.app.js

Lines changed: 13 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ let ui = {
218218
h: 152,
219219
w: 176,
220220
last_b: 0,
221+
topLeft: function() { this.drawMsg("Unimpl"); },
222+
topRight: function() { this.drawMsg("Unimpl"); },
221223
touchHandler: function(d) {
222224
let x = Math.floor(d.x);
223225
let y = Math.floor(d.y);
@@ -229,18 +231,15 @@ let ui = {
229231

230232
print("touch", x, y, this.h, this.w);
231233

232-
/*
233-
if ((x<this.h/2) && (y<this.w/2)) {
234-
}
235-
if ((x>this.h/2) && (y<this.w/2)) {
236-
}
237-
*/
238-
239-
if ((x<this.h/2) && (y>this.w/2)) {
234+
if ((x<this.w/2) && (y<this.y2/2))
235+
this.topLeft();
236+
if ((x>this.w/2) && (y<this.y2/2))
237+
this.topRight();
238+
if ((x<this.w/2) && (y>this.y2/2)) {
240239
print("prev");
241240
this.prevScreen();
242241
}
243-
if ((x>this.h/2) && (y>this.w/2)) {
242+
if ((x>this.w/2) && (y>this.y2/2)) {
244243
print("next");
245244
this.nextScreen();
246245
}
@@ -473,46 +472,18 @@ function markGps() {
473472
gps_display.updateGps();
474473
}
475474

476-
gps_quality.resetAlt();
477-
478475
ui.init();
479476
ui.numScreens = 3;
480-
ui.drawBusy();
481-
482-
var last_b = 0;
483-
function touchHandler(d) {
484-
let x = Math.floor(d.x);
485-
let y = Math.floor(d.y);
486-
487-
if (d.b != 1 || last_b != 0) {
488-
last_b = d.b;
489-
return;
490-
}
491-
last_b = d.b;
492-
493-
if ((x<ui.y2/2) && (y<ui.w/2)) {
494-
ui.drawMsg("Clock\nadjust");
495-
adj_time = 1;
496-
}
497-
if ((x>ui.y2/2) && (y<ui.w/2)) {
498-
ui.drawMsg("Alt\nadjust");
499-
adj_alt = 1;
500-
}
501-
502-
if ((x<ui.y2/2) && (y>ui.w/2))
503-
ui.prevScreen();
504-
if ((x>ui.y2/2) && (y>ui.w/2))
505-
ui.nextScreen();
506-
}
507-
508-
ui.init();
509477
gps.init();
478+
gps_quality.resetAlt();
510479
fmt.init();
511480

512-
Bangle.on("drag", touchHandler);
481+
ui.topLeft = () => { ui.drawMsg("Clock\nadjust"); adj_time = 1; };
482+
ui.topRight = () => { ui.drawMsg("Alt\nadjust"); adj_alt = 1; };
483+
484+
Bangle.on("drag", (b) => ui.touchHandler(b));
513485
Bangle.setUI({
514486
mode : "custom",
515-
swipe : ui.onSwipe,
516487
clock : 0
517488
});
518489

0 commit comments

Comments
 (0)