sysfs gpio (and later pwm) api for nodejs
node-native-io contains sysfs bindings for gpio (and when finally working pwm) in nodejs.
var nativeio = require('native-io'); nativeio.createGPIO(22) .direction(nativeio.GPIO.OUT) .value(nativeio.GPIO.HIGH) ;
Install node-native-io with npm(1):
$ npm install node-native-io
Basically node-native-io uses a C++ add-on to give a nice api to the sysfs filesystem api.
Going to be supported when usage through device tree overlays is possible on my beaglebone black with archlinux.
The General Purpose Input Output module targets the sysfs api
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.
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.
if (gpio.direction() === nativeio.GPIO.IN) gpio.direction(nativeio.GPIO.OUT);
Returns and sets direction of a GPIO.
Copyright © 2013 Bodo Kaiser firstname.lastname@example.org
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.