Made Date more visible

pull/701/head
Tutturuuu 2021-03-22 20:19:31 +01:00 committed by GitHub
parent df5fb6c052
commit b6a29a7da1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 10 deletions

View File

@ -5,7 +5,7 @@ require("Font7x11Numeric7Seg").add(Graphics);
var is12Hour = (require("Storage").readJSON("setting.json",1)||{})["12hour"];
// position on screen
const X = 160, Y = 140;
function draw() {
// work out how to display the current time
var d = new Date();
@ -23,15 +23,15 @@ function draw() {
g.drawString(time, X, Y, true /*clear background*/);
// draw the seconds (2x size 7 segment)
g.setFont("7x11Numeric7Seg",2);
g.drawString(("0"+d.getSeconds()).substr(-2), X+30, Y, true /*clear background*/);
g.drawString(("0"+d.getSeconds()).substr(-2), X+35, Y, true /*clear background*/);
// draw the date, in a normal font
g.setFont("6x8");
g.setFont("6x8", 3);
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(d)+" ";
g.drawString(dateStr, g.getWidth()/2, Y+15, true /*clear background*/);
g.drawString(dateStr, g.getWidth()/2, Y+35, true /*clear background*/);
}
// Clear the screen once, at startup
g.clear();
// draw immediately at first
@ -51,7 +51,7 @@ Bangle.loadWidgets();
Bangle.drawWidgets();
// Show launcher when middle button pressed
setWatch(Bangle.showLauncher, BTN2, { repeat: false, edge: "falling" });
// ====================================== Vibration
// vibrate 0..9
function vibrateDigit(num) {
@ -74,24 +74,24 @@ function vibrateNumber(num) {
});
});
}
var vibrateBusy;
function vibrateTime() {
if (vibrateBusy) return;
vibrateBusy = true;
var d = new Date();
var hours = d.getHours(), minutes = d.getMinutes();
if (is12Hour) {
if (hours == 0) hours = 12;
else if (hours>12) hours -= 12;
}
vibrateNumber(hours.toString()).
then(() => new Promise(resolve=>setTimeout(resolve,500))).
then(() => vibrateNumber(minutes.toString())).
then(() => vibrateBusy=false);
}
// when BTN1 pressed, vibrate
setWatch(vibrateTime, BTN1, {repeat:true,edge:"rising"});