Skip to content

Commit 4553367

Browse files
committed
It now works with many basic functions from EADK library.
1 parent 661e556 commit 4553367

File tree

5 files changed

+435
-367
lines changed

5 files changed

+435
-367
lines changed

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ CFLAGS += -Os -Wall -Wextra -Wvla
3030
# CFLAGS += -ggdb
3131
CFLAGS += -Isrc/javascript
3232

33+
CFLAGS += -DPLATFORM_DEVICE=1
34+
3335
LDFLAGS = -Wl,--relocatable
3436
LDFLAGS += $(shell $(NWLINK) eadk-ldflags-device)
3537

README.md

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ Returns a 8 bits integer giving the battery level.
9999

100100
Returns a floating value of the battery voltage (in Volt, I guess?).
101101

102+
> These functions are missing from the hardware!
103+
> See [this issue on NumWorks/epsilon's repository](https://github.com/numworks/epsilon/issues/2326)
104+
> TODO: [I could try to implement them myself, by SVC calls](https://github.com/Naereen/A-JavaScript-interpreter-for-the-NumWorks-calculator/issues/5)
105+
102106
### Display
103107

104108
#### `void Eadk.display_draw_string(const char* text, uint16_t x, uint16_t y, bool large_font, uint16_t text_color, uint16_t background_color)`
@@ -107,23 +111,27 @@ TODO: I still haven't been able to define this one correctly, due to the `char*
107111

108112
### Timing
109113

110-
#### ? `void Eadk.timing_usleep(uint32_t us)`
114+
#### `void Eadk.timing_usleep(uint32_t us)`
111115

112116
Sleep for `us` micro-seconds
113117

114-
#### ? `void Eadk.timing_msleep(uint32_t ms)`
118+
#### `void Eadk.timing_msleep(uint32_t ms)`
115119

116120
Sleep for `ms` micro-seconds
117121

118-
#### `uint64_t Eadk.timing_millis()`
122+
#### `uint64_t Eadk.timing_millis()`
119123

120124
Time since boot of the machine? Not clear. FIXME:
121125

122126
### Miscellanious
123127

124128
#### `bool Eadk.usb_is_plugged()`
125129

126-
Indicates whether the USB is plugging.
130+
Indicates whether the USB is plugged.
131+
132+
> This function is missing from the hardware!
133+
> See [this issue on NumWorks/epsilon's repository](https://github.com/numworks/epsilon/issues/2326)
134+
> TODO: [I could try to implement it myself, by SVC calls](https://github.com/Naereen/A-JavaScript-interpreter-for-the-NumWorks-calculator/issues/5)
127135
128136
#### ✅? `uint32_t Eadk.random()`
129137

@@ -141,35 +149,31 @@ The functions already present should give a good direction to follow!
141149

142150
The example below runs now correctly and showcases a decreasing then increasing brightness, with small pauses between every change:
143151

152+
For a more complete and length example, see [`src/test.js`](src/test.js).
153+
144154
```javascript
145155
// Save this to `javascript.py` on your NumWorks, and run it with
146156
// the "JS interpreter" NumWorks application!
147157

148-
function msleep(s) {
149-
for (let j = 1; j <= s; j++) {
150-
// Just a comment here
151-
}
152-
}
153-
154158
console.log("Hello world from JavaScript!");
155159
console.log("Testing Eadk functions:");
156-
msleep(5000);
160+
Eadk.timing_msleep(5000);
157161

158162
const brightness = Eadk.backlight_brightness();
159163
console.log("Eadk.backlight_brightness() =", Eadk.backlight_brightness());
160-
msleep(2000);
164+
Eadk.timing_msleep(2000);
161165

162166
for (let dwarf = 1; dwarf <= 13; dwarf++) {
163167
for (let b = brightness; b >= 0; b=b-16) {
164168
Eadk.set_backlight_brightness(b);
165169
console.log("Eadk.backlight_brightness() =", Eadk.backlight_brightness());
166-
msleep(50);
170+
Eadk.timing_msleep(50);
167171
}
168172

169173
for (let b = 0; b <= brightness; b=b+16) {
170174
Eadk.set_backlight_brightness(b);
171175
console.log("Eadk.backlight_brightness() =", Eadk.backlight_brightness());
172-
msleep(50);
176+
Eadk.timing_msleep(50);
173177
}
174178
}
175179
```

0 commit comments

Comments
 (0)