mirror of https://github.com/espruino/BangleApps
drained: emit "drained" event
parent
ab75d5b353
commit
80a77772e8
|
@ -20,6 +20,7 @@ With this app installed, your Bangle will automatically switch into low power mo
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
- [x] Wake on twist -> off (#2502)
|
- [x] Wake on twist -> off (#2502)
|
||||||
|
- [x] Emit `"drained"` event
|
||||||
|
|
||||||
# Creator
|
# Creator
|
||||||
|
|
||||||
|
|
|
@ -57,3 +57,4 @@ Bangle.setUI({
|
||||||
Bangle.CLOCK = 1;
|
Bangle.CLOCK = 1;
|
||||||
g.clear();
|
g.clear();
|
||||||
draw();
|
draw();
|
||||||
|
Bangle.emit("drained", E.getBattery());
|
||||||
|
|
|
@ -76,3 +76,6 @@ Bangle.CLOCK=1;
|
||||||
|
|
||||||
g.clear();
|
g.clear();
|
||||||
draw();
|
draw();
|
||||||
|
|
||||||
|
// permit other apps to put themselves into low-power mode
|
||||||
|
Bangle.emit("drained", E.getBattery());
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
var _a = require("Storage").readJSON("drained.setting.json", true) || {}, _b = _a.battery, battery = _b === void 0 ? 5 : _b, _c = _a.interval, interval = _c === void 0 ? 10 : _c, _d = _a.disableBoot, disableBoot = _d === void 0 ? false : _d;
|
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) {
|
if (disableBoot) {
|
||||||
require("Storage").erase(".boot0");
|
require("Storage").erase(".boot0");
|
||||||
Bangle.on("charging", function (charging) {
|
Bangle.on("charging", function (charging) {
|
||||||
|
@ -7,10 +12,5 @@ if (disableBoot) {
|
||||||
eval(require('Storage').read('bootupdate.js'));
|
eval(require('Storage').read('bootupdate.js'));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
drainedInterval = setInterval(function () {
|
|
||||||
if (Bangle.isCharging())
|
|
||||||
return;
|
|
||||||
if (E.getBattery() > battery)
|
|
||||||
return;
|
|
||||||
load("drained.app.js");
|
load("drained.app.js");
|
||||||
}, interval * 60 * 1000);
|
}, interval * 60 * 1000);
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
const { battery = 5, interval = 10, disableBoot = false }: DrainedSettings
|
const { battery: threshold = 5, interval = 10, disableBoot = false }: DrainedSettings
|
||||||
= require("Storage").readJSON(`drained.setting.json`, true) || {};
|
= require("Storage").readJSON(`drained.setting.json`, true) || {};
|
||||||
|
|
||||||
|
drainedInterval = setInterval(() => {
|
||||||
|
if(Bangle.isCharging())
|
||||||
|
return;
|
||||||
|
if(E.getBattery() > threshold)
|
||||||
|
return;
|
||||||
|
|
||||||
if(disableBoot){
|
if(disableBoot){
|
||||||
require("Storage").erase(".boot0");
|
require("Storage").erase(".boot0");
|
||||||
|
|
||||||
|
@ -10,11 +16,5 @@ if(disableBoot){
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
drainedInterval = setInterval(() => {
|
|
||||||
if(Bangle.isCharging())
|
|
||||||
return;
|
|
||||||
if(E.getBattery() > battery)
|
|
||||||
return;
|
|
||||||
|
|
||||||
load("drained.app.js");
|
load("drained.app.js");
|
||||||
}, interval * 60 * 1000);
|
}, interval * 60 * 1000);
|
||||||
|
|
Loading…
Reference in New Issue