Integrate ArduinoCore-mbed and modern JavaScript standards (ECMAScript 5/6/6+) powered by JerryScript.
This project is in beta stage and is subject to changes of the code-base, including project-wide name changes and API changes.
The build have below flags enabled, if needed you can disable this for reduce code size
jerryscript-config.h
// Build differences from default:
#define JERRY_LOGGING 1
#define JERRY_LINE_INFO 1
#define JERRY_ERROR_MESSAGES 1
#define JERRY_GLOBAL_HEAP_SIZE 128
#define JERRY_CPOINTER_32_BIT 1- Portenta H7 on M7 core
-
Working JerryScript engine
-
Working Repl
-
In progress
-
HIGH | LOW | CHANGE | RISING | FALLING -
INPUT | OUTPUT | INPUT_PULLUP -
LSBFIRST | MSBFIRST -
PIN_LED | LED_BUILTIN | LEDR | LEDG | LEDB -
A0 | A1 | A2 | A3 | A4 | A5 | A6 | A7 -
D0 | D1 | D2 | D3 | D4 | D5 | D6 | D7 | D8 | D9 | D10 | D11 | D12 | D13 | D14 | D19 | D20 | D21
-
Digital I/O:
-
pinMode() -
digitalWrite() -
digitalRead()
-
-
Time:
-
delay() -
delayMicroseconds() -
micros() -
millis()
-
-
Math:
-
abs()- via javascript 'Math' module -
constrain() -
map() -
max()- via javascript 'Math' module -
min()- via javascript 'Math' module -
pow()- via javascript 'Math' module -
sq() -
sqrt()- via javascript 'Math' module
-
-
Trigonometry:
-
cos()- via javascript 'Math' module -
sin()- via javascript 'Math' module -
tan()- via javascript 'Math' module
-
-
Random Numbers:
-
random() -
randomSeed()
-
-
Bits and Bytes:
-
bit() -
bitClear() -
bitRead() -
bitSet() -
bitWrite() -
highByte() -
lowByte()
-
-
Analog I/O:
-
analogRead() -
analogWrite() -
analogReadResolution() -
analogWriteResolution()
-
-
Advanced I/O:
-
noTone() -
pulseIn() -
pulseInLong() -
shiftIn() -
shiftOut() -
tone()
-
-
External Interrupts:
-
attachInterrupt() -
detachInterrupt()
-
-
Interrupts:
-
interrupts() -
noInterrupts()
-
-
Characters:
-
isAlpha() -
isAlphaNumeric() -
isAscii() -
isControl() -
isDigit() -
isGraph() -
isHexadecimalDigit() -
isLowerCase() -
isPrintable() -
isPunct() -
isSpace() -
isUpperCase() -
isWhitespace()
-
-
Communication:
-
Serial -
SPI -
Stream -
Wire
-
-
-
Documentations
-
External library from javascript
Create a Javascript engine and execute the script `print ('Hello, World!', Math.random ());`
ArduinoCoreMbedJS.ino
#include "Arduino.h"
#include "mbed.h"
#include "Arduino_Portenta_JerryScript.h"
REDIRECT_STDOUT_TO(Serial);
void setup() {
/* Initialize Serial */
Serial.begin(115200);
/* Wait Serial */
while (!Serial) {}
printf("Mbed OS API: %d.%d.%d\n", MBED_MAJOR_VERSION, MBED_MINOR_VERSION, MBED_PATCH_VERSION);
printf("JerryScript API: %d.%d.%d\n", JERRY_API_MAJOR_VERSION, JERRY_API_MINOR_VERSION, JERRY_API_PATCH_VERSION);
const jerry_char_t script[] = "print ('Hello, World!', Math.random ());";
/* Initialize engine */
jerry_init (JERRY_INIT_EMPTY);
/* Set log level */
jerry_log_set_level (JERRY_LOG_LEVEL_DEBUG);
/* Register the print function in the global object */
jerryx_register_global ("print", jerryx_handler_print);
/* Run script with 'eval' */
jerry_value_free (jerry_eval (script, sizeof (script) - 1, JERRY_PARSE_NO_OPTS));
/* Cleanup engine */
jerry_cleanup ();
}
void loop() {
delay(1000);
}Mbed OS API: 6.15.1
JerryScript API: 3.0.0
Hello, World! 0.6900010318495333
for other see examples folder of this repository