updated example clock with fast load code and a screenshot

pull/3430/head
Gordon Williams 2024-05-21 11:28:01 +01:00
parent 662cb75dfa
commit e0acc5610e
3 changed files with 45 additions and 40 deletions

View File

@ -1,16 +1,17 @@
{
// timeout used to update every minute
let drawTimeout;
// schedule a draw for the next minute
function queueDraw() {
let queueDraw = function() {
if (drawTimeout) clearTimeout(drawTimeout);
drawTimeout = setTimeout(function() {
drawTimeout = undefined;
draw();
}, 60000 - (Date.now() % 60000));
}
};
function draw() {
let draw = function() {
// queue next draw in one minute
queueDraw();
// Work out where to draw...
@ -30,7 +31,7 @@ function draw() {
g.setFontAlign(0,0).setFont("6x8");
g.clearRect(0,y-4,g.getWidth(),y+4); // clear the background
g.drawString(dateStr,x,y);
}
};
// Clear the screen once, at startup
g.clear();
@ -38,7 +39,10 @@ g.clear();
draw();
// Show launcher when middle button pressed
Bangle.setUI("clock");
Bangle.setUI({mode:"clock", remove:function() {
// free any memory we allocated to allow fast loading
}});
// Load widgets
Bangle.loadWidgets();
Bangle.drawWidgets();
}

View File

@ -4,6 +4,7 @@
"version":"0.01",
"description": "A detailed description of my clock",
"icon": "icon.png",
"screenshots": [{"url":"screenshot.png"}],
"type": "clock",
"tags": "clock",
"supports" : ["BANGLEJS2"],

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB