widalarmeta: font 4x5 -> 6x8:1x2

- Change 4x5 font to 6x8
- teletext is now default font
- reload widget on settings change
master
Erik Andresen 2023-05-04 22:22:44 +02:00
parent dea770cb91
commit fe6247cc79
4 changed files with 25 additions and 13 deletions

View File

@ -11,3 +11,4 @@
0.07: Fix when no alarms are present 0.07: Fix when no alarms are present
0.08: Selectable font. Allow to disable hour padding. 0.08: Selectable font. Allow to disable hour padding.
0.09: Match draw() API e.g. to allow wid_edit to alter this widget 0.09: Match draw() API e.g. to allow wid_edit to alter this widget
0.10: Change 4x5 font to 6x8, teletext is now default font

View File

@ -2,7 +2,7 @@
"id": "widalarmeta", "id": "widalarmeta",
"name": "Alarm & Timer ETA", "name": "Alarm & Timer ETA",
"shortName": "Alarm ETA", "shortName": "Alarm ETA",
"version": "0.09", "version": "0.10",
"description": "A widget that displays the time to the next Alarm or Timer in hours and minutes, maximum 24h (configurable).", "description": "A widget that displays the time to the next Alarm or Timer in hours and minutes, maximum 24h (configurable).",
"icon": "widget.png", "icon": "widget.png",
"type": "widget", "type": "widget",

View File

@ -6,11 +6,12 @@
drawBell: false, drawBell: false,
padHours: true, padHours: true,
showSeconds: 0, // 0=never, 1=only when display is unlocked, 2=for less than a minute showSeconds: 0, // 0=never, 1=only when display is unlocked, 2=for less than a minute
font: 0, // 0=segment style font, 1=teletest font, 2=4x5 font: 1, // 0=segment style font, 1=teletext font, 2=6x8:1x2
}, require("Storage").readJSON(CONFIGFILE,1) || {}); }, require("Storage").readJSON(CONFIGFILE,1) || {});
function writeSettings() { function writeSettings() {
require('Storage').writeJSON(CONFIGFILE, settings); require('Storage').writeJSON(CONFIGFILE, settings);
WIDGETS["widalarmeta"].reload();
} }
// Show the menu // Show the menu
@ -52,7 +53,7 @@
/*LANG*/'Font': { /*LANG*/'Font': {
value: settings.font, value: settings.font,
min: 0, max: 2, min: 0, max: 2,
format: v => [/*LANG*/"Segment", /*LANG*/"Teletext", /*LANG*/"4x5"][v || 0], format: v => [/*LANG*/"Segment", /*LANG*/"Teletext", /*LANG*/"6x8"][v || 0],
onchange: v => { onchange: v => {
settings.font = v; settings.font = v;
writeSettings(); writeSettings();

View File

@ -1,14 +1,19 @@
(() => { (() => {
require("Font5x9Numeric7Seg").add(Graphics); require("Font5x9Numeric7Seg").add(Graphics);
require("FontTeletext5x9Ascii").add(Graphics); require("FontTeletext5x9Ascii").add(Graphics);
require("Font4x5").add(Graphics);
const config = Object.assign({ let config;
function loadSettings() {
config = Object.assign({
maxhours: 24, maxhours: 24,
drawBell: false, drawBell: false,
padHours: true, padHours: true,
showSeconds: 0, // 0=never, 1=only when display is unlocked, 2=for less than a minute showSeconds: 0, // 0=never, 1=only when display is unlocked, 2=for less than a minute
font: 0, // 0=segment style font, 1=teletest font, 2=4x5 font: 1, // 0=segment style font, 1=teletext font, 2=6x8:1x2
}, require("Storage").readJSON("widalarmeta.json",1) || {}); }, require("Storage").readJSON("widalarmeta.json",1) || {});
}
loadSettings();
function getNextAlarm(date) { function getNextAlarm(date) {
const alarms = (require("Storage").readJSON("sched.json",1) || []).filter(alarm => alarm.on && alarm.hidden !== true); const alarms = (require("Storage").readJSON("sched.json",1) || []).filter(alarm => alarm.on && alarm.hidden !== true);
@ -66,7 +71,7 @@
if (config.font == 1) { if (config.font == 1) {
g.setFont("Teletext5x9Ascii:1x2"); g.setFont("Teletext5x9Ascii:1x2");
} else if (config.font == 2) { } else if (config.font == 2) {
g.setFont("4x5"); g.setFont("6x8:1x2");
} else { } else {
// Default to this if no other font is set. // Default to this if no other font is set.
g.setFont("5x9Numeric7Seg:1x2"); g.setFont("5x9Numeric7Seg:1x2");
@ -112,7 +117,12 @@
WIDGETS["widalarmeta"]={ WIDGETS["widalarmeta"]={
area:"tl", area:"tl",
width: 0, // hide by default = assume no timer width: 0, // hide by default = assume no timer
draw:draw draw:draw,
reload: () => {
loadSettings();
g.clear();
Bangle.drawWidgets();
},
}; };
} }
})(); })();