mirror of https://github.com/espruino/BangleApps
Merge pull request #2319 from nxdefiant/master
taglaunch: Backport PR 2316 for launchpull/2333/head
commit
f55db143be
|
@ -18,6 +18,11 @@
|
|||
var notesElement = document.getElementById("notes");
|
||||
var notes = {};
|
||||
|
||||
function disableFormInput() {
|
||||
document.querySelectorAll(".form-input").forEach(el => el.disabled = true);
|
||||
document.querySelectorAll(".btn").forEach(el => el.disabled = true);
|
||||
}
|
||||
|
||||
function getData() {
|
||||
// show loading window
|
||||
Util.showModal("Loading...");
|
||||
|
@ -53,8 +58,10 @@ function getData() {
|
|||
buttonSave.classList.add('btn-default');
|
||||
buttonSave.onclick = function() {
|
||||
notes[i].note = textarea.value;
|
||||
Util.writeStorage("noteify.json", JSON.stringify(notes));
|
||||
location.reload();
|
||||
disableFormInput();
|
||||
Util.writeStorage("noteify.json", JSON.stringify(notes), () => {
|
||||
location.reload(); // reload so we see current data
|
||||
});
|
||||
}
|
||||
divColumn2.appendChild(buttonSave);
|
||||
|
||||
|
@ -64,8 +71,10 @@ function getData() {
|
|||
buttonDelete.onclick = function() {
|
||||
notes[i].note = textarea.value;
|
||||
notes.splice(i, 1);
|
||||
Util.writeStorage("noteify.json", JSON.stringify(notes));
|
||||
location.reload(); // reload so we see current data
|
||||
disableFormInput();
|
||||
Util.writeStorage("noteify.json", JSON.stringify(notes), () => {
|
||||
location.reload(); // reload so we see current data
|
||||
});
|
||||
}
|
||||
divColumn2.appendChild(buttonDelete);
|
||||
divColumn.appendChild(divColumn2);
|
||||
|
@ -77,8 +86,10 @@ function getData() {
|
|||
document.getElementById("btnAdd").addEventListener("click", function() {
|
||||
const note = document.getElementById("note-new").value;
|
||||
notes.push({"note": note});
|
||||
Util.writeStorage("noteify.json", JSON.stringify(notes));
|
||||
location.reload(); // reload so we see current data
|
||||
disableFormInput();
|
||||
Util.writeStorage("noteify.json", JSON.stringify(notes), () => {
|
||||
location.reload(); // reload so we see current data
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
0.01: New App!
|
||||
0.02: Use Bangle.showClock for changing to clock (Backport from launch)
|
||||
|
|
|
@ -69,16 +69,6 @@ let tagKeys = Object.keys(tags).filter(tag => tag !== "clock" || settings.showCl
|
|||
if (!settings.fullscreen)
|
||||
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) => {
|
||||
E.showScroller({
|
||||
h : 64*scaleval, c : appsByTag[tag].length,
|
||||
|
@ -121,7 +111,12 @@ let showMainMenu = () => {
|
|||
let tag = tagKeys[i];
|
||||
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();
|
||||
|
@ -134,7 +129,7 @@ let lockHandler = function(locked) {
|
|||
if (lockTimeout) clearTimeout(lockTimeout);
|
||||
lockTimeout = undefined;
|
||||
if (locked) {
|
||||
lockTimeout = setTimeout(returnToClock, 10000);
|
||||
lockTimeout = setTimeout(Bangle.showClock, 10000);
|
||||
}
|
||||
};
|
||||
Bangle.on("lock", lockHandler);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"id": "taglaunch",
|
||||
"name": "Tag Launcher",
|
||||
"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.",
|
||||
"readme": "README.md",
|
||||
"icon": "app.png",
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"description": "Tetris",
|
||||
"icon": "tetris.png",
|
||||
"readme": "README.md",
|
||||
"tags": "games",
|
||||
"tags": "game",
|
||||
"supports" : ["BANGLEJS2"],
|
||||
"storage": [
|
||||
{"name":"tetris.app.js","url":"tetris.app.js"},
|
||||
|
|
Loading…
Reference in New Issue