Skip to content

Latest commit



77 lines (58 loc) · 2.36 KB

File metadata and controls

77 lines (58 loc) · 2.36 KB


Here you can author libraries for the Espruino with native code.

For more information on the actual build process, see the build process page

For more detailed information, check out these tutorials on the Espruino website

To get you started, here are some steps that can be made to enable in Espruino. Of course you have guessed that it will print "Hello World!" to the console. Let's get on with it!

Create a directory to contain your library files

We'll create a new folder libs/hello. In this directory, we'll create our .h and .c files.

Create the jswrap_hello.h and jswrap_hello.c files


void jswrap_hello_world();


#include "jswrap_hello.h"  // We need the declaration of the jswrap_hello_world function
#include "jsinteractive.h" // Pull inn the jsiConsolePrint function

// Let's define the JavaScript class that will contain our `world()` method. We'll call it `Hello`
  "type" : "class",
  "class" : "Hello"

// Now, we define the `jswrap_hello_world` to be a `staticmethod` on the `Hello` class
  "type" : "staticmethod",
  "class" : "Hello",
  "name" : "world",
  "generate" : "jswrap_hello_world"
void jswrap_hello_world() {
    jsiConsolePrint("Hello World!\r\n");

You can add more files here if you need. It's up to you!

Modify the Makefile

Find the text

# ---------------------------------------------------------------------------------
# When adding stuff here, also remember build_pininfo, platform_config.h, jshardware.c
# TODO: Load more of this out of the files if at all possible (see next section)
# --------------------------------------------------------------------------------- 

and add those two lines just before it

INCLUDE += -I$(ROOT)/libs/hello
WRAPPERSOURCES += libs/hello/jswrap_hello.c #you can add more files here if your library depend on them

If you want to make a pull request for your new library you'll need to make a ifdef guard for it, and specify which platforms should have access to your library. To see it in action, follow the USE_TRIGGER definition.

Compile and test!

First run make, now you can run ./espruino and test your new command.

Hello World!