{"id":19655921,"url":"https://github.com/dislick/wiring-pi-wrapper","last_synced_at":"2025-02-27T02:18:28.699Z","repository":{"id":57398300,"uuid":"55408099","full_name":"dislick/wiring-pi-wrapper","owner":"dislick","description":"Node.js wrapper around wiring-pi written in TypeScript.","archived":false,"fork":false,"pushed_at":"2017-07-05T11:34:49.000Z","size":29,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-23T21:35:35.243Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dislick.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-04T12:06:58.000Z","updated_at":"2017-08-18T08:49:48.000Z","dependencies_parsed_at":"2022-08-29T18:51:59.506Z","dependency_job_id":null,"html_url":"https://github.com/dislick/wiring-pi-wrapper","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dislick%2Fwiring-pi-wrapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dislick%2Fwiring-pi-wrapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dislick%2Fwiring-pi-wrapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dislick%2Fwiring-pi-wrapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dislick","download_url":"https://codeload.github.com/dislick/wiring-pi-wrapper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240964357,"owners_count":19885733,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T15:24:59.157Z","updated_at":"2025-02-27T02:18:28.676Z","avatar_url":"https://github.com/dislick.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# wiring-pi-wrapper\n\nNode.js wrapper around [wiring-pi](https://github.com/eugeneware/wiring-pi) written in TypeScript.\n\n## Usage\n\n`npm install wiring-pi-wrapper --save`\n\n```javascript\nvar wpw = require('wiring-pi-wrapper').WiringPiWrapper;\nvar pinLayout = require('wiring-pi-wrapper').PinLayout;\nvar pinModes = require('wiring-pi-wrapper').PinModes;\nvar ChangeWorker = require('wiring-pi-wrapper').ChangeWorker;\n\n// setup the pin layout\nwpw.setup(pinLayout.wpi);\n\n// write example\nvar pin = wpw.setupPin(3, pinModes.output);\npin.write(true);\n\n// read example\nvar pin = wpw.setupPin(2, pinModes.input);\nvar status = pin.read(); // returns a boolean\n\n// event listener example\nvar pin = wpw.setupPin(2, pinModes.input);\nChangeWorker.interval = 50; // sets the worker interval\npin.addEventListener('change', (status) =\u003e {\n  console.log(status);\n});\n```\n\n## API\n\n### wpw\n\n#### `wpw.setup(mode: wpw.PinLayout)`\n\nMaps directly to the `wiring-pi` `setup()` function. Mode must be one of the following values:\n\n- `PinLayout.wpi`: sets up pin numbering with [`wiringPiSetup()`](https://github.com/eugeneware/wiring-pi/blob/master/DOCUMENTATION.md#wiringpisetup)\n- `PinLayout.gpio`: sets up pin numbering with [`wiringPiSetupGpio()`](https://github.com/eugeneware/wiring-pi/blob/master/DOCUMENTATION.md#wiringpisetupgpio)\n- `PinLayout.sys`: sets up pin numbering with [`wiringPiSetupSys()`](https://github.com/eugeneware/wiring-pi/blob/master/DOCUMENTATION.md#wiringpisetupphys)\n- `PinLayout.phys`: sets up pin numbering with [`wiringPiSetupPhys()`](https://github.com/eugeneware/wiring-pi/blob/master/DOCUMENTATION.md#wiringpisetupsys)\n\nMore information [can be found here](https://github.com/eugeneware/wiring-pi/blob/master/DOCUMENTATION.md#setupmode).\n\n#### `wpw.setupPin(pin: number, mode: wpw.PinModes)`\n\nCreates a new `Pin` object and executes the [`pinMode()`](https://github.com/eugeneware/wiring-pi/blob/master/DOCUMENTATION.md#pinmodepin-mode) function. Mode must be one of the following values:\n\n- `PinModes.input`\n- `PinModes.output`\n\n### Pin\n\n#### `constructor`\n\nThe `Pin` class cannot be instantiated using the `new` keyword. Use `wpw.setupPin()`.\n\n#### `pin.read()`\n\nSynchronously returns the status of the pin as a boolean. Maps to [`digitalRead()`](https://github.com/eugeneware/wiring-pi/blob/master/DOCUMENTATION.md#digitalreadpin).\n\n#### `pin.write(status: boolean)`\n\nSynchronously writes a status to the pin. Maps to [`digitalWrite()`](https://github.com/eugeneware/wiring-pi/blob/master/DOCUMENTATION.md#digitalwritepin-state).\n\n#### `pin.addEventListener(event: string, handler: function)`\n\nBinds one of the following events to the pin:\n\n- `change`: Fires when the status of the pin changes. The `handler` function receives the status as a parameter.\n\n#### `pin.removeEventListener(event: string, handler?: function)`\n\nUnbinds an event listener. If no `handler` function gets passed it removes all registered event listeners of that event.\n\n### ChangeWorker\n\n#### `ChangeWorker.interval`\n\nAllows the user to change the dirty checking interval of the pins.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdislick%2Fwiring-pi-wrapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdislick%2Fwiring-pi-wrapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdislick%2Fwiring-pi-wrapper/lists"}