lcdclock: load clockinfo before widgets

This matches the behaviour of other clocks, meaning any dependencies
between widgets and clock info is consistent

See also #2900
master
Rob Pilling 2023-08-08 07:28:56 +01:00
parent 614c003eca
commit 5ab81829a2
3 changed files with 28 additions and 26 deletions

View File

@ -1,3 +1,4 @@
0.01: New App! 0.01: New App!
0.02: Use clock_info module as an app 0.02: Use clock_info module as an app
0.03: clock_info now uses app name to maintain settings specifically for this clock face 0.03: clock_info now uses app name to maintain settings specifically for this clock face
0.04: clock_info is loaded before widgets to match other clocks

View File

@ -30,24 +30,6 @@ let draw = function() {
}, 60000 - (Date.now() % 60000)); }, 60000 - (Date.now() % 60000));
}; };
// Show launcher when middle button pressed
Bangle.setUI({
mode : "clock",
remove : function() {
// Called to unload all of the clock app
if (drawTimeout) clearTimeout(drawTimeout);
drawTimeout = undefined;
delete Graphics.prototype.setFont7Seg;
// remove info menu
clockInfoMenu.remove();
delete clockInfoMenu;
clockInfoMenu2.remove();
delete clockInfoMenu2;
// reset theme
g.setTheme(oldTheme);
}});
// Load widgets
Bangle.loadWidgets();
var R = Bangle.appRect; var R = Bangle.appRect;
R.x+=1; R.x+=1;
R.y+=1; R.y+=1;
@ -57,12 +39,6 @@ R.w-=2;
R.h-=2; R.h-=2;
var midX = R.x+R.w/2; var midX = R.x+R.w/2;
var barY = 80; var barY = 80;
// Clear the screen once, at startup
let oldTheme = g.theme;
g.setTheme({bg:"#000",fg:"#fff",dark:true}).clear(1);
g.fillRect({x:R.x, y:R.y, w:R.w, h:R.h, r:8}).clearRect(R.x,barY,R.w,barY+1).clearRect(midX,R.y,midX+1,barY);
draw();
setTimeout(Bangle.drawWidgets,0);
let clockInfoDraw = (itm, info, options) => { let clockInfoDraw = (itm, info, options) => {
let texty = options.y+41; let texty = options.y+41;
@ -81,4 +57,29 @@ let clockInfoDraw = (itm, info, options) => {
let clockInfoItems = require("clock_info").load(); let clockInfoItems = require("clock_info").load();
let clockInfoMenu = require("clock_info").addInteractive(clockInfoItems, { app:"lcdclock", x:R.x, y:R.y, w:midX-2, h:barY-R.y-2, draw : clockInfoDraw}); let clockInfoMenu = require("clock_info").addInteractive(clockInfoItems, { app:"lcdclock", x:R.x, y:R.y, w:midX-2, h:barY-R.y-2, draw : clockInfoDraw});
let clockInfoMenu2 = require("clock_info").addInteractive(clockInfoItems, { app:"lcdclock", x:midX+2, y:R.y, w:midX-3, h:barY-R.y-2, draw : clockInfoDraw}); let clockInfoMenu2 = require("clock_info").addInteractive(clockInfoItems, { app:"lcdclock", x:midX+2, y:R.y, w:midX-3, h:barY-R.y-2, draw : clockInfoDraw});
// Show launcher when middle button pressed
Bangle.setUI({
mode : "clock",
remove : function() {
// Called to unload all of the clock app
if (drawTimeout) clearTimeout(drawTimeout);
drawTimeout = undefined;
delete Graphics.prototype.setFont7Seg;
// remove info menu
clockInfoMenu.remove();
delete clockInfoMenu;
clockInfoMenu2.remove();
delete clockInfoMenu2;
// reset theme
g.setTheme(oldTheme);
}});
// Load widgets
Bangle.loadWidgets();
// Clear the screen once, at startup
let oldTheme = g.theme;
g.setTheme({bg:"#000",fg:"#fff",dark:true}).clear(1);
g.fillRect({x:R.x, y:R.y, w:R.w, h:R.h, r:8}).clearRect(R.x,barY,R.w,barY+1).clearRect(midX,R.y,midX+1,barY);
draw();
setTimeout(Bangle.drawWidgets,0);
} }

View File

@ -1,6 +1,6 @@
{ "id": "lcdclock", { "id": "lcdclock",
"name": "LCD Clock", "name": "LCD Clock",
"version":"0.03", "version":"0.04",
"description": "A Casio-style clock, with ClockInfo areas at the top and bottom. Tap them and swipe up/down to toggle between different information", "description": "A Casio-style clock, with ClockInfo areas at the top and bottom. Tap them and swipe up/down to toggle between different information",
"icon": "app.png", "icon": "app.png",
"screenshots": [{"url":"screenshot.png"}], "screenshots": [{"url":"screenshot.png"}],