commit
a5cb8e6970
|
|
@ -1,2 +1,3 @@
|
||||||
0.01: New App!
|
0.01: New App!
|
||||||
0.02: Set Bangle.js 2 compatible
|
0.02: Set Bangle.js 2 compatible
|
||||||
|
0.03: Add setting to hide the widget
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,15 @@
|
||||||
"id": "gpsautotime",
|
"id": "gpsautotime",
|
||||||
"name": "GPS auto time",
|
"name": "GPS auto time",
|
||||||
"shortName": "GPS auto time",
|
"shortName": "GPS auto time",
|
||||||
"version": "0.02",
|
"version": "0.03",
|
||||||
"description": "A widget that automatically updates the Bangle.js time to the GPS time whenever there is a valid GPS fix.",
|
"description": "A widget that automatically updates the Bangle.js time to the GPS time whenever there is a valid GPS fix.",
|
||||||
"icon": "widget.png",
|
"icon": "widget.png",
|
||||||
"type": "widget",
|
"type": "widget",
|
||||||
"tags": "widget,gps",
|
"tags": "widget,gps",
|
||||||
"supports": ["BANGLEJS","BANGLEJS2"],
|
"supports": ["BANGLEJS","BANGLEJS2"],
|
||||||
"storage": [
|
"storage": [
|
||||||
{"name":"gpsautotime.wid.js","url":"widget.js"}
|
{"name":"gpsautotime.wid.js","url":"widget.js"},
|
||||||
]
|
{"name":"gpsautotime.settings.js","url":"settings.js"}
|
||||||
|
],
|
||||||
|
"data": [{"name":"gpsautotime.json"}]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
(function(back) {
|
||||||
|
var FILE = "gpsautotime.json";
|
||||||
|
// Load settings
|
||||||
|
var settings = Object.assign({
|
||||||
|
show: true,
|
||||||
|
}, require('Storage').readJSON(FILE, true) || {});
|
||||||
|
|
||||||
|
function writeSettings() {
|
||||||
|
require('Storage').writeJSON(FILE, settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show the menu
|
||||||
|
E.showMenu({
|
||||||
|
"" : { "title" : "GPS auto time" },
|
||||||
|
"< Back" : () => back(),
|
||||||
|
'Show widget?': {
|
||||||
|
value: !!settings.show, // !! converts undefined to false
|
||||||
|
format: v => v?"Show":"Hide",
|
||||||
|
onchange: v => {
|
||||||
|
settings.show = v;
|
||||||
|
writeSettings();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
@ -1,6 +1,13 @@
|
||||||
(() => {
|
(() => {
|
||||||
var lastTimeSet = 0;
|
var lastTimeSet = 0;
|
||||||
|
|
||||||
|
var settings = Object.assign({
|
||||||
|
// default values
|
||||||
|
show: true,
|
||||||
|
}, require('Storage').readJSON("gpsautotime.json", true) || {});
|
||||||
|
const show = settings.show;
|
||||||
|
delete settings;
|
||||||
|
|
||||||
Bangle.on('GPS',function(fix) {
|
Bangle.on('GPS',function(fix) {
|
||||||
if (fix.fix) {
|
if (fix.fix) {
|
||||||
var curTime = fix.time.getTime()/1000;
|
var curTime = fix.time.getTime()/1000;
|
||||||
|
|
@ -14,8 +21,9 @@
|
||||||
// add your widget
|
// add your widget
|
||||||
WIDGETS["gpsAutoTime"]={
|
WIDGETS["gpsAutoTime"]={
|
||||||
area:"tl", // tl (top left), tr (top right), bl (bottom left), br (bottom right)
|
area:"tl", // tl (top left), tr (top right), bl (bottom left), br (bottom right)
|
||||||
width: 28, // width of the widget
|
width: show ? 4*6+2 : 0, // width of the widget
|
||||||
draw: function() {
|
draw: function() {
|
||||||
|
if (!show) return;
|
||||||
g.reset(); // reset the graphics context to defaults (color/font/etc)
|
g.reset(); // reset the graphics context to defaults (color/font/etc)
|
||||||
g.setFont("6x8");
|
g.setFont("6x8");
|
||||||
if ((getTime() - lastTimeSet) <= 60) {
|
if ((getTime() - lastTimeSet) <= 60) {
|
||||||
|
|
@ -27,7 +35,9 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (show) {
|
||||||
setInterval(function() {
|
setInterval(function() {
|
||||||
WIDGETS["gpsAutoTime"].draw(WIDGETS["gpsAutoTime"]);
|
WIDGETS["gpsAutoTime"].draw(WIDGETS["gpsAutoTime"]);
|
||||||
}, 1*60000); // update every minute
|
}, 1*60000); // update every minute
|
||||||
})()
|
}
|
||||||
|
})();
|
||||||
|
|
|
||||||
|
|
@ -5,3 +5,4 @@
|
||||||
0.05: Refactor decodeTime() to scheduling library
|
0.05: Refactor decodeTime() to scheduling library
|
||||||
0.06: Add logging
|
0.06: Add logging
|
||||||
use Layout library and display ETA
|
use Layout library and display ETA
|
||||||
|
0.07: Add check for day of week
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
# Sleep Phase Alarm
|
# Sleep Phase Alarm
|
||||||
|
|
||||||
|
The alarm must be in the next 24h.
|
||||||
|
|
||||||
The display shows:
|
The display shows:
|
||||||
|
|
||||||
- the current time
|
- the current time
|
||||||
|
|
|
||||||
|
|
@ -51,9 +51,11 @@ active.forEach(alarm => {
|
||||||
if (dateAlarm < now) { // dateAlarm in the past, add 24h
|
if (dateAlarm < now) { // dateAlarm in the past, add 24h
|
||||||
dateAlarm.setTime(dateAlarm.getTime() + (24*60*60*1000));
|
dateAlarm.setTime(dateAlarm.getTime() + (24*60*60*1000));
|
||||||
}
|
}
|
||||||
|
if ((alarm.dow >> dateAlarm.getDay()) & 1) { // check valid day of week
|
||||||
if (nextAlarm === undefined || dateAlarm < nextAlarm) {
|
if (nextAlarm === undefined || dateAlarm < nextAlarm) {
|
||||||
nextAlarm = dateAlarm;
|
nextAlarm = dateAlarm;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var layout = new Layout({
|
var layout = new Layout({
|
||||||
|
|
@ -80,7 +82,7 @@ function drawApp() {
|
||||||
layout.date.label = locale.time(now, BANGLEJS2 && Bangle.isLocked() ? 1 : 0); // hide seconds on bangle 2
|
layout.date.label = locale.time(now, BANGLEJS2 && Bangle.isLocked() ? 1 : 0); // hide seconds on bangle 2
|
||||||
const diff = nextAlarm - now;
|
const diff = nextAlarm - now;
|
||||||
const diffHour = Math.floor((diff % 86400000) / 3600000).toString();
|
const diffHour = Math.floor((diff % 86400000) / 3600000).toString();
|
||||||
const diffMinutes = Math.round(((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 = "ETA: -"+ diffHour + ":" + diffMinutes.padStart(2, '0');
|
||||||
layout.render();
|
layout.render();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
"id": "sleepphasealarm",
|
"id": "sleepphasealarm",
|
||||||
"name": "SleepPhaseAlarm",
|
"name": "SleepPhaseAlarm",
|
||||||
"shortName": "SleepPhaseAlarm",
|
"shortName": "SleepPhaseAlarm",
|
||||||
"version": "0.06",
|
"version": "0.07",
|
||||||
"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",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue