mirror of https://github.com/espruino/BangleApps
drained: rearrange disabling/enabling bootcode
parent
80a77772e8
commit
ea5acf0b12
|
@ -58,3 +58,10 @@ Bangle.CLOCK = 1;
|
|||
g.clear();
|
||||
draw();
|
||||
Bangle.emit("drained", E.getBattery());
|
||||
var _a = (require("Storage").readJSON("".concat(app, ".setting.json"), true) || {}).disableBoot, disableBoot = _a === void 0 ? false : _a;
|
||||
if (disableBoot) {
|
||||
Bangle.on("charging", function (charging) {
|
||||
if (charging)
|
||||
eval(require('Storage').read('bootupdate.js'));
|
||||
});
|
||||
}
|
||||
|
|
|
@ -79,3 +79,14 @@ draw();
|
|||
|
||||
// permit other apps to put themselves into low-power mode
|
||||
Bangle.emit("drained", E.getBattery());
|
||||
|
||||
// restore normal boot on charge
|
||||
const { disableBoot = false }: DrainedSettings
|
||||
= require("Storage").readJSON(`${app}.setting.json`, true) || {};
|
||||
|
||||
if(disableBoot){
|
||||
Bangle.on("charging", charging => {
|
||||
if (charging)
|
||||
eval(require('Storage').read('bootupdate.js'));
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,16 +1,13 @@
|
|||
"use strict";
|
||||
var _a = require("Storage").readJSON("drained.setting.json", true) || {}, _b = _a.battery, threshold = _b === void 0 ? 5 : _b, _c = _a.interval, interval = _c === void 0 ? 10 : _c, _d = _a.disableBoot, disableBoot = _d === void 0 ? false : _d;
|
||||
drainedInterval = setInterval(function () {
|
||||
if (Bangle.isCharging())
|
||||
return;
|
||||
if (E.getBattery() > threshold)
|
||||
return;
|
||||
if (disableBoot) {
|
||||
require("Storage").erase(".boot0");
|
||||
Bangle.on("charging", function (charging) {
|
||||
if (charging)
|
||||
eval(require('Storage').read('bootupdate.js'));
|
||||
});
|
||||
}
|
||||
load("drained.app.js");
|
||||
}, interval * 60 * 1000);
|
||||
{
|
||||
var _a = require("Storage").readJSON("drained.setting.json", true) || {}, _b = _a.battery, threshold_1 = _b === void 0 ? 5 : _b, _c = _a.interval, interval = _c === void 0 ? 10 : _c, _d = _a.disableBoot, disableBoot_1 = _d === void 0 ? false : _d;
|
||||
drainedInterval = setInterval(function () {
|
||||
if (Bangle.isCharging())
|
||||
return;
|
||||
if (E.getBattery() > threshold_1)
|
||||
return;
|
||||
if (disableBoot_1)
|
||||
require("Storage").erase(".boot0");
|
||||
load("drained.app.js");
|
||||
}, interval * 60 * 1000);
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
{
|
||||
const { battery: threshold = 5, interval = 10, disableBoot = false }: DrainedSettings
|
||||
= require("Storage").readJSON(`drained.setting.json`, true) || {};
|
||||
|
||||
|
@ -7,14 +8,9 @@ drainedInterval = setInterval(() => {
|
|||
if(E.getBattery() > threshold)
|
||||
return;
|
||||
|
||||
if(disableBoot){
|
||||
if(disableBoot)
|
||||
require("Storage").erase(".boot0");
|
||||
|
||||
Bangle.on("charging", charging => {
|
||||
if (charging)
|
||||
eval(require('Storage').read('bootupdate.js'));
|
||||
});
|
||||
}
|
||||
|
||||
load("drained.app.js");
|
||||
}, interval * 60 * 1000);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue