drained: only check for power-restore when charging
parent
8742e11581
commit
b721023daa
|
|
@ -101,14 +101,20 @@ function drainedRestore() {
|
||||||
load();
|
load();
|
||||||
}
|
}
|
||||||
var checkCharge = function () {
|
var checkCharge = function () {
|
||||||
if (!Bangle.isCharging() || E.getBattery() < restore) {
|
if (E.getBattery() < restore) {
|
||||||
draw();
|
draw();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
drainedRestore();
|
drainedRestore();
|
||||||
};
|
};
|
||||||
checkCharge();
|
if (Bangle.isCharging())
|
||||||
drainedInterval = setInterval(checkCharge, interval * 60 * 1000);
|
checkCharge();
|
||||||
|
Bangle.on("charging", function (charging) {
|
||||||
|
if (drainedInterval)
|
||||||
|
drainedInterval = clearInterval(drainedInterval);
|
||||||
|
if (charging)
|
||||||
|
drainedInterval = setInterval(checkCharge, interval * 60 * 1000);
|
||||||
|
});
|
||||||
if (!keepStartup) {
|
if (!keepStartup) {
|
||||||
var storage = require("Storage");
|
var storage = require("Storage");
|
||||||
for (var _i = 0, exceptions_1 = exceptions; _i < exceptions_1.length; _i++) {
|
for (var _i = 0, exceptions_1 = exceptions; _i < exceptions_1.length; _i++) {
|
||||||
|
|
|
||||||
|
|
@ -131,15 +131,22 @@ function drainedRestore() { // "public", to allow users to call
|
||||||
}
|
}
|
||||||
|
|
||||||
const checkCharge = () => {
|
const checkCharge = () => {
|
||||||
if(!Bangle.isCharging() || E.getBattery() < restore) {
|
if(E.getBattery() < restore) {
|
||||||
draw();
|
draw();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
drainedRestore();
|
drainedRestore();
|
||||||
};
|
};
|
||||||
|
|
||||||
checkCharge();
|
if (Bangle.isCharging())
|
||||||
drainedInterval = setInterval(checkCharge, interval * 60 * 1000);
|
checkCharge();
|
||||||
|
|
||||||
|
Bangle.on("charging", charging => {
|
||||||
|
if(drainedInterval)
|
||||||
|
drainedInterval = clearInterval(drainedInterval) as undefined;
|
||||||
|
if(charging)
|
||||||
|
drainedInterval = setInterval(checkCharge, interval * 60 * 1000);
|
||||||
|
});
|
||||||
|
|
||||||
if(!keepStartup){
|
if(!keepStartup){
|
||||||
const storage = require("Storage");
|
const storage = require("Storage");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue