Merge pull request #2147 from kyleplo/patch-6

Add Power Save
master
Gordon Williams 2022-09-26 10:05:17 +01:00 committed by GitHub
commit 11d13e142a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 64 additions and 0 deletions

27
apps/powersave/README.md Normal file
View File

@ -0,0 +1,27 @@
# Power Saver
Save your watch's battery power by halting foreground app execution while the screen is off.
## Features
- Stops foreground app processes
- Background processes still run
- Clears screen
- Decreases accelerometer polls
- Foreground app is returned to when screen is turned back on (app state is not preserved)
## Controls
- Automatically activates when screen times out, timing can be adjusted using normal timeout settings
- Deactivates when screen is turned back on
## Warnings
- Due to an Espruino bug, this does not take affect immediately when installed. Switch apps for these features to take affect.
- This is not compatible with apps that need to run in the foreground even while the screen is off, such as most stopwatch apps and some health trackers.
- If you check your watch super often (like multiple times per minute), this may end of costing you more power than it saves since the app you are using will have to restart everytime you check it.
## Requests
[Contact information is on my website](https://kyleplo.com/#contact)
## Creator
[kyleplo](https://kyleplo.com)

15
apps/powersave/boot.js Normal file
View File

@ -0,0 +1,15 @@
var Storage = Storage || require("Storage");
Bangle.on("lock", locked => {
if(locked){
g.clear().reset();
Bangle.setLCDBrightness(0);
Bangle.setPollInterval(1000);
load("powersave.screen.js");
}else{
load(Storage.read("resumeaftersleep") || JSON.parse(Storage.read("setting.json")).clock);
}
});
E.on("init", () => {
if(__FILE__ && __FILE__ !== "powersave.screen.js")
Storage.write("resumeaftersleep", __FILE__);
});

View File

@ -0,0 +1,15 @@
{
"id": "powersave",
"name": "Power Save",
"version": "0.01",
"description": "Halts foreground app execution while screen is off while still allowing background processes.",
"readme": "README.md",
"icon": "powersave.png",
"type": "bootloader",
"tags": "tool",
"supports": ["BANGLEJS2"],
"storage": [
{"name":"powersave.boot.js","url":"boot.js"},
{"name":"powersave.screen.js","url":"boot.js"}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

7
apps/powersave/screen.js Normal file
View File

@ -0,0 +1,7 @@
var Storage = Storage || require("Storage");
g.clear();
Bangle.setLCDBrightness(0);
Bangle.setPollInterval(1000);
if(!Bangle.isLocked()){
load(Storage.read("resumeaftersleep") || JSON.parse(Storage.read("setting.json")).clock);
}