Updated watch face for hour

master
Ephraim Amiel Yusi 2020-05-27 14:12:45 +10:00 committed by GitHub
parent 288d6bea72
commit 49a83ee65f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 12 deletions

View File

@ -4,28 +4,28 @@ require("Font7x11Numeric7Seg").add(Graphics);
function draw() { function draw() {
var daysOfWeek = ["MON", "TUE","WED","THUR","FRI","SAT","SUN"];
// work out how to display the current time // work out how to display the current time
var d = new Date(); var d = new Date();
var h = d.getHours(), m = d.getMinutes(), day = d.getDate(), month = (d.getMonth()+1), weekDay = d.getDay(); var h = d.getHours(), m = d.getMinutes(), day = d.getDate(), month = (d.getMonth()+1), weekDay = d.getDay();
var hours = h; var daysOfWeek = ["MON", "TUE","WED","THUR","FRI","SAT","SUN"];
var hours = ("0"+h).substr(-2);
var mins= ("0"+m).substr(-2); var mins= ("0"+m).substr(-2);
var date = `${daysOfWeek[weekDay]}\n\n${day}/${month}`; var date = `${daysOfWeek[weekDay]}\n\n${day}/${month}`;
// Reset the state of the graphics library // Reset the state of the graphics library
g.reset(); g.reset();
// draw the current time (4x size 7 segment)
// draw the current time g.setFont("7x11Numeric7Seg",6);
g.setFont("7x11Numeric7Seg",8);
g.setFontAlign(-1,0); // align right bottom g.setFontAlign(-1,0); // align right bottom
g.drawString(hours, 30, 70, true /*clear background*/); g.drawString(hours, 30, 80, true /*clear background*/);
g.drawString(mins, 30, 170, true /*clear background*/); g.drawString(mins, 30, 160, true /*clear background*/);
// draw the date (2x size 7 segment) // draw the date (2x size 7 segment)
g.setFont("6x8",2.5); g.setFont("6x8",2);
g.setFontAlign(-1,0); // align right bottom g.setFontAlign(-1,0); // align right bottom
g.drawString(date, 150, 110, true /*clear background*/); g.drawString(date, 130, 110, true /*clear background*/);
} }
// Clear the screen once, at startup // Clear the screen once, at startup