Merge pull request #2319 from nxdefiant/master

taglaunch: Backport PR 2316 for launch
master
Gordon Williams 2022-11-30 09:18:22 +00:00 committed by GitHub
commit f55db143be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 38 additions and 27 deletions

View File

@ -18,6 +18,11 @@
var notesElement = document.getElementById("notes"); var notesElement = document.getElementById("notes");
var notes = {}; var notes = {};
function disableFormInput() {
document.querySelectorAll(".form-input").forEach(el => el.disabled = true);
document.querySelectorAll(".btn").forEach(el => el.disabled = true);
}
function getData() { function getData() {
// show loading window // show loading window
Util.showModal("Loading..."); Util.showModal("Loading...");
@ -53,8 +58,10 @@ function getData() {
buttonSave.classList.add('btn-default'); buttonSave.classList.add('btn-default');
buttonSave.onclick = function() { buttonSave.onclick = function() {
notes[i].note = textarea.value; notes[i].note = textarea.value;
Util.writeStorage("noteify.json", JSON.stringify(notes)); disableFormInput();
location.reload(); Util.writeStorage("noteify.json", JSON.stringify(notes), () => {
location.reload(); // reload so we see current data
});
} }
divColumn2.appendChild(buttonSave); divColumn2.appendChild(buttonSave);
@ -64,8 +71,10 @@ function getData() {
buttonDelete.onclick = function() { buttonDelete.onclick = function() {
notes[i].note = textarea.value; notes[i].note = textarea.value;
notes.splice(i, 1); notes.splice(i, 1);
Util.writeStorage("noteify.json", JSON.stringify(notes)); disableFormInput();
location.reload(); // reload so we see current data Util.writeStorage("noteify.json", JSON.stringify(notes), () => {
location.reload(); // reload so we see current data
});
} }
divColumn2.appendChild(buttonDelete); divColumn2.appendChild(buttonDelete);
divColumn.appendChild(divColumn2); divColumn.appendChild(divColumn2);
@ -77,8 +86,10 @@ function getData() {
document.getElementById("btnAdd").addEventListener("click", function() { document.getElementById("btnAdd").addEventListener("click", function() {
const note = document.getElementById("note-new").value; const note = document.getElementById("note-new").value;
notes.push({"note": note}); notes.push({"note": note});
Util.writeStorage("noteify.json", JSON.stringify(notes)); disableFormInput();
location.reload(); // reload so we see current data Util.writeStorage("noteify.json", JSON.stringify(notes), () => {
location.reload(); // reload so we see current data
});
}); });
}); });
} }

View File

@ -11,3 +11,4 @@
Add setting to defer start of algorithm Add setting to defer start of algorithm
Add setting to disable scheduler alarm Add setting to disable scheduler alarm
0.10: Fix: Do not wake when falling asleep 0.10: Fix: Do not wake when falling asleep
0.11: Minor tweaks

View File

@ -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) // 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 // start of sleep marker is delayed by sleepthresh due to continous data reading
const winwidth=13; const winwidth=13; // Actually 12.5 Hz, rounded
const nomothresh=0.03; // 0.006 was working on Bangle1, but Bangle2 has higher noise. const nomothresh=0.023; // Original implementation: 6, resolution 11 bit, scale +-4G = 6/(2^(11-1))*4 = 0.023438 in G
const sleepthresh=600; const sleepthresh=600;
var ess_values = []; var ess_values = [];
var slsnds = 0; 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({ var layout = new Layout({
type:"v", c: [ type:"v", c: [
{type:"txt", font:"10%", label:"Sleep Phase Alarm", bgCol:g.theme.bgH, fillx: true, height:Bangle.appRect.h/6}, {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(); var alarmMinute = nextAlarmDate.getMinutes();
if (alarmHour < 10) alarmHour = "0" + alarmHour; if (alarmHour < 10) alarmHour = "0" + alarmHour;
if (alarmMinute < 10) alarmMinute = "0" + alarmMinute; 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(); layout.render();
function drawTime() { function drawTime() {
@ -94,7 +97,7 @@ function drawApp() {
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();
layout.eta.label = "ETA: -"+ diffHour + ":" + diffMinutes.padStart(2, '0'); layout.eta.label = `${LABEL_ETA}: ${diffHour}:${diffMinutes.padStart(2, '0')}`;
layout.render(); layout.render();
} }
@ -139,7 +142,7 @@ if (nextAlarmDate !== undefined) {
// minimum alert 30 minutes early // minimum alert 30 minutes early
minAlarm.setTime(nextAlarmDate.getTime() - (30*60*1000)); minAlarm.setTime(nextAlarmDate.getTime() - (30*60*1000));
run = () => { run = () => {
layout.state.label = "Start"; layout.state.label = /*LANG*/"Start";
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
@ -150,7 +153,7 @@ if (nextAlarmDate !== undefined) {
if (swest !== undefined) { if (swest !== undefined) {
if (Bangle.isLCDOn()) { if (Bangle.isLCDOn()) {
layout.state.label = swest ? "Sleep" : "Awake"; layout.state.label = swest ? /*LANG*/"Sleep" : /*LANG*/"Awake";
layout.render(); layout.render();
} }
// log // log

View File

@ -2,7 +2,7 @@
"id": "sleepphasealarm", "id": "sleepphasealarm",
"name": "SleepPhaseAlarm", "name": "SleepPhaseAlarm",
"shortName": "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.", "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",

View File

@ -1 +1,2 @@
0.01: New App! 0.01: New App!
0.02: Use Bangle.showClock for changing to clock (Backport from launch)

View File

@ -69,16 +69,6 @@ let tagKeys = Object.keys(tags).filter(tag => tag !== "clock" || settings.showCl
if (!settings.fullscreen) if (!settings.fullscreen)
Bangle.loadWidgets(); Bangle.loadWidgets();
let returnToClock = function() {
// unload everything manually
// ... or we could just call `load();` but it will be slower
Bangle.setUI(); // remove scroller's handling
if (lockTimeout) clearTimeout(lockTimeout);
Bangle.removeListener("lock", lockHandler);
// now load the default clock - just call .bootcde as this has the code already
setTimeout(eval,0,s.read(".bootcde"));
};
let showTagMenu = (tag) => { let showTagMenu = (tag) => {
E.showScroller({ E.showScroller({
h : 64*scaleval, c : appsByTag[tag].length, h : 64*scaleval, c : appsByTag[tag].length,
@ -121,7 +111,12 @@ let showMainMenu = () => {
let tag = tagKeys[i]; let tag = tagKeys[i];
showTagMenu(tag); showTagMenu(tag);
}, },
back : returnToClock // button press or tap in top left calls returnToClock now back : Bangle.showClock, // button press or tap in top left shows clock now
remove : () => {
// cleanup the timeout to not leave anything behind after being removed from ram
if (lockTimeout) clearTimeout(lockTimeout);
Bangle.removeListener("lock", lockHandler);
}
}); });
}; };
showMainMenu(); showMainMenu();
@ -134,7 +129,7 @@ let lockHandler = function(locked) {
if (lockTimeout) clearTimeout(lockTimeout); if (lockTimeout) clearTimeout(lockTimeout);
lockTimeout = undefined; lockTimeout = undefined;
if (locked) { if (locked) {
lockTimeout = setTimeout(returnToClock, 10000); lockTimeout = setTimeout(Bangle.showClock, 10000);
} }
}; };
Bangle.on("lock", lockHandler); Bangle.on("lock", lockHandler);

View File

@ -2,7 +2,7 @@
"id": "taglaunch", "id": "taglaunch",
"name": "Tag Launcher", "name": "Tag Launcher",
"shortName": "Taglauncher", "shortName": "Taglauncher",
"version": "0.01", "version": "0.02",
"description": "Launcher that puts all applications into submenus based on their tag. With many applications installed this can result in a faster application selection than the linear access of the default launcher.", "description": "Launcher that puts all applications into submenus based on their tag. With many applications installed this can result in a faster application selection than the linear access of the default launcher.",
"readme": "README.md", "readme": "README.md",
"icon": "app.png", "icon": "app.png",

View File

@ -5,7 +5,7 @@
"description": "Tetris", "description": "Tetris",
"icon": "tetris.png", "icon": "tetris.png",
"readme": "README.md", "readme": "README.md",
"tags": "games", "tags": "game",
"supports" : ["BANGLEJS2"], "supports" : ["BANGLEJS2"],
"storage": [ "storage": [
{"name":"tetris.app.js","url":"tetris.app.js"}, {"name":"tetris.app.js","url":"tetris.app.js"},