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
|
||||
- [x] Wake on twist -> off (#2502)
|
||||
- [x] Emit `"drained"` event
|
||||
|
||||
# Creator
|
||||
|
||||
|
|
|
@ -57,3 +57,4 @@ Bangle.setUI({
|
|||
Bangle.CLOCK = 1;
|
||||
g.clear();
|
||||
draw();
|
||||
Bangle.emit("drained", E.getBattery());
|
||||
|
|
|
@ -76,3 +76,6 @@ Bangle.CLOCK=1;
|
|||
|
||||
g.clear();
|
||||
draw();
|
||||
|
||||
// permit other apps to put themselves into low-power mode
|
||||
Bangle.emit("drained", E.getBattery());
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
"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;
|
||||
if (disableBoot) {
|
||||
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'));
|
||||
});
|
||||
}
|
||||
drainedInterval = setInterval(function () {
|
||||
if (Bangle.isCharging())
|
||||
return;
|
||||
if (E.getBattery() > battery)
|
||||
return;
|
||||
}
|
||||
load("drained.app.js");
|
||||
}, interval * 60 * 1000);
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
const { battery = 5, interval = 10, disableBoot = false }: DrainedSettings
|
||||
const { battery: threshold = 5, interval = 10, disableBoot = false }: DrainedSettings
|
||||
= require("Storage").readJSON(`drained.setting.json`, true) || {};
|
||||
|
||||
if(disableBoot){
|
||||
drainedInterval = setInterval(() => {
|
||||
if(Bangle.isCharging())
|
||||
return;
|
||||
if(E.getBattery() > threshold)
|
||||
return;
|
||||
|
||||
if(disableBoot){
|
||||
require("Storage").erase(".boot0");
|
||||
|
||||
Bangle.on("charging", charging => {
|
||||
if (charging)
|
||||
eval(require('Storage').read('bootupdate.js'));
|
||||
});
|
||||
}
|
||||
|
||||
drainedInterval = setInterval(() => {
|
||||
if(Bangle.isCharging())
|
||||
return;
|
||||
if(E.getBattery() > battery)
|
||||
return;
|
||||
}
|
||||
|
||||
load("drained.app.js");
|
||||
}, interval * 60 * 1000);
|
||||
|
|
Loading…
Reference in New Issue