npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-espruino

v0.1.5

Published

Node library for interfacing with espruino javascript microcontroller.

Downloads

11

Readme

node-espruino

An easy to use node module for interfacing with a micro controller running espruino as well as a cli. Available as a Grunt task.

Using from node

var nodeEspruino = require('node-espruino');

var espruino = nodeEspruino.espruino({
	comPort: 'COM4'
});

espruino.open(function(){
	espruino.command('1+2', function(result){
		console.log(result);
	});
});

Using from shell

Install.

npm install node-espruino -g

Use.

$ echo 'digitalWrite(LED1, true);' > led.js
$ espruino upload led.js --save

if you know the serial number of the board, you can refer to it by serial:

$ espruino upload led.js --save --boardserial '33FFD605-41573033-15720843'

API Reference

espruino

Returns a new espruino. comPort or boardSerial must be specified. Before any communication can be made to the espruino board the open function must be called, which acepts a callback to be executed on completion.

options

comPort

COM address to connect to.

boardSerial

Serial (as in board manufacturer serial number, not COM port.) of board you want to connect to.

methods

function open( function done(err) )

This function must be called before any other function, it opens communication to the espruino board. Accepts a callback to be run when communication is established.

function command(text, function done(result) )

Executes text on espruino, calls done on completion with result of command.

function reset(done)

Resets boards memory to default, dumping all loaded code. done is a callback that executes after reset completes.

function save()

Saves loaded code to flash. Preserves after board hard reset and loss of power. done is a callback that executes after reset completes.

function upload(code, options, function done() )

options:

  • save: [true| false] whether to save the loaded code to the to the espruinos onboard flash.
  • uploadModules: [true | false] if true, module requires are parsed out of code and uploaded.
  • moduleDir: 'Path' the root directory to look for modules.

Convenience function. Parses out modules from code and loads from disk, resets board, then uploads code.

function dump(function done(result))

Dumps loaded code from espruino.

function addModule(name, code, function done)

Adds a module with the specified name and code to the espruino. It can then be loaded by running require('name') on the espruino.

function clearModules(function done)

Clears all loaded modules from espruino.

function parseModules(code)

Returns an array of all modules defined in code. Parses out require('module') from input code.

function close(function done() )

Closes serial connection to espruino.

events

.on('data', function callback(data) )

when espruino writes data back over serial, callback is called with data.

CLI Reference


Global arguments

--port [COM Port]

--boardserial [Board Serial No]

--listen

If listen is specified, after the command is completed we will leave the serial connection open and print from the espruino.

Commands

upload [file] --save

Flashes the specified file to the espruino. If save is specified the uploaded code is saved to flash.

Issues


  • The command line functionality doesnt like arguments with & in them, everything after gets truncated.
  • The board is remembering things after reset has been called, I believe this is a issue with the board itself. Reported here..

ToDo


Nothing now. Yay!