Merge pull request #2533 from nxdefiant/master

widalarmeta & sleepphasealarm fixes
master
Gordon Williams 2023-01-30 09:27:24 +00:00 committed by GitHub
commit 3076a8d364
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 15 additions and 8 deletions

View File

@ -13,3 +13,4 @@
0.10: Fix: Do not wake when falling asleep
0.11: Minor tweaks
0.12: Support javascript command to execute as defined in scheduler 'js' configuration
0.13: Fix dated events alarm on wrong date

View File

@ -10,7 +10,7 @@ const config = Object.assign({
disableAlarm: false,
}
}, require("Storage").readJSON(CONFIGFILE,1) || {});
const active = alarms.filter(a=>a.on);
const active = alarms.filter(alarm => require("sched").getTimeToAlarm(alarm));
const schedSettings = require("sched").getSettings();
let buzzCount = schedSettings.buzzCount;
let logs = [];

View File

@ -2,7 +2,7 @@
"id": "sleepphasealarm",
"name": "SleepPhaseAlarm",
"shortName": "SleepPhaseAlarm",
"version": "0.12",
"version": "0.13",
"description": "Uses the accelerometer to estimate sleep and wake states with the principle of Estimation of Stationary Sleep-segments (ESS, see https://ubicomp.eti.uni-siegen.de/home/datasets/ichi14/index.html.en). This app will read the next alarm from the alarm application and will wake you up to 30 minutes early at the best guessed time when you are almost already awake.",
"icon": "app.png",
"tags": "alarm",
@ -14,6 +14,6 @@
{"name":"sleepphasealarm.settings.js","url":"settings.js"},
{"name":"sleepphasealarm.img","url":"app-icon.js","evaluate":true}
],
"data": [{"name":"sleepphasealarm.json","storageFile":true}],
"data": [{"name":"sleepphasealarm.json"}],
"interface": "interface.html"
}

View File

@ -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

View File

@ -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",

View File

@ -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 */