Skip to content

Allows for boards other than Arduinos loaded with Firmata to be used with johnny-five

Notifications You must be signed in to change notification settings

achingbrain/board-io

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

board-io

An extendable implementation of Johnny Five's IO Plugins.

Implements all required and optional methods, along with the required constants - MODE, HIGH, LOW, etc.

You should configure the relevant pins of your board in your constructor, then emit the ready event.

E.g.:

var util = require('util'),
  BoardIO = require('board-io');

MyIO = function(path, callback) {
  // call super constructor
  BoardIO.call(this);

  // .. configure pins
  this._pins.push(..);

  // wait for an async method or use proccess.nextTick to
  // signal events
  process.nextTick(function() {
    // connect to hardware and emit "connect" event
    this.emit("connect");

    // all done, emit ready event
    this.emit("ready");

    // finally call the passed callback
    callback();
  }.bind(this));
}
util.inherits(IO, BoardIO);

Finally implement any of the IO Plugin methods of your choosing:

// implement digitalWrite
MyIO.prototype.digitalWrite = function(pin, value) {
  ..
};

Logging

By default BoardIO will print a message when every non-implemented method is invoked. To prevent this, set the quiet property of the super constructor args to true:

MyIO = function(path, callback) {
  // call super constructor
  BoardIO.call(this, {
    ..
    quiet: true
  });

  ..
}
util.inherits(IO, BoardIO);

Changelog

3.0.5

  1. Add serial methods and constants to match firmata

3.0.4

  1. Actually just configurable

3.0.3

  1. Make properties configurable and writable

3.0.2

  1. Define pins and analogPins on initialisation

3.0.1

  1. Adds new i2cXXX methods
  2. Prints deprecation warning when calling old sendI2CXXX methods

3.0.0 - Initial release

  1. All Firmata methods stubbed out

About

Allows for boards other than Arduinos loaded with Firmata to be used with johnny-five

Resources

Stars

Watchers

Forks

Packages

No packages published