[TerminalClock] Attempt to fix high batery usage since the switch to ClockFace

master
Stiralbios 2022-06-19 08:47:59 +02:00
parent 295d646e74
commit 4d8558ef13
1 changed files with 12 additions and 8 deletions

View File

@ -21,10 +21,15 @@ if (process.env.HWVERSION == 1){
// initialising the clockface // initialising the clockface
const ClockFace = require("ClockFace"); const ClockFace = require("ClockFace");
const clock = new ClockFace({ const clock = new ClockFace({
precision: 60,
settingsFile: "terminalclock.json",
init: function () { init: function () {
// check settings and set default if needed // check settings and set default if needed
this.showHRM = false; this.showHRM = false;
this.showAltitude = false; this.showAltitude = false;
this.lock_precision = this.precision;
this.unlock_precision = 1;
if (this.HRMinConfidence === undefined) this.HRMinConfidence = 50; if (this.HRMinConfidence === undefined) this.HRMinConfidence = 50;
if (this.PowerOnInterval === undefined) this.PowerOnInterval = 15; if (this.PowerOnInterval === undefined) this.PowerOnInterval = 15;
if (this.powerSaving===undefined) this.powerSaving = true; if (this.powerSaving===undefined) this.powerSaving = true;
@ -50,11 +55,13 @@ const clock = new ClockFace({
}); });
// set the services (HRM, pressure sensor, etc....) // set the services (HRM, pressure sensor, etc....)
if(!this.powerSaving){
turnOnServices(); turnOnServices();
if(this.powerSaving){ } else{
setInterval(turnOnServices, this.PowerOnInterval*60000); // every PowerOnInterval min setInterval(turnOnServices, this.PowerOnInterval*60000); // every PowerOnInterval min
} }
// start the clock unlocked
unlock();
}, },
draw: function (date) { draw: function (date) {
@ -74,8 +81,6 @@ const clock = new ClockFace({
curPos++; curPos++;
}); });
}, },
settingsFile: "terminalclock.json"
}); });
@ -192,13 +197,12 @@ function unlock(){
if(clock.powerSaving){ if(clock.powerSaving){
turnOnServices(); turnOnServices();
} }
clock.old_precision = clock.precision; clock.precision = clock.unlock_precision;
clock.precision = 1;
clock.tick(); clock.tick();
} }
function lock(){ function lock(){
clock.precision = clock.old_precision; clock.precision = clock.lock_precision;
clock.tick(); clock.tick();
} }