Revert whitespace and code style changes
parent
8b04b8766b
commit
32e53e6aea
|
|
@ -1,8 +1,7 @@
|
|||
# Terminal clock
|
||||
|
||||
A clock displayed as a terminal cli.
|
||||
It can display:
|
||||
|
||||
It can display :
|
||||
- time
|
||||
- date
|
||||
- altitude
|
||||
|
|
@ -10,6 +9,7 @@ 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 seconds
|
||||
If "On" the sensors will be turned on every "Power on interval" minutes for 45 secondes
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
let font6x8At2Size = 18;
|
||||
let font6x8FirstTextSize = 4;
|
||||
let font6x8DefaultTextSize = 2;
|
||||
if (process.env.HWVERSION == 1) {
|
||||
if (process.env.HWVERSION == 1){
|
||||
paddingY = 3;
|
||||
font6x8At4Size = 48;
|
||||
font6x8At2Size = 27;
|
||||
|
|
@ -36,14 +36,14 @@
|
|||
if (this.powerSave===undefined) this.powerSave = true;
|
||||
|
||||
["L2", "L3", "L4", "L5", "L6", "L7", "L8", "L9"].forEach(k => {
|
||||
if (this[k]===undefined) {
|
||||
if (k == "L2") this[k] = "Date";
|
||||
else if (k == "L3") {
|
||||
if (this[k]===undefined){
|
||||
if(k == "L2") this[k] = "Date";
|
||||
else if(k == "L3") {
|
||||
this[k] = "HR";
|
||||
this.showHRM = true;
|
||||
} else if (k == "L4") this[k] = "Motion";
|
||||
else if (k == "L5") this[k] = "Steps";
|
||||
else if (k == "L6") this[k] = ">";
|
||||
}else if(k == "L4") this[k] = "Motion";
|
||||
else if(k == "L5") this[k] = "Steps";
|
||||
else if(k == "L6") this[k] = ">";
|
||||
else this[k] = "Empty";
|
||||
}
|
||||
else if (this[k]==="HR") this.showHRM = true;
|
||||
|
|
@ -51,9 +51,9 @@
|
|||
});
|
||||
|
||||
// set the services (HRM, pressure sensor, etc....)
|
||||
if (!this.powerSave) {
|
||||
if(!this.powerSave){
|
||||
turnOnServices();
|
||||
} else {
|
||||
} else{
|
||||
this.turnOnInterval = setInterval(turnOnServices, this.PowerOnInterval*60000); // every PowerOnInterval min
|
||||
}
|
||||
// start the clock unlocked
|
||||
|
|
@ -79,11 +79,11 @@
|
|||
},
|
||||
|
||||
remove: function() {
|
||||
if (this.turnOnInterval) {
|
||||
if (this.turnOnInterval){
|
||||
clearInterval(this.turnOnInterval);
|
||||
delete this.turnOnInterval;
|
||||
}
|
||||
if (this.turnOffServiceTimeout) {
|
||||
if (this.turnOffServiceTimeout){
|
||||
clearTimeout(this.turnOffServiceTimeout)
|
||||
delete this.turnOffServiceTimeout
|
||||
}
|
||||
|
|
@ -100,12 +100,11 @@
|
|||
Draw related of specific lines
|
||||
-------------------------------- */
|
||||
|
||||
let drawLine = function(line, pos) {
|
||||
if (pos == 1) {
|
||||
let drawLine = function(line, pos){
|
||||
if(pos == 1)
|
||||
g.setFont("6x8", font6x8FirstTextSize);
|
||||
} else {
|
||||
else
|
||||
g.setFont("6x8", font6x8DefaultTextSize);
|
||||
}
|
||||
|
||||
let yPos = Bangle.appRect.y +
|
||||
paddingY * (pos - 1) +
|
||||
|
|
@ -114,7 +113,7 @@
|
|||
g.drawString(line, 5, yPos, true);
|
||||
};
|
||||
|
||||
let drawTime = function(now, pos) {
|
||||
let drawTime = function(now, pos){
|
||||
let h = now.getHours();
|
||||
let m = now.getMinutes();
|
||||
let time = ">" + (""+h).substr(-2) + ":" + ("0"+m).substr(-2);
|
||||
|
|
@ -136,35 +135,33 @@
|
|||
drawLine(date, pos);
|
||||
};
|
||||
|
||||
let drawInput = function(pos) {
|
||||
let drawInput = function(pos){
|
||||
drawLine(">", pos);
|
||||
};
|
||||
|
||||
let drawStepCount = function(pos) {
|
||||
let drawStepCount = function(pos){
|
||||
let health = Bangle.getHealthStatus("day");
|
||||
let steps_formated = ">Steps: " + health.steps;
|
||||
drawLine(steps_formated, pos);
|
||||
};
|
||||
|
||||
let drawHRM = function(pos) {
|
||||
if (heartRate != 0) {
|
||||
let drawHRM = function(pos){
|
||||
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) {
|
||||
let drawAltitude = function(pos){
|
||||
if(altitude > 0)
|
||||
drawLine(">Alt: " + altitude.toFixed(1) + "m", pos);
|
||||
} else {
|
||||
else
|
||||
drawLine(">Alt: unknown", pos);
|
||||
}
|
||||
};
|
||||
|
||||
let drawMotion = function(pos) {
|
||||
let drawMotion = function(pos){
|
||||
let health = Bangle.getHealthStatus('last');
|
||||
let steps_formated = ">Motion: " + parseInt(health.movement);
|
||||
drawLine(steps_formated, pos);
|
||||
|
|
@ -174,26 +171,26 @@
|
|||
Services functions (HRM, pressure, etc...)
|
||||
-------------------------------------------------- */
|
||||
|
||||
let turnOnServices = function() {
|
||||
if (clock.showHRM) {
|
||||
let turnOnServices = function(){
|
||||
if(clock.showHRM){
|
||||
Bangle.setHRMPower(true, "terminalclock");
|
||||
}
|
||||
if (clock.showAltitude) {
|
||||
if(clock.showAltitude){
|
||||
Bangle.setBarometerPower(true, "terminalclock");
|
||||
}
|
||||
if (clock.powerSave) {
|
||||
if (clock.turnOffServiceTimeout) clearTimeout(clock.turnOffServiceTimeout);
|
||||
if(clock.powerSave){
|
||||
if(clock.turnOffServiceTimeout) clearTimeout(clock.turnOffServiceTimeout);
|
||||
clock.turnOffServiceTimeout = setTimeout(function () {
|
||||
turnOffServices();
|
||||
}, 45000);
|
||||
}
|
||||
};
|
||||
|
||||
let turnOffServices = function() {
|
||||
if (clock.showHRM) {
|
||||
let turnOffServices = function(){
|
||||
if(clock.showHRM){
|
||||
Bangle.setHRMPower(false, "terminalclock");
|
||||
}
|
||||
if (clock.showAltitude) {
|
||||
if(clock.showAltitude){
|
||||
Bangle.setBarometerPower(false, "terminalclock");
|
||||
}
|
||||
};
|
||||
|
|
@ -206,7 +203,7 @@
|
|||
Bangle.on("lock", clock.onLock);
|
||||
|
||||
clock.onHRM = hrmInfo => {
|
||||
if (hrmInfo.confidence >= clock.HRMinConfidence)
|
||||
if(hrmInfo.confidence >= clock.HRMinConfidence)
|
||||
heartRate = hrmInfo.bpm;
|
||||
};
|
||||
Bangle.on('HRM', clock.onHRM);
|
||||
|
|
@ -231,15 +228,15 @@
|
|||
Clock related functions but not in the ClockFace module
|
||||
---------------------------------------------------- */
|
||||
|
||||
let unlock = function() {
|
||||
if (clock.powerSave) {
|
||||
let unlock = function(){
|
||||
if(clock.powerSave){
|
||||
turnOnServices();
|
||||
}
|
||||
clock.precision = clock.unlock_precision;
|
||||
clock.tick();
|
||||
};
|
||||
|
||||
let lock = function() {
|
||||
let lock = function(){
|
||||
clock.precision = clock.lock_precision;
|
||||
clock.tick();
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue