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

BangleJS2: Swipe down to rotate screen. So you can show the time to a friend real quick. #2369

Merged
merged 2 commits into from
Dec 7, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/hworldclock/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
0.23: Added note to configure position in "my location" if not done yet. Small fixes.
0.24: Added fast load
0.25: Minor code optimization
0.26: BJS2: Swipe down to rotate 180 degree
1 change: 1 addition & 0 deletions apps/hworldclock/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Provide names and the UTC offsets for up to three other timezones in the app sto

The clock does not handle summer time / daylight saving time changes automatically. If one of your three locations changes its UTC offset, you can simply change the setting in the app store and update. Currently the clock only supports 24 hour time format for the additional time zones.

BangleJS2: Swipe down to rotate screen. So you can show the time to a friend real quick.

## Requests

Expand Down
51 changes: 50 additions & 1 deletion apps/hworldclock/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var showSunInfo;
var colorWhenDark;
// ------- Settings file

const BANGLEJS2 = process.env.HWVERSION == 2;
const big = g.getWidth()>200;
// Font for primary time and date
const primaryTimeFontSize = big?6:5;
Expand All @@ -24,6 +25,7 @@ const xcol1 = 10;
const xcol2 = g.getWidth() - xcol1;

const font = "6x8";
let drag;

/* TODO: we could totally use 'Layout' here and
avoid a whole bunch of hard-coded offsets */
Expand Down Expand Up @@ -317,6 +319,54 @@ Bangle.drawWidgets();
draw();



function initDragEvents() {

if (BANGLEJS2) {
Bangle.on("drag", e => {
if (!drag) { // start dragging
drag = {x: e.x, y: e.y};
} else if (!e.b) { // released
const dx = e.x-drag.x, dy = e.y-drag.y;
drag = null;
if (Math.abs(dx)>Math.abs(dy)+10) {
// horizontal
if (dx < dy) {
// for later purpose
} else {
// for later purpose
}
} else if (Math.abs(dy)>Math.abs(dx)+10) {
// vertical
if (dx < dy) {
g.clear().setRotation(2);
draw();
Bangle.loadWidgets();
Bangle.drawWidgets();
} else {
g.clear().setRotation(0);
draw();
Bangle.loadWidgets();
Bangle.drawWidgets();
}
} else {
//console.log("tap " + e.x + " " + e.y);
if (e.x > 145 && e.y > 145) {
// for later purpose
}
}
}
});
} else {
//setWatch(xxx, BTN1, { repeat: true, debounce:50 }); // maybe adding this later
//setWatch(xxx, BTN3, { repeat: true, debounce:50 });
//setWatch(xxx, BTN4, { repeat: true, debounce:50 });
//setWatch(xxx, BTN5, { repeat: true, debounce:50 });
}
}

initDragEvents();

if (!Bangle.isLocked()) { // Initial state
if (showSunInfo) {
if (PosInterval != 0 && typeof PosInterval != 'undefined') clearInterval(PosInterval);
Expand Down Expand Up @@ -350,7 +400,6 @@ if (!Bangle.isLocked()) { // Initial state
updatePos();
}
draw(); // draw immediately, queue redraw

}


Expand Down
2 changes: 1 addition & 1 deletion apps/hworldclock/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id": "hworldclock",
"name": "Hanks World Clock",
"shortName": "Hanks World Clock",
"version": "0.25",
"version": "0.26",
"description": "Current time zone plus up to three others",
"allow_emulator":true,
"icon": "app.png",
Expand Down