[widalarmeta] Add option to only show when on clock

master
Logan B 2025-07-30 20:39:56 -05:00
parent 7675484149
commit ceeac6cbb3
No known key found for this signature in database
4 changed files with 52 additions and 36 deletions

View File

@ -14,3 +14,4 @@
0.10: Change 4x5 font to 6x8, teletext is now default font 0.10: Change 4x5 font to 6x8, teletext is now default font
0.11: Bugfix: handle changes in alarms (e.g. done without a load, such as via fastload) 0.11: Bugfix: handle changes in alarms (e.g. done without a load, such as via fastload)
0.12: Redraw when screen turns on or watch is unlocked 0.12: Redraw when screen turns on or watch is unlocked
0.13: Add option to only show when on clock

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.12", "version": "0.13",
"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

@ -7,6 +7,7 @@
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: 1, // 0=segment style font, 1=teletext font, 2=6x8:1x2 font: 1, // 0=segment style font, 1=teletext font, 2=6x8:1x2
whenToShow: 0, // 0=always, 1=on clock only
}, require("Storage").readJSON(CONFIGFILE,1) || {}); }, require("Storage").readJSON(CONFIGFILE,1) || {});
function writeSettings() { function writeSettings() {
@ -59,5 +60,14 @@
writeSettings(); writeSettings();
} }
}, },
/*LANG*/'When To Show': {
value: settings.whenToShow,
min: 0, max: 1,
format: v => [/*LANG*/"Always", /*LANG*/"On Clock Only"][v === undefined ? 0 : v],
onchange: v => {
settings.whenToShow = v;
writeSettings();
}
},
}); });
}) })

View File

@ -8,6 +8,7 @@
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: 1, // 0=segment style font, 1=teletext font, 2=6x8:1x2 font: 1, // 0=segment style font, 1=teletext font, 2=6x8:1x2
whenToShow: 0, // 0=always, 1=on clock only
}, require("Storage").readJSON("widalarmeta.json",1) || {}); }, require("Storage").readJSON("widalarmeta.json",1) || {});
if (config.font == 0) { if (config.font == 0) {
@ -55,6 +56,9 @@
let calcWidth = 0; let calcWidth = 0;
let drawSeconds = false; let drawSeconds = false;
// If always showing, or the clock is visible
if (config.whenToShow === 0 || Bangle.CLOCK) {
// Determine text and width
if (next > 0 && next <= config.maxhours*60*60*1000) { if (next > 0 && next <= config.maxhours*60*60*1000) {
const hours = Math.floor((next-1) / 3600000).toString(); const hours = Math.floor((next-1) / 3600000).toString();
const minutes = Math.floor(((next-1) % 3600000) / 60000).toString(); const minutes = Math.floor(((next-1) % 3600000) / 60000).toString();
@ -95,6 +99,7 @@
this.bellVisible = true; this.bellVisible = true;
} }
} }
}
if (this.width !== calcWidth) { if (this.width !== calcWidth) {
// width changed, re-layout // width changed, re-layout