sleepphasealarm 0.14

Reduce update interval of current time when seconds are not shown
pull/2563/head
Erik Andresen 2023-02-03 18:03:44 +01:00
parent d9dfb3adee
commit 1174faafbf
3 changed files with 22 additions and 7 deletions

View File

@ -14,3 +14,4 @@
0.11: Minor tweaks 0.11: Minor tweaks
0.12: Support javascript command to execute as defined in scheduler 'js' configuration 0.12: Support javascript command to execute as defined in scheduler 'js' configuration
0.13: Fix dated events alarm on wrong date 0.13: Fix dated events alarm on wrong date
0.14: Reduce update interval of current time when seconds are not shown

View File

@ -14,6 +14,7 @@ const active = alarms.filter(alarm => require("sched").getTimeToAlarm(alarm));
const schedSettings = require("sched").getSettings(); const schedSettings = require("sched").getSettings();
let buzzCount = schedSettings.buzzCount; let buzzCount = schedSettings.buzzCount;
let logs = []; let logs = [];
let drawTimeTimeout;
// Sleep/Wake detection with Estimation of Stationary Sleep-segments (ESS): // Sleep/Wake detection with Estimation of Stationary Sleep-segments (ESS):
// Marko Borazio, Eugen Berlin, Nagihan Kücükyildiz, Philipp M. Scholl and Kristof Van Laerhoven, "Towards a Benchmark for Wearable Sleep Analysis with Inertial Wrist-worn Sensing Units", ICHI 2014, Verona, Italy, IEEE Press, 2014. // Marko Borazio, Eugen Berlin, Nagihan Kücükyildiz, Philipp M. Scholl and Kristof Van Laerhoven, "Towards a Benchmark for Wearable Sleep Analysis with Inertial Wrist-worn Sensing Units", ICHI 2014, Verona, Italy, IEEE Press, 2014.
@ -26,7 +27,7 @@ const nomothresh=0.023; // Original implementation: 6, resolution 11 bit, scale
const sleepthresh=600; const sleepthresh=600;
var ess_values = []; var ess_values = [];
var slsnds = 0; var slsnds = 0;
function calc_ess(acc_magn) { function calc_ess(acc_magn) {"ram"
ess_values.push(acc_magn); ess_values.push(acc_magn);
if (ess_values.length == winwidth) { if (ess_values.length == winwidth) {
@ -90,10 +91,12 @@ function drawApp() {
layout.alarm_date.label = `${LABEL_WAKEUP_TIME}: ${alarmHour}:${alarmMinute}`; layout.alarm_date.label = `${LABEL_WAKEUP_TIME}: ${alarmHour}:${alarmMinute}`;
layout.render(); layout.render();
function drawTime() { function drawTime() {"ram"
const drawSeconds = !Bangle.isLocked();
if (Bangle.isLCDOn()) { if (Bangle.isLCDOn()) {
const now = new Date(); const now = new Date();
layout.date.label = locale.time(now, BANGLEJS2 && Bangle.isLocked() ? 1 : 0); // hide seconds on bangle 2 layout.date.label = locale.time(now, !drawSeconds); // hide seconds on bangle 2
const diff = nextAlarmDate - now; const diff = nextAlarmDate - now;
const diffHour = Math.floor((diff % 86400000) / 3600000).toString(); const diffHour = Math.floor((diff % 86400000) / 3600000).toString();
const diffMinutes = Math.floor(((diff % 86400000) % 3600000) / 60000).toString(); const diffMinutes = Math.floor(((diff % 86400000) % 3600000) / 60000).toString();
@ -101,11 +104,22 @@ function drawApp() {
layout.render(); layout.render();
} }
setTimeout(()=>{ const period = drawSeconds ? 1000 : 60000;
if (this.drawTimeTimeout !== undefined) {
clearTimeout(this.drawTimeTimeout);
}
drawTimeTimeout = setTimeout(()=>{
drawTimeTimeout = undefined;
drawTime(); drawTime();
}, 1000 - (Date.now() % 1000)); }, period - (Date.now() % period));
} }
Bangle.on('lock', function(on) {
if (on === false) {
drawTime();
}
});
drawTime(); drawTime();
} }
@ -146,7 +160,7 @@ if (nextAlarmDate !== undefined) {
layout.render(); layout.render();
Bangle.setOptions({powerSave: false}); // do not dynamically change accelerometer poll interval Bangle.setOptions({powerSave: false}); // do not dynamically change accelerometer poll interval
Bangle.setPollInterval(80); // 12.5Hz Bangle.setPollInterval(80); // 12.5Hz
Bangle.on('accel', (accelData) => { Bangle.on('accel', (accelData) => {"ram"
const now = new Date(); const now = new Date();
const acc = accelData.mag; const acc = accelData.mag;
const swest = calc_ess(acc); const swest = calc_ess(acc);

View File

@ -2,7 +2,7 @@
"id": "sleepphasealarm", "id": "sleepphasealarm",
"name": "SleepPhaseAlarm", "name": "SleepPhaseAlarm",
"shortName": "SleepPhaseAlarm", "shortName": "SleepPhaseAlarm",
"version": "0.13", "version": "0.14",
"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.", "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", "icon": "app.png",
"tags": "alarm", "tags": "alarm",