diff --git a/apps/widalarmeta/ChangeLog b/apps/widalarmeta/ChangeLog index 37b619f7f..19a19c006 100644 --- a/apps/widalarmeta/ChangeLog +++ b/apps/widalarmeta/ChangeLog @@ -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 diff --git a/apps/widalarmeta/metadata.json b/apps/widalarmeta/metadata.json index 79387c1c5..89e35c090 100644 --- a/apps/widalarmeta/metadata.json +++ b/apps/widalarmeta/metadata.json @@ -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", diff --git a/apps/widalarmeta/widget.js b/apps/widalarmeta/widget.js index ff3390d89..8a7933358 100644 --- a/apps/widalarmeta/widget.js +++ b/apps/widalarmeta/widget.js @@ -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 */