1
0
Fork 0

barclock: add font setting

master
Richard de Boer 2022-05-27 17:20:13 +02:00
parent f90d5dbdca
commit 65d59242d5
No known key found for this signature in database
GPG Key ID: 8721727971871937
5 changed files with 24 additions and 6 deletions

View File

@ -10,3 +10,4 @@
0.10: Use ClockFace library 0.10: Use ClockFace library
0.11: Use ClockFace.is12Hour 0.11: Use ClockFace.is12Hour
0.12: Add settings to hide date,widgets 0.12: Add settings to hide date,widgets
0.13: Add font setting

View File

@ -6,4 +6,5 @@ A simple digital clock showing seconds as a horizontal bar.
| ![24-hour bar clock](screenshot.png) | ![12-hour bar clock with meridian](screenshot_pm.png) | | ![24-hour bar clock](screenshot.png) | ![12-hour bar clock with meridian](screenshot_pm.png) |
## Settings ## Settings
* `Show date`: display date at the bottom of screen * `Show date`: display date at the bottom of screen
* `Font`: choose between bitmap or vector fonts

View File

@ -58,7 +58,7 @@ const ClockFace = require("ClockFace"),
type: "v", c: [ type: "v", c: [
{ {
type: "h", c: [ type: "h", c: [
{id: "time", label: "88:88", type: "txt", font: "6x8:5", col:g.theme.fg, bgCol: g.theme.bg}, // size updated below {id: "time", label: "88:88", type: "txt", font: "6x8:5", col:g.theme.fg, bgCol: g.theme.bg}, // updated below
{id: "ampm", label: " ", type: "txt", font: "6x8:2", col:g.theme.fg, bgCol: g.theme.bg}, {id: "ampm", label: " ", type: "txt", font: "6x8:2", col:g.theme.fg, bgCol: g.theme.bg},
], ],
}, },
@ -69,7 +69,7 @@ const ClockFace = require("ClockFace"),
}, {lazy: true}); }, {lazy: true});
// adjustments based on screen size and whether we display am/pm // adjustments based on screen size and whether we display am/pm
let thickness; // bar thickness, same as time font "pixel block" size let thickness; // bar thickness, same as time font "pixel block" size
if (this.is12Hour) { if (this.is12Hour && locale.hasMeridian) {
// Maximum font size = (<screen width> - <ampm: 2chars * (2*6)px>) / (5chars * 6px) // Maximum font size = (<screen width> - <ampm: 2chars * (2*6)px>) / (5chars * 6px)
thickness = Math.floor((Bangle.appRect.w-24)/(5*6)); thickness = Math.floor((Bangle.appRect.w-24)/(5*6));
} else { } else {
@ -77,7 +77,16 @@ const ClockFace = require("ClockFace"),
thickness = Math.floor(Bangle.appRect.w/(5*6)); thickness = Math.floor(Bangle.appRect.w/(5*6));
} }
this.layout.bar.height = thickness+1; this.layout.bar.height = thickness+1;
this.layout.time.font = "6x8:"+thickness; if (this.font===1) { // vector
if (this.is12Hour && locale.hasMeridian) {
this.layout.time.font = "Vector:60";
this.layout.ampm.font = "Vector:40";
} else {
this.layout.time.font = "Vector:80";
}
} else {
this.layout.time.font = "6x8:"+thickness;
}
this.layout.update(); this.layout.update();
}, },
update: function(date, c) { update: function(date, c) {

View File

@ -1,7 +1,7 @@
{ {
"id": "barclock", "id": "barclock",
"name": "Bar Clock", "name": "Bar Clock",
"version": "0.12", "version": "0.13",
"description": "A simple digital clock showing seconds as a bar", "description": "A simple digital clock showing seconds as a bar",
"icon": "clock-bar.png", "icon": "clock-bar.png",
"screenshots": [{"url":"screenshot.png"},{"url":"screenshot_pm.png"}], "screenshots": [{"url":"screenshot.png"},{"url":"screenshot_pm.png"}],

View File

@ -8,12 +8,19 @@
} }
} }
const fonts = [/*LANG*/"Bitmap",/*LANG*/"Vector"];
const menu = { const menu = {
"": {"title": /*LANG*/"Bar Clock"}, "": {"title": /*LANG*/"Bar Clock"},
/*LANG*/"< Back": back, /*LANG*/"< Back": back,
/*LANG*/"Show date": require("ClockFace_menu").showDate(s.showDate, saver('showDate')), /*LANG*/"Show date": require("ClockFace_menu").showDate(s.showDate, saver('showDate')),
/*LANG*/"Load widgets": require("ClockFace_menu").loadWidgets(s.loadWidgets, saver('loadWidgets')), /*LANG*/"Load widgets": require("ClockFace_menu").loadWidgets(s.loadWidgets, saver('loadWidgets')),
} /*LANG*/"Font": {
value: s.font|0,
min:0,max:1,wrap:true,
format:v=>fonts[v],
onchange:saver('font'),
},
};
E.showMenu(menu); E.showMenu(menu);
}); });