widalarmeta fixes
Fix Bell not appearing on alarms > 24h and redrawing intervalmaster
parent
134f258d39
commit
1abb3c84e5
|
|
@ -2,3 +2,4 @@
|
|||
0.02: Change font to 5x9 7 segment-style
|
||||
Add settings page
|
||||
Add option to show seconds
|
||||
0.03: Fix Bell not appearing on alarms > 24h and redrawing interval
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
"id": "widalarmeta",
|
||||
"name": "Alarm & Timer ETA",
|
||||
"shortName": "Alarm ETA",
|
||||
"version": "0.02",
|
||||
"version": "0.03",
|
||||
"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",
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
function draw() {
|
||||
const times = alarms.map(alarm => require("sched").getTimeToAlarm(alarm)).filter(a => a !== undefined);
|
||||
const next = Math.min.apply(null, times);
|
||||
const next = times.length > 0 ? Math.min.apply(null, times) : 0;
|
||||
let calcWidth = 0;
|
||||
let drawSeconds = false;
|
||||
|
||||
|
|
@ -34,7 +34,7 @@
|
|||
if (drawSeconds) {
|
||||
calcWidth += 3*5;
|
||||
}
|
||||
} else if (times.length > 0 && config.drawBell) {
|
||||
} else if (config.drawBell && alarms.some(alarm=>alarm.on&&(alarm.hidden!==true))) {
|
||||
// next alarm too far in future, draw only widalarm bell
|
||||
g.reset().drawImage(atob("GBgBAAAAAAAAABgADhhwDDwwGP8YGf+YMf+MM//MM//MA//AA//AA//AA//AA//AA//AB//gD//wD//wAAAAADwAABgAAAAAAAAA"),this.x,this.y);
|
||||
calcWidth = 24;
|
||||
|
|
@ -52,8 +52,13 @@
|
|||
if (timeout === 0) {
|
||||
timeout += period;
|
||||
}
|
||||
setTimeout(()=>{
|
||||
WIDGETS["widalarmeta"].draw(WIDGETS["widalarmeta"]);
|
||||
|
||||
if (this.timeoutId !== undefined) {
|
||||
clearTimeout(this.timeoutId);
|
||||
}
|
||||
this.timeoutId = setTimeout(()=>{
|
||||
this.timeoutId = undefined;
|
||||
this.draw();
|
||||
}, timeout);
|
||||
} /* draw */
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue