Add option for ISO 8601 date
parent
f0ee2be3db
commit
e8642e7f41
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
A clock displayed as a terminal cli.
|
||||
It can display:
|
||||
|
||||
- time
|
||||
- date
|
||||
- altitude
|
||||
|
|
@ -9,7 +10,6 @@ It can display :
|
|||
- motion
|
||||
- steps
|
||||
|
||||
|
||||
"Power saving" setting control the HR and pressure (altitude) sensors.
|
||||
If "Off" they will always be on.
|
||||
If "On" the sensors will be turned on every "Power on interval" minutes for 45 secondes
|
||||
If "On" the sensors will be turned on every "Power on interval" minutes for 45 seconds
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@
|
|||
curPos++;
|
||||
|
||||
["L2", "L3", "L4", "L5", "L6", "L7", "L8", "L9"].forEach(line => {
|
||||
if (this[line]==='Date') drawDate(date, curPos);
|
||||
if (this[line]==='Date') drawDate(date, this.isoDate, curPos);
|
||||
else if (this[line]==='HR') drawHRM(curPos);
|
||||
else if (this[line]==='Motion') drawMotion(curPos);
|
||||
else if (this[line]==='Alt') drawAltitude(curPos);
|
||||
|
|
@ -101,10 +101,11 @@
|
|||
-------------------------------- */
|
||||
|
||||
let drawLine = function(line, pos) {
|
||||
if(pos == 1)
|
||||
if (pos == 1) {
|
||||
g.setFont("6x8", font6x8FirstTextSize);
|
||||
else
|
||||
} else {
|
||||
g.setFont("6x8", font6x8DefaultTextSize);
|
||||
}
|
||||
|
||||
let yPos = Bangle.appRect.y +
|
||||
paddingY * (pos - 1) +
|
||||
|
|
@ -120,11 +121,19 @@
|
|||
drawLine(time, pos);
|
||||
};
|
||||
|
||||
let drawDate = function(now, pos){
|
||||
let drawDate = function(now, isoDate, pos) {
|
||||
let date;
|
||||
if (clock.isoDate) {
|
||||
let year = now.getFullYear();
|
||||
let month = now.getMonth() + 1; // Months are 0-11
|
||||
let day = now.getDate();
|
||||
date = ">" + year + "-" + month + "-" + day;
|
||||
} else {
|
||||
let dow = locale.dow(now, 1);
|
||||
let date = locale.date(now, 1).substr(0,6) + locale.date(now, 1).substr(-2);
|
||||
let locale_date = ">" + dow + " " + date;
|
||||
drawLine(locale_date, pos);
|
||||
date = locale.date(now, 1).substr(0,6) + locale.date(now, 1).substr(-2);
|
||||
date = ">" + dow + " " + date;
|
||||
}
|
||||
drawLine(date, pos);
|
||||
};
|
||||
|
||||
let drawInput = function(pos) {
|
||||
|
|
@ -138,19 +147,21 @@
|
|||
};
|
||||
|
||||
let drawHRM = function(pos) {
|
||||
if(heartRate != 0)
|
||||
if (heartRate != 0) {
|
||||
drawLine(">HR: " + parseInt(heartRate), pos);
|
||||
else
|
||||
} else {
|
||||
drawLine(
|
||||
">HR: " + parseInt(Math.round(Bangle.getHealthStatus().bpm||Bangle.getHealthStatus("last").bpm)),
|
||||
pos);
|
||||
}
|
||||
};
|
||||
|
||||
let drawAltitude = function(pos) {
|
||||
if(altitude > 0)
|
||||
if (altitude > 0) {
|
||||
drawLine(">Alt: " + altitude.toFixed(1) + "m", pos);
|
||||
else
|
||||
} else {
|
||||
drawLine(">Alt: unknown", pos);
|
||||
}
|
||||
};
|
||||
|
||||
let drawMotion = function(pos) {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
"name": "Terminal Clock",
|
||||
"shortName":"Terminal Clock",
|
||||
"description": "A terminal cli like clock displaying multiple sensor data",
|
||||
"version":"0.10",
|
||||
"version":"0.11",
|
||||
"icon": "app.png",
|
||||
"type": "clock",
|
||||
"tags": "clock",
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
// Load settings
|
||||
var settings = Object.assign({
|
||||
// TerminalClock specific
|
||||
isoDate: false,
|
||||
HRMinConfidence: 50,
|
||||
PowerOnInterval: 15,
|
||||
L2: 'Date',
|
||||
|
|
@ -72,6 +73,13 @@
|
|||
writeSettings();
|
||||
}
|
||||
},
|
||||
"ISO date": {
|
||||
value: !!settings.isoDate,
|
||||
onchange: v => {
|
||||
settings.isoDate = v;
|
||||
writeSettings();
|
||||
}
|
||||
},
|
||||
};
|
||||
const save = (key, v) => {
|
||||
settings[key] = v;
|
||||
|
|
|
|||
Loading…
Reference in New Issue