{"id":14978060,"url":"https://github.com/bjoerge/piixel","last_synced_at":"2025-10-28T07:31:17.109Z","repository":{"id":224837950,"uuid":"763177331","full_name":"bjoerge/piixel","owner":"bjoerge","description":"🚥 Control WS281X / NeoPixel LEDs from a Raspberry Pi using Node.js and TypeScript","archived":false,"fork":false,"pushed_at":"2024-11-25T14:39:34.000Z","size":615,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-09T02:47:45.061Z","etag":null,"topics":["led","ledstrip","neopixel","raspberry-pi","rpi-ws281x","sk6812","sk6812rgb","sk6812rgbw","ws2812","ws281x"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bjoerge.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":"2024-02-25T18:52:00.000Z","updated_at":"2024-11-25T14:39:43.000Z","dependencies_parsed_at":"2024-09-18T23:03:06.850Z","dependency_job_id":"fc24784b-16b3-4bac-942a-12aa6b24f676","html_url":"https://github.com/bjoerge/piixel","commit_stats":{"total_commits":38,"total_committers":2,"mean_commits":19.0,"dds":0.02631578947368418,"last_synced_commit":"ae20cee1f23a2cba849d1523ceea2730cfef9c3a"},"previous_names":["bjoerge/piixel"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjoerge%2Fpiixel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjoerge%2Fpiixel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjoerge%2Fpiixel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjoerge%2Fpiixel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bjoerge","download_url":"https://codeload.github.com/bjoerge/piixel/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238614458,"owners_count":19501461,"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":["led","ledstrip","neopixel","raspberry-pi","rpi-ws281x","sk6812","sk6812rgb","sk6812rgbw","ws2812","ws281x"],"created_at":"2024-09-24T13:56:48.302Z","updated_at":"2025-10-28T07:31:16.505Z","avatar_url":"https://github.com/bjoerge.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🚥 piixel\n\n\u003e Control WS281X LEDs from a Raspberry Pi using TypeScript / Node.js\n\nThis is a Node.js / [Node-API](https://nodejs.github.io/node-addon-examples/) wrapper around the [rpi-ws281x](https://github.com/jgarff/rpi_ws281x) library.\n\n### Requirements\n\n- Raspberry Pi (Tested on Raspberry Pi 4 Model B). NOTE: It will **NOT** work on Raspberry Pi 5, see: [jgarff/rpi_ws281x#528](https://github.com/jgarff/rpi_ws281x/issues/528) for details.\n- A WS281X LED Strip, for example one of the many [Adafruit NeoPixels](https://www.adafruit.com/category/168)\n- Node.js v18.x or later\n\n### Installation\n\nNote: This package will only work on a Raspberry Pi.\n\n```sh\nnpm install piixel\n\n# or if you prefer to install it system-wide\nnpm install -g piixel\n```\n\n### Usage\n\nSee [API documentation](./docs/index.md) and the [examples](./examples) directory.\n\n# Minimal Example\n\nThis will light up all LEDs in different colors of the color wheel.\n\n```typescript\n// example.ts\n\nimport {colorwheel, StripType, ws281x} from 'piixel'\n\nconst LEDS = 16\n\n// Configure the library. Must be called before calling `render`.\n// See APIDocs for the full list of options\n// https://github.com/bjoerge/pipixel/blob/main/docs/piixel.ws281xconfig.md\nws281x.configure({\n  gpio: 18,\n  leds: LEDS,\n  type: StripType.WS2811_STRIP_GRB,\n})\n\nconst pixels = new Uint32Array(LEDS)\nfor (let i = 0; i \u003c LEDS; i++) {\n  pixels[i] = colorwheel((i * 256) / LEDS)\n}\n\n// Render pixels to the LED strip\nws281x.render(pixels)\n\n// Optionally, render with brightness\nws281x.render({pixels, brightness: 0.4})\n```\n\nUse ts-node or [tsx](https://github.com/privatenumber/tsx) to run\n\n```sh\ntsx ./example.ts\n```\n\nNote: Depending on which GPIO pin you use, you might need to run the script with `sudo`. See the README of [rpi-ws281x](https://github.com/jgarff/rpi_ws281x?tab=readme-ov-file) for more information.\n\n### Development\n\nSince this library only works on a Raspberry Pi, development on other platforms becomes a bit cumbersome.\nTo make it easier to develop on your local machine, there's a `MOCK_PIIXEL` environment variable that can be set that will mock the hardware module and instead allow you to (optionally) render pixels to the terminal.\n![terminal-mock.gif](terminal-mock.gif)\n\nThe environment variable can be set to the following values:\n- `1` - Enables terminal rendering, and renders all pixels in a single row.\n- `-1` – Enables mocking, but turns off terminal rendering.\n- `n` - Distributes pixels across n rows.\n- `HxW` - Renders pixels in an HxW grid. Any pixel outside the HxW grid will be ignored.\n\nExamples:\n\n- `MOCK_PIIXEL=1 tsx ./my-example.ts` - Renders all pixels in a single row.\n- `MOCK_PIIXEL=8 tsx ./my-example.ts` - Distributes pixels in an 8xN grid.\n- `MOCK_PIIXEL=8x8 tsx ./my-example.ts` - Renders pixels in an 8x8 square. Any pixel outside the 8x8 grid will be ignored.\n- `MOCK_PIIXEL=-1 tsx ./my-example.ts` - Mock the hardware module, but don't render anything to the terminal.\n\n\n### Credits\n\n- Thanks to Jeremy Garff for writing and maintaining the [rpi-ws281x](https://github.com/jgarff/rpi_ws281x) C library.\n\n- This project has taken a lot of inspiration from [meg768/rpi-ws281x](https://github.com/meg768/rpi-ws281x). It originally started as an attempt to make it work on a Raspberry Pi 4b, but I kept running into issues with random memory corruptions, so figured I'd instead write something from scratch using the [Node-API](https://nodejs.github.io/node-addon-examples/), which is more stable and future-proof than the legacy Native Abstractions for Node.js (NAN) used in that module. After the rewrite, the memory corruptions were gone.\n\n### License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbjoerge%2Fpiixel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbjoerge%2Fpiixel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbjoerge%2Fpiixel/lists"}