native-io

sysfs gpio (and later pwm) api for nodejs

npm install native-io
1 downloads in the last day
7 downloads in the last week
15 downloads in the last month

node-native-io

node-native-io contains sysfs bindings for gpio (and when finally working pwm) in nodejs.

Usage

var nativeio = require('native-io');

nativeio.createGPIO(22)
    .direction(nativeio.GPIO.OUT)
        .value(nativeio.GPIO.HIGH)
    ;

Installation

Install node-native-io with npm(1):

$ npm install node-native-io

Documentation

Basically node-native-io uses a C++ add-on to give a nice api to the sysfs filesystem api.

Class: PWM

Going to be supported when usage through device tree overlays is possible on my beaglebone black with archlinux.

Class: GPIO

The General Purpose Input Output module targets the sysfs api at /sys/class/gpio.

new GPIO(id)

var gpio = new nativeio.GPIO(22);

// is equal to

var gpio = nativeio.createGPIO(22);

On object creation the corresponding GPIO is created, on garbage collection it should be unexported.

gpio.value([value])

if (gpio.value() === nativeio.GPIO.HIGH)
    gpio.value(native.io.GPIO.LOW);

Returns and sets value of a GPIO. If direction is IN and you set a new value you will get an error.

gpio.direction([direction])

if (gpio.direction() === nativeio.GPIO.IN)
    gpio.direction(nativeio.GPIO.OUT);

Returns and sets direction of a GPIO.

License

Copyright © 2013 Bodo Kaiser i@bodokaiser.io

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

npm loves you