{"_id":"@dnetherton/rpi-gpio","_rev":"1-5352a2f2ab7e5385020bc9d8b07ac38b","name":"@dnetherton/rpi-gpio","dist-tags":{"latest":"2.1.3"},"versions":{"2.1.3":{"name":"@dnetherton/rpi-gpio","version":"2.1.3","description":"Control Raspberry Pi GPIO pins with node.js","main":"rpi-gpio.js","keywords:":["raspberry","pi","gpio"],"directories":{"test":"test","integration":"integration"},"devDependencies":{"istanbul":"^0.4.5","mocha":"^5.1.1","sinon":"^5.1.1"},"scripts":{"test":"mocha","spec":"mocha --reporter spec","coverage":"istanbul cover _mocha","int":"mocha test/integration"},"repository":{"type":"git","url":"git+https://github.com/vipoo/rpi-gpio.js.git"},"author":{"name":"James Barwell","email":"jb@jamesbarwell.co.uk"},"license":"MIT","dependencies":{"async-retry":"^1.2.1","debug":"^3.1.0","epoll":"^2.0.3"},"gitHead":"b25f04cbe100dcad0019fffe3e256070b30ff3a9","bugs":{"url":"https://github.com/vipoo/rpi-gpio.js/issues"},"homepage":"https://github.com/vipoo/rpi-gpio.js#readme","_id":"@dnetherton/rpi-gpio@2.1.3","_nodeVersion":"10.15.3","_npmVersion":"6.9.0","dist":{"integrity":"sha512-UOeK9T+1jbiLvEijgPIcn2G3IxnnAQ1lGVLq9hCCFvSloLpEveJH4xyp3i9k8g2OFsf5nLmlhnryRa/NHReqFw==","shasum":"f1040394cfac02e40e79058f0e04ad60d14490a6","tarball":"https://registry.npmjs.org/@dnetherton/rpi-gpio/-/rpi-gpio-2.1.3.tgz","fileCount":7,"unpackedSize":73315,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJc5NwgCRA9TVsSAnZWagAAr/EP/inT4zlJ4Nal8fI79hQ5\nvvAwAwxHuxDTp9ACO3JDvYpVBZclOIFlxvbmziNBi+/5Z5Y4mZBXORT8SWnK\nBNi610ZHW+M3RXKfeTf9A6DELp/n808gsyEucI6e2LLw/E5Pf4bfjvXs2ihM\nYytRxgVVpXIiA3Ejz+alh7X9gLe/M3SH4+0CiLyYRfl0ZHFat8Iox+TS9bgA\nMDRS89DdtXicFe0SiAXmi2rV1ds1mJ1j6xu72oUONTEEx3hDa3E+0bQ0Yscu\nzIf4F7+D1srovlACxp2Pz1kwR9GLBbTMJ+Dy0llDYfpZwkdkPSu3YdpXuw81\nIoxgcEUGh2tZyQ6SaICC0+Gmljl7UJP3yHeDeDVG2vrQMcyHz7ZH5eYEcdd8\nQcT0sKeZtJWrTQr2kxJ0z+sEAuqm2LnPC1jQxSkklmTPsYc3wG7kToFyyGq2\nWAvHueYk/R4kzNfQZ3eqK60EMOeFLowhKeTDZcoxYBSKsTnumqZMHuGLPEAe\no9z9EheIJQtI7Z4a8jTuqCSRHwaRBbram1CBJVwCA8xPiveDG5WBr2J8dWM7\n7URwp6YuoM5tZ0P4daKcafWtDWDcdWU1HiknY/ZagaArycwEVkx+ZuxzOlRy\n/pm2rGKD7UnRJqPcmXHHzoSWgjiDyI5JeiCFqgdTpJ5fRc1auVOOcMaWmDAu\npTNz\r\n=ToYY\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCM2uBmfVh0T76qhzqrsUqjo4RFuSYAT3ySh+TnACNnUwIgdMlJp2kQV9zJUrTBpHLH0mVH0KdQvRCp0D2gGOLCaIA="}]},"maintainers":[{"name":"dnetherton","email":"antispam@netherton.org"}],"_npmUser":{"name":"dnetherton","email":"antispam@netherton.org"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rpi-gpio_2.1.3_1558502431552_0.07476366182092598"},"_hasShrinkwrap":false}},"time":{"created":"2019-05-22T05:20:31.521Z","2.1.3":"2019-05-22T05:20:31.701Z","modified":"2022-04-05T05:01:12.125Z"},"maintainers":[{"name":"dnetherton","email":"antispam@netherton.org"}],"description":"Control Raspberry Pi GPIO pins with node.js","homepage":"https://github.com/vipoo/rpi-gpio.js#readme","repository":{"type":"git","url":"git+https://github.com/vipoo/rpi-gpio.js.git"},"author":{"name":"James Barwell","email":"jb@jamesbarwell.co.uk"},"bugs":{"url":"https://github.com/vipoo/rpi-gpio.js/issues"},"license":"MIT","readme":"rpi-gpio.js\n==========\n\nControl Raspberry Pi GPIO pins with node.js\n\n[![Build Status](https://travis-ci.org/JamesBarwell/rpi-gpio.js.svg?branch=master)](https://travis-ci.org/JamesBarwell/rpi-gpio.js)\n[![NPM version](https://badge.fury.io/js/rpi-gpio.svg)](http://badge.fury.io/js/rpi-gpio)\n\n## Supported hardware\n\n* Raspberry Pi 1 Model A\n* Raspberry Pi 1 Model A+\n* Raspberry Pi 1 Model B\n* Raspberry Pi 1 Model B+\n* Raspberry Pi 2 Model B\n* Raspberry Pi 3 Model B\n* Raspberry Pi Zero\n* Raspberry Pi Zero W\n\n## Supported node versions\n\nrpi-gpio 1.x is no longer supported. Please use 2.x unless you need to run with an old version of node.\n\n| node version | rpi-gpio 1.x | rpi-gpio 2.x + |\n| ------------ | ------------ | -------------- |\n| 0.10         | Yes          | No             |\n| 0.12         | Yes          | No             |\n| 4            | Yes          | Yes            |\n| 6            | Yes          | Yes            |\n| 8            | Yes          | Yes            |\n| 10           | No           | Yes            |\n\n## Setup and install\n\nSee this guide on how to get [node.js running on Raspberry Pi](http://thisdavej.com/beginners-guide-to-installing-node-js-on-a-raspberry-pi/#install-node).\n\nThis module can then be installed with npm:\n```\nnpm install rpi-gpio\n```\n\n### Dependency\nPlease note that this module has a dependency on [epoll](https://github.com/fivdi/epoll) and that currently it is only possible to build and develop the module on Linux systems.\n\nIf you are having trouble installing this module make sure you are running gcc/g++ `-v 4.8` or higher. [Here](https://github.com/fivdi/onoff/wiki/Node.js-v4-and-native-addons) is an installation guide.\n\n## Usage\nBefore you can read or write, you must use `setup()` to open a channel, and must specify whether it will be used for input or output. Having done this, you can then read in the state of the channel or write a value to it using `read()` or `write()`.\n\nAll of the functions relating to the pin state within this module are asynchronous, so where necessary - for example in reading the value of a channel - a callback must be provided. This module inherits the standard [EventEmitter](http://nodejs.org/api/events.html), so you may use its functions to listen to events.\n\n### Pin naming\nPlease be aware that there are multiple ways of referring to the pins on the Raspberry Pi. The simplest and default way to use the module is refer to them by physical position, using the diagrams on [this page](http://elinux.org/RPi_Low-level_peripherals). So holding the Raspberry Pi such that the GPIO header runs down the upper-right side of the board, if you wished to address GPIO4 (which is in column 1 and row 4), you would setup pin 7. If you wish instead to refer to the pins by their GPIO names (known as BCM naming), you can use the `setMode` command described in the API documentation below.\n\n### Running without sudo\nThis module will work without use of the `sudo` command, as long as the user running the node process belongs to the `gpio` group. You can check the current user's groups by running the command `groups`, or `groups <user>` for another user. If you are not already a member of the `gpio` group, you can add yourself or another user by running `sudo adduser <user> gpio`.\n\n\n## API (Error-first)\n\nThe default API uses the node-style error-first callbacks to perform asynchronous functions. Most of these methods take a callback, and that callback should check for an error in its first argument. It is important to check for an error after each command, else your code will continue to run and will likely fail in hard to understand ways.\n\n### Methods\n\n#### setup(channel [, direction, edge], callback)\nSets up a channel for read or write. Must be done before the channel can be used.\n* channel: Reference to the pin in the current mode's schema.\n* direction: The pin direction, pass either DIR_IN for read mode or DIR_OUT for write mode. You can also pass DIR_LOW or DIR_HIGH to use the write mode and specify an initial state of 'off' or 'on' respectively. Defaults to DIR_OUT.\n* edge: Interrupt generating GPIO chip setting, pass in EDGE_NONE for no interrupts, EDGE_RISING for interrupts on rising values, EDGE_FALLING for interrupts on falling values or EDGE_BOTH for all interrupts.\nDefaults to EDGE_NONE.\n* callback: Provides Error as the first argument if an error occurred.\n\n#### read(channel, callback)\nReads the value of a channel.\n* channel: Reference to the pin in the current mode's schema.\n* callback: Provides Error as the first argument if an error occured, otherwise the pin value boolean as the second argument.\n\n#### write(channel, value [, callback])\nWrites the value of a channel.\n* channel: Reference to the pin in the current mode's schema.\n* value: Boolean value to specify whether the channel will turn on or off.\n* callback: Provides Error as the first argument if an error occured.\n\n#### setMode(mode)\nSets the channel addressing schema.\n* mode: Specify either Raspberry Pi or SoC/BCM pin schemas, by passing MODE_RPI or MODE_BCM. Defaults to MODE_RPI.\n\n#### input()\nAlias of read().\n\n#### output()\nAlias of write().\n\n#### destroy()\nTears down any previously set up channels. Should be run when your program stops, or needs to reset the state of the pins.\n\n#### reset()\nTears down the module state - used for testing.\n\n### Events\nSee Node [EventEmitter](http://nodejs.org/api/events.html) for documentation on listening to events.\n\n#### change\nEmitted when the value of a channel changed\n* channel\n* value\n\n## API (Promises)\n\nThis API exposes a Promises interface to the module. All of the same functions are available, but do not take callbacks and instead return a Promise.\n\nThe Promises interface is available in the `promise` namespace, e.g.:\n\n```js\nvar gpio = require('rpi-gpio')\nvar gpiop = gpio.promise;\n\ngpiop.setup(7, gpio.DIR_OUT)\n    .then(() => {\n        return gpiop.write(7, true)\n    })\n    .catch((err) => {\n        console.log('Error: ', err.toString())\n    })\n```\n\n\n## Examples\n\nSee the `examples` directory included in this project.\n\nPlease note that all examples are intended to be directly runnable from the code repository, so they always require the module in at the top using `var gpio = require(../rpi-gpio)`. In reality, you will want to include the module using `var gpio = require('rpi-gpio')`\n\n## Contributing\nContributions are always appreciated, whether that's in the form of bug reports, pull requests or helping to diagnose bugs and help other users on the issues page.\n\nDue to the nature of this project it can be quite time-consuming to test against real hardware, so the automated test suite is all the more important. I will not accept any pull requests that cause the build to fail, and probably will not accept any that do not have corresponding test coverage.\n\nYou can run the tests with npm:\n```\nnpm test\n```\nand create a coverage report with:\n```\nnpm run coverage\n```\nThere is also an integration test that you can run on Raspberry Pi hardware, having connected two GPIO pins across a resistor. The command to run the test will provide further instructions on how to set up the hardware:\n```\nnpm run int\n```\n\nThe tests use [mochajs](http://mochajs.org) as the test framework, and [Sinon.JS](http://sinonjs.org) to stub and mock out file system calls.\n","readmeFilename":"README.md"}