So... this is what I've got so far.
It just flashes back and forth between the "Zen" splash and the clock.
I think we're almost there.
Any Suggestions?
// This is my Zen Splash Screen
function zen(){
setInterval(function() {
g.clear(1);
//Draw Text
g.setFont("Vector",45);
g.drawString("Now",42,70);
}, 5000);
}
// clock from your tutorial
function time(){
// Load fonts
// position on screen
const X = 170, Y = 110;
function draw() {
// work out how to display the current time
var d = new Date();
var h = d.getHours(), m = d.getMinutes();
var time = (" "+h).substr(-2) + ":" + ("0"+m).substr(-2);
// Reset the state of the graphics library
g.reset();
// draw the current time
g.setFont("Vector",55);
g.setFontAlign(40,40); // align right bottom
g.drawString(time, X, Y, true /*clear background*/);
// draw the date, in a normal font
g.setFont("Vector",20);
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*/);
}
// Clear the screen once, at startup
g.clear();
// draw immediately at first
draw();
var secondInterval = setInterval(draw, 1000);
// Stop updates when LCD is off, restart when on
Bangle.on('lcdPower',on=>{
if (secondInterval) clearInterval(secondInterval);
secondInterval = undefined;
if (on) {
secondInterval = setInterval(draw, 1000);
draw(); // draw immediately
}
});
// Show launcher when middle button pressed
Bangle.setUI("clock");
// Load widgets
Bangle.loadWidgets();
Bangle.drawWidgets();
//revert to zen splashscreen
myTimeout = setTimeout (zen, 3000);
}
// run clock
time();
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
So... this is what I've got so far.
It just flashes back and forth between the "Zen" splash and the clock.
I think we're almost there.
Any Suggestions?