sleepphasealarm: Minor tweaks
parent
5eda7ae889
commit
bfbd86bc33
|
|
@ -11,3 +11,4 @@
|
|||
Add setting to defer start of algorithm
|
||||
Add setting to disable scheduler alarm
|
||||
0.10: Fix: Do not wake when falling asleep
|
||||
0.11: Minor tweaks
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@ let logs = [];
|
|||
//
|
||||
// Function needs to be called for every measurement but returns a value at maximum once a second (see winwidth)
|
||||
// start of sleep marker is delayed by sleepthresh due to continous data reading
|
||||
const winwidth=13;
|
||||
const nomothresh=0.03; // 0.006 was working on Bangle1, but Bangle2 has higher noise.
|
||||
const winwidth=13; // Actually 12.5 Hz, rounded
|
||||
const nomothresh=0.023; // Original implementation: 6, resolution 11 bit, scale +-4G = 6/(2^(11-1))*4 = 0.023438 in G
|
||||
const sleepthresh=600;
|
||||
var ess_values = [];
|
||||
var slsnds = 0;
|
||||
|
|
@ -69,6 +69,9 @@ active.forEach(alarm => {
|
|||
}
|
||||
});
|
||||
|
||||
const LABEL_ETA = /*LANG*/"ETA";
|
||||
const LABEL_WAKEUP_TIME = /*LANG*/"Alarm at";
|
||||
|
||||
var layout = new Layout({
|
||||
type:"v", c: [
|
||||
{type:"txt", font:"10%", label:"Sleep Phase Alarm", bgCol:g.theme.bgH, fillx: true, height:Bangle.appRect.h/6},
|
||||
|
|
@ -84,7 +87,7 @@ function drawApp() {
|
|||
var alarmMinute = nextAlarmDate.getMinutes();
|
||||
if (alarmHour < 10) alarmHour = "0" + alarmHour;
|
||||
if (alarmMinute < 10) alarmMinute = "0" + alarmMinute;
|
||||
layout.alarm_date.label = "Alarm at " + alarmHour + ":" + alarmMinute;
|
||||
layout.alarm_date.label = `${LABEL_WAKEUP_TIME}: ${alarmHour}:${alarmMinute}`;
|
||||
layout.render();
|
||||
|
||||
function drawTime() {
|
||||
|
|
@ -94,7 +97,7 @@ function drawApp() {
|
|||
const diff = nextAlarmDate - now;
|
||||
const diffHour = Math.floor((diff % 86400000) / 3600000).toString();
|
||||
const diffMinutes = Math.floor(((diff % 86400000) % 3600000) / 60000).toString();
|
||||
layout.eta.label = "ETA: -"+ diffHour + ":" + diffMinutes.padStart(2, '0');
|
||||
layout.eta.label = `${LABEL_ETA}: ${diffHour}:${diffMinutes.padStart(2, '0')}`;
|
||||
layout.render();
|
||||
}
|
||||
|
||||
|
|
@ -139,7 +142,7 @@ if (nextAlarmDate !== undefined) {
|
|||
// minimum alert 30 minutes early
|
||||
minAlarm.setTime(nextAlarmDate.getTime() - (30*60*1000));
|
||||
run = () => {
|
||||
layout.state.label = "Start";
|
||||
layout.state.label = /*LANG*/"Start";
|
||||
layout.render();
|
||||
Bangle.setOptions({powerSave: false}); // do not dynamically change accelerometer poll interval
|
||||
Bangle.setPollInterval(80); // 12.5Hz
|
||||
|
|
@ -150,7 +153,7 @@ if (nextAlarmDate !== undefined) {
|
|||
|
||||
if (swest !== undefined) {
|
||||
if (Bangle.isLCDOn()) {
|
||||
layout.state.label = swest ? "Sleep" : "Awake";
|
||||
layout.state.label = swest ? /*LANG*/"Sleep" : /*LANG*/"Awake";
|
||||
layout.render();
|
||||
}
|
||||
// log
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
"id": "sleepphasealarm",
|
||||
"name": "SleepPhaseAlarm",
|
||||
"shortName": "SleepPhaseAlarm",
|
||||
"version": "0.10",
|
||||
"version": "0.11",
|
||||
"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",
|
||||
|
|
|
|||
Loading…
Reference in New Issue