Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aviatorclk: added tap event to scroll METAR and toggle seconds display #3182

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/aviatorclk/ChangeLog
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
1.00: initial release
1.01: added tap event to scroll METAR and toggle seconds display
9 changes: 7 additions & 2 deletions apps/aviatorclk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,20 @@ module after installing this app.
- Latest METAR for the nearest airport (scrollable)

Tap the screen in the top or bottom half to scroll the METAR text (in case not
the whole report fits on the screen).
the whole report fits on the screen). You can also tap the watch from the top
or bottom to scroll, which works even with the screen locked.

The colour of the METAR text will change to orange if the report is more than
1h old, and red if it's older than 1.5h.

To toggle the seconds display, double tap the watch from either the left or
right. This only changes the display "temporarily" (ie. it doesn't change the
default configured through the settings).


## Settings

- **Show Seconds**: to conserve battery power, you can turn the seconds display off
- **Show Seconds**: to conserve battery power, you can turn the seconds display off (as the default)
- **Invert Scrolling**: swaps the METAR scrolling direction of the top and bottom taps


Expand Down
47 changes: 39 additions & 8 deletions apps/aviatorclk/aviatorclk.app.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ function drawSeconds() {
let seconds = now.getSeconds().toString();
if (seconds.length == 1) seconds = '0' + seconds;
let y = Bangle.appRect.y + mainTimeHeight - 3;
g.setBgColor(g.theme.bg);
g.setFontAlign(-1, 1).setFont("Vector", secondaryFontHeight).setColor(COLOUR_GREY);
g.drawString(seconds, horizontalCenter + 54, y, true);
}
Expand Down Expand Up @@ -232,10 +233,10 @@ function draw() {
// initialise
g.clear(true);

// scroll METAR lines on taps
Bangle.setUI("clockupdown", action => {
// scroll METAR lines (either by touch or tap)
function scrollAVWX(action) {
switch (action) {
case -1: // top tap
case -1: // top touch/tap
if (settings.invertScrolling) {
if (METARscollLines > 0)
METARscollLines--;
Expand All @@ -244,7 +245,7 @@ Bangle.setUI("clockupdown", action => {
METARscollLines++;
}
break;
case 1: // bottom tap
case 1: // bottom touch/tap
if (settings.invertScrolling) {
if (METARscollLines < METARlinesCount - 4)
METARscollLines++;
Expand All @@ -254,11 +255,41 @@ Bangle.setUI("clockupdown", action => {
}
break;
default:
// ignore
// ignore other actions
}
drawAVWX();
}

Bangle.on('tap', data => {
switch (data.dir) {
case 'top':
scrollAVWX(-1);
break;
case 'bottom':
scrollAVWX(1);
break;
case 'left':
case 'right':
// toggle seconds display on double taps left or right
if (data.double) {
if (settings.showSeconds) {
clearInterval(secondsInterval);
let y = Bangle.appRect.y + mainTimeHeight - 3;
g.clearRect(horizontalCenter + 54, y - secondaryFontHeight, g.getWidth(), y);
settings.showSeconds = false;
} else {
settings.showSeconds = true;
syncSecondsUpdate();
}
}
break;
default:
// ignore other taps
}
});

Bangle.setUI("clockupdown", scrollAVWX);

// load widgets
Bangle.loadWidgets();
Bangle.drawWidgets();
Expand All @@ -276,8 +307,8 @@ updateAVWX();


// TMP for debugging:
//METAR = 'YAAA 011100Z 21014KT CAVOK 23/08 Q1018 RMK RF000/0000';
//METAR = 'YAAA 150900Z 14012KT 9999 SCT045 BKN064 26/14 Q1012 RMK RF000/0000 DL-W/DL-NW';
//METAR = 'YAAA 020030Z VRB CAVOK';
//METAR = 'YAAA 011100Z 21014KT CAVOK 23/08 Q1018 RMK RF000/0000'; drawAVWX();
//METAR = 'YAAA 150900Z 14012KT 9999 SCT045 BKN064 26/14 Q1012 RMK RF000/0000 DL-W/DL-NW'; drawAVWX();
//METAR = 'YAAA 020030Z VRB CAVOK'; drawAVWX();
//METARts = new Date(Date.now() - 61 * 60000); // 61 to trigger warning, 91 to trigger alert

2 changes: 1 addition & 1 deletion apps/aviatorclk/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id": "aviatorclk",
"name": "Aviator Clock",
"shortName":"AV8R Clock",
"version":"1.00",
"version":"1.01",
"description": "A clock for aviators, with local time and UTC - and the latest METAR for the nearest airport",
"icon": "aviatorclk.png",
"screenshots": [{ "url": "screenshot.png" }, { "url": "screenshot2.png" }],
Expand Down
Loading