You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+66Lines changed: 66 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,6 +27,72 @@ If you want a demo, use [this `javascript.py` script](https://my.numworks.com/py
27
27
28
28
This programs uses [the code generated by the Espruino project](https://github.com/espruino/Espruino/blob/master/README_Building.md#embedding-in-other-applications) (`espruino_embedded.c`, `espruino_embedded.h` etc), a portable JavaScript interpreter for microcontrolers.
29
29
30
+
I've started to work on [my fork of Espruino](https://github.com/Naereen/Espruino), in order to solve [this issue](https://github.com/Naereen/A-JavaScript-interpreter-for-the-NumWorks-calculator/issues/2): I wanted to give access to NumWorks's EADK library (see [`eadk.h`](https://github.com/numworks/epsilon/blob/master/eadk/include/eadk/eadk.h)) to the JavaScript files that are executed in this Espruino JS interpreter.
31
+
*It's a work in progress!*
32
+
33
+
## Documentation of the `Eadk` module accessible in JavaScript on the NumWorks
34
+
35
+
Here is a short documentation for each function that I've ported from their interface in [`eadk.h`](https://github.com/numworks/epsilon/blob/master/eadk/include/eadk/eadk.h) to a working version in JavaScript.
36
+
37
+
### Controlling the screen's brightness
38
+
#### `Eadk.backlight_brightness() -> int`
39
+
40
+
Returns the screen's brightness, it's a 8 bits integer (`uint8_t` in C), ranging between 0 (min brightness, screen almost shut down) to 240 (for max brightness).
`brightness`**must** be an integer value which fits inside a `uint8_t`, between 0 and 256.
46
+
47
+
### Eadk predefined colors
48
+
`Eadk.color_black`, `Eadk.color_white`, `Eadk.color_red`, `Eadk.color_green`, `Eadk.color_blue` are the five predefined colors.
49
+
50
+
### How to add new functions to Espruino JavaScript's `Eadk` module?
51
+
52
+
To add new functions, edit in [my fork of Espruino](https://github.com/Naereen/Espruino/) the files: [`libs/eadk/jswrap_eadk.c`](https://github.com/Naereen/Espruino/blob/master/libs/eadk/jswrap_eadk.c) and [`libs/eadk/jswrap_eadk.h`](https://github.com/Naereen/Espruino/blob/master/libs/eadk/jswrap_eadk.h).
53
+
The functions already present should give a good direction to follow!
54
+
55
+
----
56
+
57
+
## Example of a tiny JavaScript test file
58
+
59
+
The example below runs now correctly and showcases a decreasing then increasing brightness, with small pauses between every change:
60
+
61
+
```javascript
62
+
// Save this to `javascript.py` on your NumWorks, and run it with
To build this sample app, you will need to install the [embedded ARM toolchain](https://developer.arm.com/Tools%20and%20Software/GNU%20Toolchain) and [nwlink](https://www.npmjs.com/package/nwlink).
0 commit comments