0.0.6 • Published 12 months ago
@tibbo-tps/gpio v0.0.6
Common API for Tibbo's GPIO Modules
The node module for GPIO tibbits, like buttons, leds, relays and isolated inputs.
This package is deprecated!
Please, use https://www.npmjs.com/package/node-libgpiod instead
NEW GPIO code installation (package.json)
"dependencies": {
...
"@tibbo-tps/pinmap": "^0.0.x",
"@tibbo-tps/socket-name-parser": "^0.0.x",
"node-libgpiod": ">=0.3.0",
...
},
NEW GPIO code usage
const TPSpmap = require( '@tibbo-tps/pinmap');
const { version, Chip, Line } = require( "node-libgpiod");
global.chip = new Chip(0);
global.led = new Line( chip, TPSpmap.getRpin( "S15A"));
led.requestOutputMode();
led.setValue(1);
Please, see an example of GPIO usage in Wiegand app https://github.com/tibbotech/wiegand-demo/blob/master/modules/led.js
How to include it into your app: https://github.com/tibbotech/wiegand-demo/blob/master/package.json
OLD readme
Installation Instructions
Install the module
npm install @tibbo-tps/gpio
Usage
var led = gpio.init("S13A");
led.setDirection("output");
led.setValue(0);
API Methods:
init(line)
- line - TPP line code in form: S{socket number}{pin letter}, where pin letter is A, B, C or D. E.g. S15A, S3D
Returns an object with the following methods:
.setDiection(direction)
- direction - 'input' or 'output'. Use 'input' for buttons, 'output' for leds.
.getDiection()
Returns direction, 'input' or 'output'.
.setValue(value)
- value - 1 for HIGH or 0 for LOW
Sets line state.
.getValue()
Returns line state.
Example:
var gpio = require("@tibbo-tps/gpio");
var led = gpio.init("S13A");
led.setDirection("output");
var value = 0;
setInterval(function(){
led.setValue(value);
value = value === 1 ? 0 : 1;
},1000)