widalarmeta: reload widget when alarms change

master
Rob Pilling 2024-03-03 19:30:18 +00:00
parent 0dd67533ac
commit f9d6ca1c13
3 changed files with 8 additions and 2 deletions

View File

@ -12,3 +12,4 @@
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
0.11: Bugfix: handle changes in alarms (e.g. done without a load, such as via fastload)

View File

@ -2,7 +2,7 @@
"id": "widalarmeta",
"name": "Alarm & Timer ETA",
"shortName": "Alarm ETA",
"version": "0.10",
"version": "0.11",
"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",

View File

@ -21,6 +21,7 @@
function getNextAlarm(date) {
const alarms = require("sched")
.getAlarms()
// more precise filtering is done using getTimeToAlarm() below
.filter(alarm => alarm.on && alarm.hidden !== true);
WIDGETS["widalarmeta"].numActiveAlarms = alarms.length;
@ -123,11 +124,15 @@
area:"tl",
width: 0, // hide by default = assume no timer
draw:draw,
reload: () => {
reload: function () {
this.nextAlarm = undefined;
loadSettings();
g.clear();
Bangle.drawWidgets();
},
};
Bangle.on("alarmReload", () => WIDGETS["widalarmeta"].reload());
}
})();