mirror of https://github.com/espruino/BangleApps
Add time line
parent
f61aa0650a
commit
97785aadbd
|
@ -76,6 +76,7 @@ function tick() {
|
|||
function draw() {
|
||||
// work out how to display the current time
|
||||
const timeLines = getTimeLines(mins);
|
||||
const bottomLines = getBottomLines();
|
||||
|
||||
// Reset the state of the graphics library
|
||||
g.clear(true);
|
||||
|
@ -85,12 +86,13 @@ function draw() {
|
|||
g.setFontAlign(0,0); // align center top
|
||||
g.drawString(timeLines.join("\n"), X, Y, true /*clear background*/);
|
||||
|
||||
// draw the date, in a normal font
|
||||
if (bottomLines.length) {
|
||||
// draw the time and/or date, in a normal font
|
||||
g.setFont("6x8");
|
||||
g.setFontAlign(0,1); // align center bottom
|
||||
// pad the date - this clears the background if the date were to change length
|
||||
var dateStr = " "+require("locale").date(date)+" ";
|
||||
g.drawString(dateStr, SCREEN_WIDTH / 2, SCREEN_HEIGHT - 5, true /*clear background*/);
|
||||
g.drawString(bottomLines.join('\n'), SCREEN_WIDTH/2, SCREEN_HEIGHT - 5, true /*clear background*/);
|
||||
}
|
||||
|
||||
/* Show launcher when middle button pressed
|
||||
This should be done *before* Bangle.loadWidgets so that
|
||||
|
@ -116,6 +118,20 @@ function setFont(timeLines) {
|
|||
}
|
||||
}
|
||||
|
||||
function getBottomLines() {
|
||||
const lines = [];
|
||||
|
||||
if (settings.showTimeLine) {
|
||||
lines.push(require("locale").time(date));
|
||||
}
|
||||
|
||||
if (settings.showDateLine) {
|
||||
lines.push(`${date.getHours()}:${String(date.getMinutes()).padStart(2, '0')}`);
|
||||
}
|
||||
|
||||
return lines;
|
||||
}
|
||||
|
||||
function getTimeLines(m) {
|
||||
switch (settings.variant) {
|
||||
case VARIANT_EXACT:
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"name": "Dutch Clock",
|
||||
"shortName":"Dutch Clock",
|
||||
"icon": "app.png",
|
||||
"version":"0.06",
|
||||
"version":"0.07",
|
||||
"description": "A clock that displays the time the way a Dutch person would respond when asked what time it is.",
|
||||
"type": "clock",
|
||||
"tags": "clock,dutch,text",
|
||||
|
|
Loading…
Reference in New Issue