Skip to content

Commit 76c3801

Browse files
authored
Merge branch 'espruino:master' into Weather-Feels-Like-Updates
2 parents 7bb0218 + b7daabb commit 76c3801

File tree

123 files changed

+1690
-441
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+1690
-441
lines changed

apps/backlite/ChangeLog

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
0.01: New app! (settings, boot.js).
2+
0.02: Fix settings defaulting brightness to 0

apps/backlite/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# BackLite
2+
### This app needs the latest settings app update (v 0.80), to ensure that setting the brightness to `0` does not default to `1`.
3+
4+
BackLite is an app which greatly conserves battery life by only turning the backlight on when you long press the button from a locked state.
5+
6+
Modern watches have a dedicated button to turn the backlight on, so as not to waste battery in an already light environment. This app recreates that functionality for the Bangle.js, which only has one button.
7+
8+
#### Warning: This app overwrites the LCD brightness setting in `Bangle.js LCD settings`. If it is changed, the app will basically lose functionality. It auto-fixes itself every boot, so if you change the brightness, just reboot :)
9+
# Usage
10+
When you unlock with a press of the button, or any other way you unlock the watch, the backlight will not turn on, as most of the time you are able to read it, due to the transreflective display on the Bangle.js 2.
11+
12+
If you press and hold the button to unlock the watch (for around half a second), the backlight will turn on for 5 seconds - just enough to see what you need to see. After that, it will turn off again.
13+
14+
Some apps like `Light Switch Widget` will prevent this app from working properly.
15+
# Settings
16+
`Brightness` - The LCD brightness when unlocked with a long press.
17+
# Creator
18+
RKBoss6
19+
20+
TODO: Add a setting for long press time, or light duration

apps/backlite/boot.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
let getSettings = function(){
3+
return Object.assign({
4+
// default values
5+
brightness: 0.3,
6+
7+
}, require('Storage').readJSON("BackLite.settings.json", true) || {});
8+
};
9+
10+
11+
//Set LCD to zero every reboot
12+
let s = require("Storage").readJSON("setting.json", 1) || {};
13+
s.brightness = 0;
14+
require("Storage").writeJSON("setting.json", s);
15+
//remove large settings object from memory
16+
delete s;
17+
const longPressTime=400; //(ms)
18+
19+
Bangle.on('lock', function(isLocked) {
20+
Bangle.setLCDBrightness(0);
21+
22+
if (!isLocked) {
23+
// Just unlocked — give a short delay and check if BTN1 is still pressed
24+
setTimeout(() => {
25+
if (digitalRead(BTN1)) {
26+
//set brightness until. locked.
27+
Bangle.setLCDBrightness(getSettings().brightness);
28+
} else {
29+
Bangle.setLCDBrightness(0);
30+
}
31+
}, longPressTime); // Slight delay to allow unlock to settle
32+
}
33+
});
34+
35+
}
36+

apps/backlite/icon.png

1.44 MB
Loading

apps/backlite/metadata.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"id": "backlite",
3+
"name": "BackLite",
4+
"version": "0.02",
5+
"description": "Conserves battery life by turning the backlight on only on a long press of the button from a locked state. **Requires the latest settings update (v0.80)**",
6+
"icon": "icon.png",
7+
"type": "bootloader",
8+
"tags": "system",
9+
"readme": "README.md",
10+
"supports": ["BANGLEJS2"],
11+
"storage": [
12+
{"name":"backlite.boot.js","url":"boot.js"},
13+
{"name":"backlite.settings.js","url":"settings.js"}
14+
15+
],
16+
"data": [{"name":"BackLite.settings.json"}]
17+
}

apps/backlite/settings.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
(function(back) {
2+
var FILE = "BackLite.settings.json";
3+
4+
var settings = require("Storage").readJSON(FILE, 1) || {};
5+
6+
if (!isFinite(settings.brightness)) settings.brightness = 0.3;
7+
8+
function writeSettings() {
9+
require("Storage").writeJSON(FILE, settings);
10+
}
11+
12+
E.showMenu({
13+
"" : { "title" : "BackLite" },
14+
"< Back": back, // fallback if run standalone
15+
"Brightness": {
16+
value: settings.brightness,
17+
min: 0.1, max: 1,
18+
step: 0.1,
19+
onchange: v => {
20+
settings.brightness = v;
21+
writeSettings();
22+
}
23+
},
24+
});
25+
})

apps/bbreaker/ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
0.01: It works somehow, early version for testers and feedback :)
2+
0.02: Changed almost all code with Frederic version of Pong and adjusted to be a BrickBreaker!, still Alpha
3+
0.03: Rewrote the whole thing to have less code and better graphics, now it works.
4+
0.04: Rewrote part of the code to coupe with the flickering and added better logic to handle the graphics.

apps/bbreaker/README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# BrickBreaker
2+
3+
A simple BreakOut clone for the Banglejs
4+
5+
![Screenshot](bbreaker.png)
6+
7+
## Usage
8+
9+
![Screenshot](playing.png)
10+
11+
Buttons 1 and 3 to move the BrickBreaker!
12+
13+
Button 2 to pause and start the game again.
14+
15+
## Disclaimer
16+
17+
This game was created to learn JS and how to interact with Banglejs, meaning that it may not be perfect :).
18+
19+
Built with love with base on the tutorial: 2D breakout game using pure JavaScript
20+
https://developer.mozilla.org/en-US/docs/Games/Tutorials/2D_Breakout_game_pure_JavaScript
21+
22+
Started on 2020 but rewrote all in 2025 and this is the version I got without having issues with Memory Exhaustion.
23+
24+
And yes, for Bangle 1, old school!
25+
26+
## Creator
27+
28+
Israel Ochoa <isuraeru at gmail.com>

apps/bbreaker/app-icon.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)