forked from espruino/BangleApps
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:espruino/BangleApps
- Loading branch information
Showing
9 changed files
with
126 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.01: New Clock Nifty A |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
const locale = require("locale"); | ||
const is12Hour = (require("Storage").readJSON("setting.json", 1) || {})["12hour"]; | ||
|
||
/* Clock *********************************************/ | ||
const scale = g.getWidth() / 176; | ||
|
||
const widget = 24; | ||
|
||
const viewport = { | ||
width: g.getWidth(), | ||
height: g.getHeight(), | ||
} | ||
|
||
const center = { | ||
x: viewport.width / 2, | ||
y: Math.round(((viewport.height - widget) / 2) + widget), | ||
} | ||
|
||
function d02(value) { | ||
return ('0' + value).substr(-2); | ||
} | ||
|
||
function draw() { | ||
g.reset(); | ||
g.clearRect(0, widget, viewport.width, viewport.height); | ||
const now = new Date(); | ||
|
||
const hour = d02(now.getHours() - (is12Hour && now.getHours() > 12 ? 12 : 0)); | ||
const minutes = d02(now.getMinutes()); | ||
const day = d02(now.getDay()); | ||
const month = d02(now.getMonth() + 1); | ||
const year = now.getFullYear(); | ||
|
||
const month2 = locale.month(now, 3); | ||
const day2 = locale.dow(now, 3); | ||
|
||
g.setFontAlign(1, 0).setFont("Vector", 90 * scale); | ||
g.drawString(hour, center.x + 32 * scale, center.y - 31 * scale); | ||
g.drawString(minutes, center.x + 32 * scale, center.y + 46 * scale); | ||
|
||
g.fillRect(center.x + 30 * scale, center.y - 72 * scale, center.x + 32 * scale, center.y + 74 * scale); | ||
|
||
g.setFontAlign(-1, 0).setFont("Vector", 16 * scale); | ||
g.drawString(year, center.x + 40 * scale, center.y - 62 * scale); | ||
g.drawString(month, center.x + 40 * scale, center.y - 44 * scale); | ||
g.drawString(day, center.x + 40 * scale, center.y - 26 * scale); | ||
g.drawString(month2, center.x + 40 * scale, center.y + 48 * scale); | ||
g.drawString(day2, center.x + 40 * scale, center.y + 66 * scale); | ||
} | ||
|
||
|
||
/* Minute Ticker *************************************/ | ||
|
||
let tickTimer; | ||
|
||
function clearTickTimer() { | ||
if (tickTimer) { | ||
clearTimeout(tickTimer); | ||
tickTimer = undefined; | ||
} | ||
} | ||
|
||
function queueNextTick() { | ||
clearTickTimer(); | ||
tickTimer = setTimeout(tick, 60000 - (Date.now() % 60000)); | ||
// tickTimer = setTimeout(tick, 3000); | ||
} | ||
|
||
function tick() { | ||
draw(); | ||
queueNextTick(); | ||
} | ||
|
||
/* Init **********************************************/ | ||
|
||
// Clear the screen once, at startup | ||
g.clear(); | ||
// Start ticking | ||
tick(); | ||
|
||
// Stop updates when LCD is off, restart when on | ||
Bangle.on('lcdPower', (on) => { | ||
if (on) { | ||
tick(); // Start ticking | ||
} else { | ||
clearTickTimer(); // stop ticking | ||
} | ||
}); | ||
|
||
// Load widgets | ||
Bangle.loadWidgets(); | ||
Bangle.drawWidgets(); | ||
|
||
// Show launcher when middle button pressed | ||
Bangle.setUI("clock"); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
0.01: First release | ||
0.02: Display 12 hour clock as 12:xx not 00:xx when just into PM | ||
0.03: Make it work with Gadgetbridge, Notifications fullscreen on a Bangle 2 | ||
0.04: Leave space at the bottom for Chrono widget, set back option at first option |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters