1
0
Fork 0

drained: configure battery% and check interval

master
Rob Pilling 2023-04-08 08:25:27 +01:00
parent 512381a2de
commit 9c643f6b5d
4 changed files with 45 additions and 3 deletions

View File

@ -7,6 +7,7 @@ With this app installed, your Bangle will automatically switch into low power mo
## Time
- [x] Show simple date/time
- [ ] Disable alarms - with a setting?
- [ ] Smarter/backoff interval for checking battery percentage
## No backlight (#2502)
- [x] LCD brightness

View File

@ -1,8 +1,11 @@
const { battery = 5, interval = 10 } = require("Storage")
.readJSON(`${app}.setting.json`, true) || {};
let drainedInterval: number | undefined = setInterval(() => {
if(Bangle.isCharging())
return;
if(E.getBattery() > 5)
if(E.getBattery() > battery)
return;
load("drained.app.js");
}, 5 * 60 * 1000);
}, interval * 60 * 1000);

View File

@ -11,6 +11,7 @@
"allow_emulator": true,
"storage": [
{"name":"drained.boot.js","url":"boot.js"},
{"name":"drained.app.js","url":"app.js"}
{"name":"drained.app.js","url":"app.js"},
{"name":"drained.settings.js","url":"settings.js"}
]
}

37
apps/drained/settings.ts Normal file
View File

@ -0,0 +1,37 @@
((back: () => void) => {
const SETTINGS_FILE = "drained.setting.json";
const storage = require("Storage")
const settings = storage.readJSON(SETTINGS_FILE, true) || {};
settings.battery ??= 5;
settings.interval ??= 10;
const save = () => {
storage.writeJSON(SETTINGS_FILE, settings)
};
E.showMenu({
"": { "title": "Drained" },
"< Back": back,
"Trigger when battery reaches": {
value: settings.battery,
min: 0,
max: 95,
step: 5,
onchange: (v: number) => {
settings.battery = v;
save();
},
},
"Check every N minutes": {
value: settings.interval,
min: 1,
max: 60 * 2,
step: 5,
onchange: (v: number) => {
settings.interval = v;
save();
},
},
});
})