Skip to content

Commit

Permalink
0.05: fix alignment of clock items caused by 0.04 (fix #2970)
Browse files Browse the repository at this point in the history
Also move var->let, to stop fast load memory leaks
  • Loading branch information
gfwilliams committed Aug 15, 2023
1 parent 9eded4c commit 656b8a2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
1 change: 1 addition & 0 deletions apps/lcdclock/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
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.04: clock_info is loaded before widgets to match other clocks
0.05: fix alignment of clock items caused by 0.04 (fix #2970)
32 changes: 16 additions & 16 deletions apps/lcdclock/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,6 @@ let draw = function() {
}, 60000 - (Date.now() % 60000));
};

var R = Bangle.appRect;
R.x+=1;
R.y+=1;
R.x2-=1;
R.y2-=1;
R.w-=2;
R.h-=2;
var midX = R.x+R.w/2;
var barY = 80;

let clockInfoDraw = (itm, info, options) => {
let texty = options.y+41;
g.reset().setFont("7Seg").setColor(g.theme.bg).setBgColor(g.theme.fg);
Expand All @@ -52,11 +42,7 @@ let clockInfoDraw = (itm, info, options) => {
if (title!="Bangle") g.setFontAlign(1,0).drawString(title.toUpperCase(), options.x+options.w-2, options.y+14);
if (g.setFont("7Seg:2").stringWidth(text)+8>options.w) g.setFont("7Seg");
g.setFontAlign(0,0).drawString(text, options.x+options.w/2, options.y+40);

};
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 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({
Expand All @@ -76,10 +62,24 @@ Bangle.setUI({
}});
// Load widgets
Bangle.loadWidgets();
// Work out sizes
let R = Bangle.appRect;
R.x+=1;
R.y+=1;
R.x2-=1;
R.y2-=1;
R.w-=2;
R.h-=2;
let midX = R.x+R.w/2;
let 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);
}
Bangle.drawWidgets();
// Allocate and draw clockinfos
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 clockInfoMenu2 = require("clock_info").addInteractive(clockInfoItems, { app:"lcdclock", x:midX+2, y:R.y, w:midX-3, h:barY-R.y-2, draw : clockInfoDraw});
}
2 changes: 1 addition & 1 deletion apps/lcdclock/metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ "id": "lcdclock",
"name": "LCD Clock",
"version":"0.04",
"version":"0.05",
"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",
"screenshots": [{"url":"screenshot.png"}],
Expand Down

0 comments on commit 656b8a2

Please sign in to comment.