{"id":25972043,"url":"https://github.com/szwenni/libgpiod-node-wrapper","last_synced_at":"2026-05-09T19:33:57.975Z","repository":{"id":280712454,"uuid":"942912814","full_name":"szwenni/libgpiod-node-wrapper","owner":"szwenni","description":"libgpiod 2+ node wrapper","archived":false,"fork":false,"pushed_at":"2025-03-04T22:06:10.000Z","size":43,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-04T23:19:40.703Z","etag":null,"topics":["gpio","libgpiod","nodejs","raspberry-pi"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/szwenni.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-04T21:58:24.000Z","updated_at":"2025-03-04T22:07:29.000Z","dependencies_parsed_at":"2025-03-04T23:19:44.057Z","dependency_job_id":"eff2fd7c-1344-4701-9587-ac49f423e47c","html_url":"https://github.com/szwenni/libgpiod-node-wrapper","commit_stats":null,"previous_names":["szwenni/libgpiod-node-wrapper"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szwenni%2Flibgpiod-node-wrapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szwenni%2Flibgpiod-node-wrapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szwenni%2Flibgpiod-node-wrapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szwenni%2Flibgpiod-node-wrapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/szwenni","download_url":"https://codeload.github.com/szwenni/libgpiod-node-wrapper/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241940765,"owners_count":20045931,"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":["gpio","libgpiod","nodejs","raspberry-pi"],"created_at":"2025-03-05T00:18:56.906Z","updated_at":"2026-05-09T19:33:52.925Z","avatar_url":"https://github.com/szwenni.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DISCLAIMER\n\nThis library is a work in progress.\nIt may have bugs, and it may not follow the best practices for a library.\n\nPlease report any issues you find, and help me improve the library by submitting pull requests or at least a issue. I'm not forcing anybody to use any template for a issue, just describe the bug and the output you are getting. Pull request is always better, you know it :)\n\nI'm not responsible for any damage caused by using this library. Use with caution, but I was not able to break anything till now.\n\n\n# libgpiod2-node-wrapper\n\nA Node.js wrapper for the libgpiod 2 C++ API. This library provides an easy-to-use interface for GPIO manipulation on Linux systems, similar to the [onoff](https://www.npmjs.com/package/onoff) library but using the modern libgpiod 2 API.\n\n## Requirements\n\n- Node.js \u003e= 16.0.0\n- libgpiod 2+ development headers\n- A C++ compiler compatible with C++17\n\n## Installation\n\n```bash\n# Install libgpiod development headers (on Debian/Ubuntu)\nsudo apt-get install libgpiod-dev\n\n# Install the package (not wokrking currently as I did not publish anything)\nnpm install libgpiod2-node\n```\n\n## Usage\n\n```typescript\nimport { Chip, Direction, Edge, Value, LineConfig, LineRequest } from 'libgpiod2-node';\n\n// Discover available GPIO chips\nconst chipPaths = Chip.getChips();\nconsole.log('Available chips:', chipPaths);\n\n// Open GPIO chip\nconst chip = new Chip('gpiochip0');\nconsole.log(`Chip label: ${chip.label}`);\nconsole.log(`Number of lines: ${chip.numLines}`);\n\n// Get information about a line without exporting it\nconst lineInfo = chip.getLineInfo(17);\nconsole.log('Line info:', lineInfo);\n\n// Configure GPIO line for output\nconst led = chip.getLine(17);\nled.setDirection(Direction.OUTPUT);\nled.setValue(Value.HIGH);\n\n// Configure GPIO line for input with interrupt\nconst button = chip.getLine(27);\nbutton.setDirection(Direction.INPUT);\nbutton.setEdge(Edge.BOTH);\n\n// Watch for button changes\nbutton.watch((err, value) =\u003e {\n  if (err) {\n    console.error('Error:', err);\n    return;\n  }\n  console.log('Button value changed to:', value);\n  \n  // Toggle LED when button is pressed\n  if (value === Value.HIGH) {\n    const currentValue = led.getValue();\n    led.setValue(currentValue === Value.HIGH ? Value.LOW : Value.HIGH);\n  }\n});\n\n// Example of configuring multiple lines with different settings\nfunction configureMultipleLines() {\n  // Create a line configuration\n  const config = new LineConfig();\n  \n  // Configure line 5 as output\n  config.setOffset(5);\n  config.setDirection(Direction.OUTPUT);\n  config.setDrive(Drive.PUSH_PULL);\n  config.setOutputValue(Value.HIGH);\n  \n  // Configure line 6 as input with pull-up and edge detection\n  config.setOffset(6);\n  config.setDirection(Direction.INPUT);\n  config.setBias(Bias.PULL_UP);\n  config.setEdge(Edge.BOTH);\n  \n  // Request both lines at once\n  const request = new LineRequest(chip, [5, 6], config);\n  \n  // Now you can interact with both lines through the request object\n  console.log(`Line 6 value: ${request.getValue(6)}`);\n  request.setValue(5, Value.LOW);\n  \n  // Remember to release when done\n  request.release();\n}\n\n// Remember to clean up when done\nprocess.on('SIGINT', () =\u003e {\n  console.log('Cleaning up...');\n  button.unwatch();\n  button.unexport();\n  led.unexport();\n  chip.close();\n  process.exit(0);\n});\n```\n\n## API\n\n### Chip\n\n- `new Chip(name: string)` - Open a GPIO chip by name\n- `getLine(offset: number)` - Get a GPIO line by offset\n- `close()` - Close the chip\n- `getChips()` - Get a list of available GPIO chip paths\n- `label` - Get the label of the chip\n- `numLines` - Get the number of lines on the chip\n- `getLineInfo(offset: number)` - Get information about a line without exporting it\n\n### Line\n\n- `setDirection(direction: Direction)` - Set line direction (INPUT or OUTPUT)\n- `setValue(value: Value)` - Set line value (HIGH or LOW)\n- `getValue()` - Get current line value\n- `setEdge(edge: Edge)` - Set edge detection (NONE, RISING, FALLING, or BOTH)\n- `watch(callback: (err: Error | null, value: Value) =\u003e void)` - Watch for value changes\n- `unwatch()` - Stop watching for changes\n- `unexport()` - Release the line\n\n### LineConfig\n\n- `setOffset(offset: number)` - Set the offset for which subsequent configuration will apply\n- `setDirection(direction: Direction)` - Set line direction\n- `setEdge(edge: Edge)` - Set edge detection\n- `setBias(bias: Bias)` - Set line bias\n- `setDrive(drive: Drive)` - Set line drive\n- `setActiveLow(activeLow: boolean)` - Set active low\n- `setOutputValue(value: Value)` - Set initial output value\n\n### LineRequest\n\n- `new LineRequest(chip: Chip, offsets: number[], config: LineConfig)` - Create a new LineRequest instance\n- `getValue(offset: number)` - Get value of a requested line\n- `setValue(offset: number, value: Value)` - Set value of a requested line\n- `release()` - Release all requested lines\n\n### Enums\n\n- `Direction`: INPUT, OUTPUT\n- `Value`: LOW, HIGH\n- `Edge`: NONE, RISING, FALLING, BOTH\n- `Bias`: UNKNOWN, DISABLED, PULL_UP, PULL_DOWN\n- `Drive`: PUSH_PULL, OPEN_DRAIN, OPEN_SOURCE\n\n## License\n\nLGPL-2.1\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fszwenni%2Flibgpiod-node-wrapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fszwenni%2Flibgpiod-node-wrapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fszwenni%2Flibgpiod-node-wrapper/lists"}