[TerminalClock] Change the settings to be able to personalize the line display more

master
Stiralbios 2022-06-18 18:39:51 +02:00
parent 93b6fdb974
commit a6fa71290b
4 changed files with 103 additions and 115 deletions

View File

@ -4,3 +4,4 @@
0.04: Fix settings bug
0.05: Add altitude display (only Bangle.js 2)
0.06: Add power related settings to control the HR and pressure(altitude) sensor from the watchface
0.07: Use ClockFace module and rework the settings to be able to personnalize the order of the lines

View File

@ -23,15 +23,15 @@ const ClockFace = require("ClockFace");
const clock = new ClockFace({
init: function () {
// check settings and set default if needed
this.showHRM = false;
this.showAltitude = false;
if (this.HRMinConfidence === undefined) this.HRMinConfidence = 50;
if (this.PowerOnInterval === undefined) this.PowerOnInterval = 15;
if (this.showAltitude === undefined){
this.showAltitude = true && process.env.HWVERSION == 2;
}else {
this.showAltitude = this.showAltitude && process.env.HWVERSION == 2;
}
["showHRM", "showActivity", "showStepCount", "powerSaving"].forEach(k => {
if (this[k]===undefined) this[k] = true;
if (this.powerSaving===undefined) this[k] = true;
["L2", "L3", "L4", "L5", "L6", "L7", "L8", "L9"].forEach(k => {
if (this[k]===undefined) this[k] = "Empty";
else if (this[k]==="HR") this.showHRM = true;
else if (this[k]==="Alt") this.showAltitude = true && process.env.HWVERSION == 2;
});
Bangle.on("lock", on => {
@ -52,27 +52,16 @@ const clock = new ClockFace({
g.setColor(fontColor);
drawTime(date, curPos);
curPos++;
if(this.showDate){
drawDate(date, curPos);
["L2", "L3", "L4", "L5", "L6", "L7", "L8", "L9"].forEach(line => {
if (this[line]==='Date') drawDate(date, curPos);
else if (this[line]==='HR') drawHRM(curPos);
else if (this[line]==='Motion') drawMotion(curPos);
else if (this[line]==='Alt') drawAltitude(curPos);
else if (this[line]==='Steps') drawStepCount(curPos);
else if (this[line]==='>') drawInput(curPos);
curPos++;
}
if(this.showAltitude){
drawAltitude(curPos);
curPos++;
}
if(this.showHRM){
drawHRM(curPos);
curPos++;
}
if(this.showActivity){
drawActivity(curPos);
curPos++;
}
if(this.showStepCount){
drawStepCount(curPos);
curPos++;
}
drawInput(curPos);
});
},
settingsFile: "terminalclock.json"
@ -134,13 +123,12 @@ function drawAltitude(pos){
drawLine(">Alt: unknown", pos);
}
function drawActivity(pos){
function drawMotion(pos){
var health = Bangle.getHealthStatus('last');
var steps_formated = ">Motion: " + parseInt(health.movement);
drawLine(steps_formated, pos);
}
/* -----------------------------------------------
Services functions (HRM, pressure, etc...)
-------------------------------------------------- */

View File

@ -3,7 +3,7 @@
"name": "Terminal Clock",
"shortName":"Terminal Clock",
"description": "A terminal cli like clock displaying multiple sensor data",
"version":"0.06",
"version":"0.07",
"icon": "app.png",
"type": "clock",
"tags": "clock",

View File

@ -3,104 +3,103 @@
// Load settings
var settings = Object.assign({
// ClockFace lib
showDate: true,
loadWidgets: true,
// TerminalClock specific
HRMinConfidence: 50,
showAltitude: process.env.HWVERSION == 2 ? true : false,
showHRM: true,
showActivity: true,
showStepCount: true,
powerSaving: true,
PowerOnInterval: 15,
L2: 'Date',
L3: 'HR',
L4: 'Motion',
L5: 'Steps',
L6: '>',
L7: 'Empty',
L8: 'Empty',
L9: 'Empty',
}, require('Storage').readJSON(FILE, true) || {});
function writeSettings() {
require('Storage').writeJSON(FILE, settings);
}
// Show the menu
var menu = {
"" : { "title" : "Terminal Clock" },
"< Back" : () => back(),
'HR confidence': {
value: settings.HRMinConfidence,
min: 0, max: 100,
if(process.env.HWVERSION == 2) {
var lineType = ['Date', 'HR', 'Motion', 'Alt', 'Steps', '>', 'Empty'];
} else{
var lineType = ['Date', 'HR', 'Motion', 'Steps', '>', 'Empty'];
}
function getLineChooser(lineID){
return {
value: lineType.indexOf(settings[lineID]),
min: 0, max: lineType.length-1,
format: v => lineType[v],
onchange: v => {
settings.HRMinConfidence = v;
writeSettings();
}
},
'Show widgets': {
value: settings.loadWidgets,
format: v => v?"Yes":"No",
onchange: v => {
settings.loadWidgets = v;
writeSettings();
}
},
'Show date': {
value: settings.showDate,
format: v => v?"Yes":"No",
onchange: v => {
settings.showDate = v;
writeSettings();
}
},
'Show Altitude': {
value: settings.showAltitude,
format: v => v?"Yes":"No",
onchange: v => {
settings.showAltitude = v;
writeSettings();
}
},
'Show HRM': {
value: settings.showHRM,
format: v => v?"Yes":"No",
onchange: v => {
settings.showHRM = v;
writeSettings();
}
},
'Show Activity': {
value: settings.showActivity,
format: v => v?"Yes":"No",
onchange: v => {
settings.showActivity = v;
writeSettings();
}
},
'Show Steps': {
value: settings.showStepCount,
format: v => v?"Yes":"No",
onchange: v => {
settings.showStepCount = v;
writeSettings();
}
},
'Power saving': {
value: settings.powerSaving,
format: v => v?"On":"Off",
onchange: v => {
settings.powerSaving = v;
writeSettings();
}
},
'Power on interval': {
value: settings.PowerOnInterval,
min: 3, max: 60,
onchange: v => {
settings.PowerOnInterval = v;
settings[lineID] = lineType[v];
writeSettings();
},
format: x => {
return x + " min";
};
}
var lineMenu = {
'< Back': function() { E.showMenu(getMainMenu());},
'Line 2': getLineChooser('L2'),
'Line 3': getLineChooser('L3'),
'Line 4': getLineChooser('L4'),
'Line 5': getLineChooser('L5'),
'Line 6': getLineChooser('L6'),
'Line 7': getLineChooser('L7'),
'Line 8': getLineChooser('L8'),
'Line 9': getLineChooser('L9'),
};
function getMainMenu(){
var mainMenu = {
"" : { "title" : "Terminal Clock" },
"< Back" : () => back(),
'HR confidence': {
value: settings.HRMinConfidence,
min: 0, max: 100,
onchange: v => {
settings.HRMinConfidence = v;
writeSettings();
}
},
'Show widgets': {
value: settings.loadWidgets,
format: v => v?"Yes":"No",
onchange: v => {
settings.loadWidgets = v;
writeSettings();
}
},
'Power saving': {
value: settings.powerSaving,
format: v => v?"On":"Off",
onchange: v => {
settings.powerSaving = v;
writeSettings();
setTimeout(function() {
E.showMenu(getMainMenu());
},0);
}
}
};
if(settings.powerSaving){
mainMenu['Power on interval'] = {
value: settings.PowerOnInterval,
min: 3, max: 60,
onchange: v => {
settings.PowerOnInterval = v;
writeSettings();
},
format: x => {
return x + " min";
},
};
}
mainMenu['Lines'] = function() { E.showMenu(lineMenu);};
return mainMenu;
}
if (process.env.HWVERSION == 1) {
delete menu['Show Altitude']
}
E.showMenu(menu);
})
E.showMenu(getMainMenu());
})();