Skip to content

Commit

Permalink
Bangle.js: add fake LED/LED1/LED2 as @allObjects suggested
Browse files Browse the repository at this point in the history
  • Loading branch information
gfwilliams committed Dec 4, 2019
1 parent e03843e commit 3bdafd8
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ChangeLog
Expand Up @@ -50,6 +50,8 @@
Bangle.js: Added heart rate autocorrelation, setHRMPower and 'HRM' event
Bangle.js: New 120x120 and 80x80 high speed buffered modes
Fixed REPL to allow chars with char code >=128
Fixed lex tokenToString for 'break'
Bangle.js: add fake LED/LED1/LED2 as @allObjects suggested

2v04 : Allow \1..\9 escape codes in RegExp
ESP8266: reading storage is not working for boot from user2 (fix #1507)
Expand Down
42 changes: 42 additions & 0 deletions libs/banglejs/jswrap_bangle.c
Expand Up @@ -2103,3 +2103,45 @@ E.showAlert("These are\nLots of\nLines","My Title").then(function() {
To remove the window, call `E.showAlert()` with no arguments.
*/

/*JSON{
"type" : "variable",
"name" : "LED",
"generate" : "gen_jswrap_LED1",
"return" : ["JsVar","A `Pin` object for a fake LED which appears on "],
"ifdef" : "BANGLEJS"
}
On most Espruino board there are LEDs, in which case `LED` will be an actual Pin.
On Bangle.js there are no LEDs, so to remain compatible with example code that might
expect an LED, this is an object that behaves like a pin, but which just displays
a circle on the display
*/
/*JSON{
"type" : "variable",
"name" : "LED1",
"generate_js" : "libs/js/banglejs/LED1.min.js",
"return" : ["JsVar","A `Pin` object for a fake LED which appears on "],
"ifdef" : "BANGLEJS"
}
On most Espruino board there are LEDs, in which case `LED1` will be an actual Pin.
On Bangle.js there are no LEDs, so to remain compatible with example code that might
expect an LED, this is an object that behaves like a pin, but which just displays
a circle on the display
*/
/*JSON{
"type" : "variable",
"name" : "LED2",
"generate_js" : "libs/js/banglejs/LED2.min.js",
"return" : ["JsVar","A `Pin` object for a fake LED which appears on "],
"ifdef" : "BANGLEJS"
}
On most Espruino board there are LEDs, in which case `LED2` will be an actual Pin.
On Bangle.js there are no LEDs, so to remain compatible with example code that might
expect an LED, this is an object that behaves like a pin, but which just displays
a circle on the display
*/
10 changes: 10 additions & 0 deletions libs/js/banglejs/LED1.js
@@ -0,0 +1,10 @@
(function() { // by @allObjects
return {
_v: false, // status on / off
read: function() { return this._v; },
set: function() { this.write(1); },
reset: function() { this.write(0); },
write: function(v) { g.setColor((this._v=!!v)?1:0,0,0).fillCircle(110,5,5); },
toggle: function() { this.write(!this._v); }
};
})
1 change: 1 addition & 0 deletions libs/js/banglejs/LED1.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions libs/js/banglejs/LED2.js
@@ -0,0 +1,10 @@
(function() { // by @allObjects
return {
_v: false, // status on / off
read: function() { return this._v; },
set: function() { this.write(1); },
reset: function() { this.write(0); },
write: function(v) { g.setColor(0,(this._v=!!v)?1:0,0).fillCircle(130,5,5); },
toggle: function() { this.write(!this._v); }
};
})
1 change: 1 addition & 0 deletions libs/js/banglejs/LED2.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions libs/js/update_js.sh
Expand Up @@ -34,5 +34,7 @@ node ../../../EspruinoDocs/bin/minify.js banglejs/E_showMenu.js banglejs/E_showM
node ../../../EspruinoDocs/bin/minify.js banglejs/E_showMessage.js banglejs/E_showMessage.min.js
node ../../../EspruinoDocs/bin/minify.js banglejs/E_showPrompt.js banglejs/E_showPrompt.min.js
node ../../../EspruinoDocs/bin/minify.js banglejs/E_showAlert.js banglejs/E_showAlert.min.js
node ../../../EspruinoDocs/bin/minify.js banglejs/LED1.js banglejs/LED1.min.js
node ../../../EspruinoDocs/bin/minify.js banglejs/LED2.js banglejs/LED2.min.js


0 comments on commit 3bdafd8

Please sign in to comment.