@clysema/raspberry-gpio

0.1.2 • Public • Published

@clysema/raspberry-gpio

npm (scoped) npm bundle size (minified)

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());

Readme

Keywords

none

Package Sidebar

Install

npm i @clysema/raspberry-gpio

Weekly Downloads

1

Version

0.1.2

License

MIT

Unpacked Size

10.9 kB

Total Files

6

Last publish

Collaborators

  • vicnala
  • vnavarroclysema