@clysema/raspberry-gpio
v0.1.2
Published
[![npm (scoped)](https://img.shields.io/npm/v/@clysema/raspberry-gpio.svg)](https://www.npmjs.com/package/@clysema/raspberry-gpio) [![npm bundle size (minified)](https://img.shields.io/bundlephobia/min/@clysema/raspberry-gpio.svg)](https://www.npmjs.com/p
Downloads
3
Readme
@clysema/raspberry-gpio
Simple wrapper for the onoff package.
Install
$ npm install @clysema/raspberry-gpio
Config
config/raspberry-gpio.json
[
{
"name": "IN1",
"gpio": 22,
"type": "input",
"edge": "falling",
"debounceTimeout": 100
},
{
"name": "IN2",
"gpio": 23,
"type": "input"
},
{
"name": "OUT1",
"gpio": 24,
"type": "output",
"init": 1
}
]
Usage
Is an event emitter:
// subscribe to data
app.modules["raspberry-gpio"].emitter.on("data", (data) => {
console.log(data);
// { name: 'IN1', value: 1 }
});
// subscribe to errors
app.modules["raspberry-gpio"].emitter.on("error", (error) => {
console.log(error);
});
Read/Write:
console.log(await app.modules["raspberry-gpio"].readOutputs());
await app.modules["raspberry-gpio"].setOutput("OUT1", 0);
console.log(await app.modules["raspberry-gpio"].readOutputs());