rwaldron / io-plugins

Documentation and discussion point for IO Plugins
117 stars 21 forks source link

IO Plugins

Gitter

(This document is a work in progress)

An IO Plugin is any class whose instances implement a Firmata compatible interface. For an in-depth case study of creating an IO plugin, read about the design and creation of the Galileo-IO Plugin here.

IO Plugins are used extensively by Johnny-Five to communicate with non-Arduino based hardware but may also be used independently if desired.

Available IO Plugins

The following platform IO Plugins are currently available:

Minimum Plugin Class Requirements

The plugin must...

Minimum API Requirements

pinMode(pin, mode)

Writing

Data writing operations must be executed in order of instruction.

analogWrite(pin, value)

pwmWrite(pin, value) (to supercede analogWrite)

digitalWrite(pin, value)

i2cWrite(address, inBytes)

i2cWrite(address, register, inBytes)

i2cWriteReg(address, register, value)

serialWrite(portId, inBytes)

servoWrite(pin, value)

Reading

All new data read processes must be asynchronous. The following methods must not block the execution process, by any means necessary. The following methods must not return the value of the new data read process.

analogRead(pin, handler)

digitalRead(pin, handler)

i2cRead(address, register, bytesToRead, handler)

i2cRead(address, bytesToRead, handler)

i2cReadOnce(address, register, bytesToRead, handler)

i2cReadOnce(address, bytesToRead, handler)

pingRead(settings, handler)

This method is defined solely to handle the needs of HCSR04 (and similar) components.

serialRead(portId, handler)

serialRead(portId[, maxBytesToRead], handler)

Configuring

i2cConfig(options)

serialConfig(options)

All options specified by a user program in the instantiation of a component will be forwarded to serialConfig.

servoConfig(options)

servoConfig(pin, min, max)

IO Control

These additions are still pending.

serialStop(portId)

serialClose(portId)

serialFlush(portId)

Special Method Definitions

normalize(pin)

// The board might want to map "A*" pins to their integer value, // eg. Arduino allows user code to write "A0" for pin 14: io.normalize("A0"); // 14



### Special Property Definitions

#### defaultLed

- This is the pin address for the board's default, built-in led.

#### name

- A printable version of the name of the IO plugin being used, e.g. "Raspi IO"

### TODO

- Define pluggable transports, for example: replacing node-serialport with socket.io-serialport and similar.