Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: bellard/quickjs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: binzume/esp32quickjs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 2020-11-08_esp32
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.
  • 6 commits
  • 4 files changed
  • 1 contributor

Commits on Nov 23, 2020

  1. esp32

    binzume committed Nov 23, 2020
    Copy the full SHA
    219eab6 View commit details

Commits on Nov 26, 2020

  1. add header library for ESP32.

    binzume committed Nov 26, 2020
    Copy the full SHA
    966b975 View commit details

Commits on Nov 28, 2020

  1. reduce firmware size

    binzume committed Nov 28, 2020
    Copy the full SHA
    b1c37b7 View commit details
  2. Add esp32.fetch() api

    binzume committed Nov 28, 2020
    Copy the full SHA
    1827764 View commit details

Commits on Dec 5, 2020

  1. esp32 module

    binzume committed Dec 5, 2020
    Copy the full SHA
    1c8a1d5 View commit details

Commits on Nov 8, 2021

  1. Clear timers in end().

    binzume committed Nov 8, 2021
    Copy the full SHA
    ec49bcf View commit details
Showing with 579 additions and 5 deletions.
  1. +66 −0 README.md
  2. +470 −0 esp32/QuickJS.h
  3. +38 −0 library.json
  4. +5 −5 quickjs.c
66 changes: 66 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# QuickJS Javascript Engine

- https://bellard.org/quickjs/
- https://github.com/bellard/quickjs

The main documentation is in doc/quickjs.pdf or doc/quickjs.html.

# Build with platform.io (ESP32)

Exampes: https://github.com/binzume/esp32quickjs-examples

### platformio.ini

add git url to `lib_deps`.

```ini
lib_deps =
https://github.com/binzume/esp32quickjs.git
```

### main.cpp

include `esp/QuickJS.h`.

```c++
#include <Arduino.h>
#include "esp/QuickJS.h"

static const char *jscode = R"CODE(
console.log('Hello, JavaScript!');
)CODE";

M5QuickJS qjs;

void setup() {
Serial.begin(115200);
qjs.begin();
qjs.exec(jscode);
}
```

# JavaScript API

- console.log(string)
- setTimeout(callback, ms) : int
- setInterval(callback, ms) : int
- clearTimeout(id)

`esp32` module

- esp32.millis() : int
- esp32.digitalRead(pin) : int
- esp32.digitalWrite(pin, value) // value=0: LOW, 1: HIGH
- esp32.pinMode(pin, mode) // mode=1: INPUT, 2: OUTPUT
- esp32.setLoop(func) // func is called every arduino loop().
- esp32.deepSleep(us) // not returns

if WiFi.h is included:

- esp32.isWifiConnected() : bool
- esp32.fetch(url, {method:string, body:string}): Promise<{body:string, status:int}>


# License

MIT License
Loading