forked from FOSS/BangleApps
commit
79eedba54d
|
@ -11,3 +11,4 @@
|
|||
0.07: Fix when no alarms are present
|
||||
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.10: Change 4x5 font to 6x8, teletext is now default font
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"id": "widalarmeta",
|
||||
"name": "Alarm & Timer 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).",
|
||||
"icon": "widget.png",
|
||||
"type": "widget",
|
||||
|
|
|
@ -6,11 +6,12 @@
|
|||
drawBell: false,
|
||||
padHours: true,
|
||||
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) || {});
|
||||
|
||||
function writeSettings() {
|
||||
require('Storage').writeJSON(CONFIGFILE, settings);
|
||||
WIDGETS["widalarmeta"].reload();
|
||||
}
|
||||
|
||||
// Show the menu
|
||||
|
@ -52,7 +53,7 @@
|
|||
/*LANG*/'Font': {
|
||||
value: settings.font,
|
||||
min: 0, max: 2,
|
||||
format: v => [/*LANG*/"Segment", /*LANG*/"Teletext", /*LANG*/"4x5"][v || 0],
|
||||
format: v => [/*LANG*/"Segment", /*LANG*/"Teletext", /*LANG*/"6x8"][v === undefined ? 1 : v],
|
||||
onchange: v => {
|
||||
settings.font = v;
|
||||
writeSettings();
|
||||
|
|
|
@ -1,14 +1,22 @@
|
|||
(() => {
|
||||
require("Font5x9Numeric7Seg").add(Graphics);
|
||||
require("FontTeletext5x9Ascii").add(Graphics);
|
||||
require("Font4x5").add(Graphics);
|
||||
const config = Object.assign({
|
||||
maxhours: 24,
|
||||
drawBell: false,
|
||||
padHours: true,
|
||||
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
|
||||
}, require("Storage").readJSON("widalarmeta.json",1) || {});
|
||||
let config;
|
||||
|
||||
function loadSettings() {
|
||||
config = Object.assign({
|
||||
maxhours: 24,
|
||||
drawBell: false,
|
||||
padHours: true,
|
||||
showSeconds: 0, // 0=never, 1=only when display is unlocked, 2=for less than a minute
|
||||
font: 1, // 0=segment style font, 1=teletext font, 2=6x8:1x2
|
||||
}, require("Storage").readJSON("widalarmeta.json",1) || {});
|
||||
|
||||
if (config.font == 0) {
|
||||
require("Font5x9Numeric7Seg").add(Graphics);
|
||||
} else if (config.font == 1) {
|
||||
require("FontTeletext5x9Ascii").add(Graphics);
|
||||
}
|
||||
}
|
||||
loadSettings();
|
||||
|
||||
function getNextAlarm(date) {
|
||||
const alarms = (require("Storage").readJSON("sched.json",1) || []).filter(alarm => alarm.on && alarm.hidden !== true);
|
||||
|
@ -63,13 +71,13 @@
|
|||
if (drawSeconds) {
|
||||
text += ":" + seconds.padStart(2, '0');
|
||||
}
|
||||
if (config.font == 1) {
|
||||
if (config.font == 0) {
|
||||
g.setFont("5x9Numeric7Seg:1x2");
|
||||
} else if (config.font == 1) {
|
||||
g.setFont("Teletext5x9Ascii:1x2");
|
||||
} else if (config.font == 2) {
|
||||
g.setFont("4x5");
|
||||
} else {
|
||||
// Default to this if no other font is set.
|
||||
g.setFont("5x9Numeric7Seg:1x2");
|
||||
g.setFont("6x8:1x2");
|
||||
}
|
||||
g.drawString(text, this.x+1, this.y+12);
|
||||
|
||||
|
@ -112,7 +120,12 @@
|
|||
WIDGETS["widalarmeta"]={
|
||||
area:"tl",
|
||||
width: 0, // hide by default = assume no timer
|
||||
draw:draw
|
||||
draw:draw,
|
||||
reload: () => {
|
||||
loadSettings();
|
||||
g.clear();
|
||||
Bangle.drawWidgets();
|
||||
},
|
||||
};
|
||||
}
|
||||
})();
|
||||
|
|
Loading…
Reference in New Issue