{"id":21363152,"url":"https://github.com/firstteam102/lights-rasp-pi","last_synced_at":"2025-07-22T10:37:48.482Z","repository":{"id":248301784,"uuid":"828300949","full_name":"FIRSTTeam102/Lights-Rasp-Pi","owner":"FIRSTTeam102","description":null,"archived":false,"fork":false,"pushed_at":"2024-07-13T18:31:53.000Z","size":403,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-16T07:12:14.859Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FIRSTTeam102.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-07-13T18:00:27.000Z","updated_at":"2024-07-13T18:34:31.000Z","dependencies_parsed_at":"2024-07-13T20:44:06.116Z","dependency_job_id":null,"html_url":"https://github.com/FIRSTTeam102/Lights-Rasp-Pi","commit_stats":null,"previous_names":["firstteam102/lights-rasp-pi"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/FIRSTTeam102/Lights-Rasp-Pi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FIRSTTeam102%2FLights-Rasp-Pi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FIRSTTeam102%2FLights-Rasp-Pi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FIRSTTeam102%2FLights-Rasp-Pi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FIRSTTeam102%2FLights-Rasp-Pi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FIRSTTeam102","download_url":"https://codeload.github.com/FIRSTTeam102/Lights-Rasp-Pi/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FIRSTTeam102%2FLights-Rasp-Pi/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266477152,"owners_count":23935390,"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","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-22T06:18:11.769Z","updated_at":"2025-07-22T10:37:48.455Z","avatar_url":"https://github.com/FIRSTTeam102.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"rpi_ws281x\n==========\n\nUserspace Raspberry Pi library for controlling WS281X LEDs.\nThis includes WS2812 and SK6812RGB RGB LEDs\nPreliminary support is now included for SK6812RGBW LEDs (yes, RGB + W)\nThe LEDs can be controlled by either the PWM (2 independent channels)\nor PCM controller (1 channel) or the SPI interface (1 channel).\n\n### Bindings:\n\nLanguage-specific bindings for rpi_ws281x are available in:\n\n* Python - https://github.com/rpi-ws281x/rpi-ws281x-python\n* Rust - https://github.com/rpi-ws281x/rpi-ws281x-rust\n* Powershell - https://github.com/rpi-ws281x/rpi-ws281x-powershell\n* Java - https://github.com/rpi-ws281x/rpi-ws281x-java\n* CSharp - https://github.com/rpi-ws281x/rpi-ws281x-csharp\n* Go - https://github.com/rpi-ws281x/rpi-ws281x-go\n\n### Background:\n\nThe BCM2835 in the Raspberry Pi has both a PWM and a PCM module that\nare well suited to driving individually controllable WS281X LEDs.\nUsing the DMA, PWM or PCM FIFO, and serial mode in the PWM, it's\npossible to control almost any number of WS281X LEDs in a chain connected\nto the appropriate output pin.\nFor SPI the Raspbian spidev driver is used (`/dev/spidev0.0`).\nThis library and test program set the clock rate to 3X the desired output\nfrequency and creates a bit pattern in RAM from an array of colors where\neach bit is represented by 3 bits as follows.\n\n    Bit 1 - 1 1 0\n    Bit 0 - 1 0 0\n\n\n### GPIO Usage:\n\nThe GPIOs that can be used are limited by the hardware of the Pi and will\nvary based on the method used to drive them (PWM, PCM or SPI).\nBeware that the GPIO numbers are not the same as the physical pin numbers\non the header.\n\nPWM:\n```\n        PWM0, which can be set to use GPIOs 12, 18, 40, and 52.\n        Only 12 (pin 32) and 18 (pin 12) are available on the B+/2B/3B\n\n        PWM1 which can be set to use GPIOs 13, 19, 41, 45 and 53.\n        Only 13 is available on the B+/2B/PiZero/3B, on pin 33\n```\n\nPCM:\n```\n        PCM_DOUT, which can be set to use GPIOs 21 and 31.\n        Only 21 is available on the B+/2B/PiZero/3B, on pin 40.\n```\n\nSPI:\n```\n        SPI0-MOSI is available on GPIOs 10 and 38.\n        Only GPIO 10 is available on all models.\n        See also note for RPi 3 below.\n```\n\n\n### Power and voltage requirements\n\nWS281X LEDs are generally driven at 5V. Depending on your actual\nLED model and data line length you might be able to successfully drive\nthe data input with 3.3V. However in the general case you probably\nwant to use a level shifter to convert from the Raspberry Pi GPIO/PWM to 5V.\n\nIt is also possible to run the LEDs from a 3.3V - 3.6V power source, and\nconnect the GPIO directly at a cost of brightness, but this isn't\nrecommended.\n\nThe test program is designed to drive a 8x8 grid of LEDs e.g.from\nAdafruit (http://www.adafruit.com/products/1487) or Pimoroni\n(https://shop.pimoroni.com/products/unicorn-hat).\nPlease see the Adafruit and Pimoroni websites for more information.\n\nKnow what you're doing with the hardware and electricity.  I take no\nreponsibility for damage, harm, or mistakes.\n\n### Build:\n\n#### Build with SCons:\n\n- Install Scons (on raspbian, `apt-get install scons`).\n- Make sure to adjust the parameters in main.c to suit your hardware.\n  - Signal rate (400kHz to 800kHz).  Default 800kHz.\n  - ledstring.invert=1 if using a inverting level shifter.\n  - Width and height of LED matrix (height=1 for LED string).\n- Type `scons` from inside the source directory.\n\n#### Build and install with CMake:\n\n- Install CMake\n- Configure your build:\n\n  For example:\n  ```\n  mkdir build\n  cd build\n  cmake -D BUILD_SHARED=OFF -D BUILD_TEST=ON ..\n  ```\n  See also for available options in `CMakeLists.txt`.\n- Type `cmake --build .` to build\n- To install built binaries and headers into your system type:\n  ```\n  sudo make install\n  ```\n\n### Running:\n\n- Type `sudo ./test` (default uses PWM channel 0).\n- That's it.  You should see a moving rainbow scroll across the\n  display.\n- More options are available, `./test -h` should show them:\n```\n./test version 1.1.0\nUsage: ./test\n-h (--help)    - this information\n-s (--strip)   - strip type - rgb, grb, gbr, rgbw\n-x (--width)   - matrix width (default 8)\n-y (--height)  - matrix height (default 8)\n-d (--dma)     - dma channel to use (default 10)\n-g (--gpio)    - GPIO to use\n                 If omitted, default is 18 (PWM0)\n-i (--invert)  - invert pin output (pulse LOW)\n-c (--clear)   - clear matrix on exit.\n-v (--version) - version information\n```\n\n### Important warning about DMA channels\n\nYou must make sure that the DMA channel you choose to use for the LEDs is not [already in use](https://www.raspberrypi.org/forums/viewtopic.php?p=609380#p609380) by the operating system.\n\nFor example, **using DMA channel 5 [will cause](https://github.com/jgarff/rpi_ws281x/issues/224) filesystem corruption** on the Raspberry Pi 3 Model B.\n\nThe default DMA channel (10) should be safe for the Raspberry Pi 3 Model B, but this may change in future software releases.\n\n### Limitations:\n\n#### PWM\n\nSince this library and the onboard Raspberry Pi audio\nboth use the PWM, they cannot be used together.  You will need to\nblacklist the Broadcom audio kernel module by creating a file\n`/etc/modprobe.d/snd-blacklist.conf` with\n\n    blacklist snd_bcm2835\n\nIf the audio device is still loading after blacklisting, you may also\nneed to comment it out in the /etc/modules file.\n\nOn headless systems you may also need to force audio through hdmi\nEdit config.txt and add:\n\n    hdmi_force_hotplug=1\n    hdmi_force_edid_audio=1\n\nA reboot is required for this change to take effect\n\nSome distributions use audio by default, even if nothing is being played.\nIf audio is needed, you can use a USB audio device instead.\n\n#### PCM\n\nWhen using PCM you cannot use digital audio devices which use I2S since I2S\nuses the PCM hardware, but you can use analog audio.\n\n#### SPI\n\nWhen using SPI the led string is the only device which can be connected to\nthe SPI bus. Both digital (I2S/PCM) and analog (PWM) audio can be used.\n\nMany distributions have a maximum SPI transfer of 4096 bytes. This can be\nchanged in `/boot/cmdline.txt` by appending\n```\n    spidev.bufsiz=32768\n```\n\nOn an RPi 3 you have to change the GPU core frequency to 250 MHz, otherwise\nthe SPI clock has the wrong frequency.\n\nDo this by adding the following line to /boot/config.txt and reboot:\n\n```\n    core_freq=250\n```\n\nOn an RPi 4 you must set a fixed frequency to avoid the idle CPU scaling changing the SPI frequency and breaking the ws281x timings:\n\nDo this by adding the following lines to /boot/config.txt and reboot:\n\n```\n    core_freq=500\n    core_freq_min=500\n```\n\nSPI requires you to be in the `gpio` group if you wish to control your LEDs\nwithout root.\n\n### Comparison PWM/PCM/SPI\n\nBoth PWM and PCM use DMA transfer to output the control signal for the LEDs.\nThe max size of a DMA transfer is 65536 bytes. Since each LED needs 12 bytes\n(4 colors, 8 symbols per color, 3 bits per symbol) this means you can\ncontrol approximately 5400 LEDs for a single strand in PCM and 2700 LEDs per string\nfor PWM (Only PWM can control 2 independent strings simultaneously)\nSPI uses the SPI device driver in the kernel. For transfers larger than\n96 bytes the kernel driver also uses DMA.\nOf course there are practical limits on power and signal quality. These will\nbe more constraining in practice than the theoretical limits above.\n\nWhen controlling a LED string of 240 LEDs the CPU load on the original Pi 2 (BCM2836) are:\n  PWM  5%\n  PCM  5%\n  SPI  1%\n\n### Usage:\n\nThe API is very simple.  Make sure to create and initialize the `ws2811_t`\nstructure as seen in [`main.c`](main.c).  From there it can be initialized\nby calling `ws2811_init()`.  LEDs are changed by modifying the color in\nthe `.led[index]` array and calling `ws2811_render()`.\nThe rest is handled by the library, which either creates the DMA memory and\nstarts the DMA for PWM and PCM or prepares the SPI transfer buffer and sends\nit out on the MISO pin.\n\nMake sure to hook a signal handler for SIGKILL to do cleanup.  From the\nhandler make sure to call `ws2811_fini()`.  It'll make sure that the DMA\nis finished before program execution stops and cleans up after itself.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffirstteam102%2Flights-rasp-pi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffirstteam102%2Flights-rasp-pi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffirstteam102%2Flights-rasp-pi/lists"}