GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - dmazzella/Arduino_Portenta_JerryScript: JerryScript port to ArduinoCore-Mbed

BranchesTags
Open more actions menu

Latest commit

 

History

30 Commits
30 Commits

Folders and files

NameName
Last commit message
Last commit date
examples
examples
 
 
src
src
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
library.properties
library.properties
 
 

Repository files navigation

JerryScript port to ArduinoCore-Mbed

Overview

Integrate ArduinoCore-mbed and modern JavaScript standards (ECMAScript 5/6/6+) powered by JerryScript.

WARNING:

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

Tested on:

  • Portenta H7 on M7 core

Goals:

  • Working JerryScript engine

  • Working Repl

  • Arduino API from javascript In progress

    In progress

    Constants:

    • 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

    Functions:

    • 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

Examples:

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);
}

Output

Mbed OS API: 6.15.1
JerryScript API: 3.0.0
Hello, World! 0.6900010318495333

for other see examples folder of this repository

About

JerryScript port to ArduinoCore-Mbed

Topics

arduinojavascriptjerryscriptportentaportenta-h7portentah7

Resources

Readme
MIT license
Activity

Stars

7 stars

Watchers

1 watching

Forks

1 fork
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.