apa102-pi


Nameapa102-pi JSON
Version 2.5.3 PyPI version JSON
download
home_pageNone
SummaryDriver for APA102 LEDs on a Raspberry Pi
upload_time2024-09-06 08:30:21
maintainerNone
docs_urlNone
authorNone
requires_python>3
licenseNone
keywords apa102 led sk9822 superled dotstar raspberry pi
VCS
bugtrack_url
requirements adafruit-circuitpython-bitbangio adafruit-circuitpython-busdevice
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # apa102-pi

## Introduction
Apa102-pi is a pure Python library to drive APA102 and SK9822 type LED strands. It is supposed to work on a Raspberry
Pi, and is not tested on any other platform.

Be advised that I consider this library to be "done", and don't plan to develop more functionality.
I still monitor the Github page for issues or pull requests, and will release minor updates
from time to time.

APA102 LEDs are typically 5050 type LEDs with an additional driver chip per LED.
The driver chip takes care of receiving the desired colour via its input lines, and then holding
this colour until a new command arrives.

Depending on the LEDs vendor, they might be called "APA102", "SK9822", "Superled", or "DotStar".
They must not be confused with the three-wire WS2812 LEDs, also known as "NeoPixel".

The really nice part about the driver chip is this: Once it has received its own colour command,
it forwards any further colour commands from its input to its output lines.
This allows to easily chain multiple LEDs together. Colour command #1 lights the first LED,
command #2 the next LED, and so forth. Sending for example 300 colour commands does light
an entire 5 Meter, 60 LEDs per Meter strip.

Some APA102 pictures are available [here](https://tinue.github.io/apa102-pi/)

## Purpose
The library takes care of the details on sending colour commands.
It is supposed to be educational, and is therefore written in Python.
The library is fast enough to produce nice colour effects on a 300 LED strand, even though it is running
via the Python interpreter. However, if you need something really fast, e.g. to drive a
small "display" based on APA102 LEDs with 15 frames per second, then you have to look elsewhere.

## Prerequisites
* A Raspberry Pi, running an up-to-date version of Raspbian / Raspberry Pi OS (32 or 64 bit edition). To date, Raspberry 
Pi OS, December 2023 (based on Debian bookworm) is out, and the library works fine with this release. It should run on all
Raspberry Pi models, from Zero to 5. Note that I did not test older models in a long time, so there are no guarantees.
* If hardware SPI is used: SPI enabled and active (`raspi-config`, Interface Options, SPI, \<Yes\>);
The SPI must be free and unused.
* For software SPI (bit bang mode): Two free GPIO pins
* Three libraries from Adafruit: [Adafruit-Blinka](https://github.com/adafruit/Adafruit_Blinka), 
[adafruit-circuitpython-bitbangio](https://github.com/adafruit/Adafruit_CircuitPython_BitbangIO),
and [adafruit-circuitpython-busdevice](https://github.com/adafruit/Adafruit_CircuitPython_BusDevice).
These libraries will be installed automatically if you follow the steps in
[Use the APA102 project as a library](#use-the-apa102-project-as-a-library).

For a permanent installation, a 10$ Raspberry Pi Zero W can be dedicated to the task of driving the LEDs.
The connector to the LED stripe would be soldered directly to the correct ports on the board.
For development purposes, a Raspberry Pi 4 Model B is a better choice due to its greater speed.
Even the 1GB model is more than enough for this purpose.

## Wiring
The Raspberry Pi is a 3.3 volt device, and the APA102 LEDs are 5 volt devices. 
Therefore, it is possible that the first LED driver chip does not properly detect the 3.3 volt SPI signal from
the Raspberry Pi.  
The first chip will amplify the signal to 5 volts before passing it on, so it is really only the first chip
that must detect the 3.3 volt signal.  
To avoid this risk, use a 74AHCT125 or 74AHC125 level shifter for both the clock and the MOSI signal.
In my limited testing with four different strips from various Chinese sources I had no issues without
a level shifter, but your experience might be different.

Without a level shifter, the wiring is very simple:

- LED ground to one of the Raspberry ground pins  
- LED Data to Raspberry SPI MOSI  
- LED Clock to Raspberry SPI SCLK

A note about "chip select": The Raspberry Pi's SPI0 bus has two hardware Chip Select pins: CE0 and CE1. They correspond
to the devices `/dev/spidev0.0` and `/dev/spidev0.1`. A typical SPI device has one Chip Select input line. So, on
a stock Raspberry Pi one can connect two SPI devices: Both share SCLK, MOSI and MISO, and each one uses its own Chip
Select. You might be wondering where the Chip Select input line is on an LED strip. Answer: There is none. You 
therefore can't disable the Strip from reading data on SCLK/MOSI, at least not without additional hardware. For
example, you can wire the chip select GPIO of the Raspberry Pi to the level shifter "output-enable" pin.

The Adafruit library does not use or support the hardware chip select pins of the Raspberry Pi. Instead, any
free GPIO pin can be used. Because this is multiplexed in software, it is very slow. The feature supports
e.g. sensors, where you have a lot of them (more than two), and each sensor only sends or
receives a limited amount of data.  
The apa102-pi library attempts to use this software multiplexing if a CE value is passed on driver initialization.
The strip will update a lot slower if this is used. It is still a bit faster than bitbang, though.
Please note that I have not tested this feature, because I never assembled the hardware required for this.

The LED strip uses a lot of power (roughly 20mA per LED, i.e. 60mA for one bright white dot).
If you try to power the LEDs from the Raspberry Pi 5V output, you will most likely immediately
kill the Raspberry! Therefore, I recommend not to connect the power line of the LED with the Raspberry. 
To be on the safe side, use a separate USB power supply for the Raspberry, and a strong 5V supply 
for the LEDs. If you use a level shifter, power it from the 5V power supply as well.

Having said this, you *can* power the Raspberry from the same power supply as the LED strips
(instead of using an extra USB power supply). If you decide to do this, make sure to never plug
a USB power supply to the Raspberry Pi, or you risk that the LEDs try to take power through the Raspberry.

All combined, this is my extremely low-tech wiring diagram:

![Wiring Diagram](Wiring.jpg)

And here it is, the finished contraption running a "rainbow" program:

![Raspberry Pi Zero driving APA102 LEDs](Finished.jpg)

This is a Raspberry Pi Zero W with a Phat Beat amplifier on top. The amplifier's "VU meter" is simply
a bunch of APA 102 LEDs; They show the "Rainbow" color scheme:

![Raspberry Pi Zero W with Phat Beat](PhatBeat.jpg)

Plugged into the USB port is a WLAN stick (nowadays I use a Raspberry Pi Zero W, of course).
This way I can reprogram the light show from my desk, even if the strips sit outside 
as a Christmas light. Compare this to an Arduino/WS2812 based installation: To reprogram one has
to take the Arduino inside, or a laptop outside.


This is a Raspberry Pi 4 with a 3D RGB Xmas Tree from Pi Hut:

![Raspberry Pi 4 with Xmas tree](xmastree.jpg)

## Quick Raspberry Pi setup
Because the Raspberry Pi Zero runs headless, I recommend using the Raspberry Pi OS *Lite* image.
This image only contains the bare minimum of packages, and some packages have be added manually.

I suggest to use the [Raspberry Pi Imager](https://www.raspberrypi.com/software/) for installation.
This software allows to setup hostname, WiFi and enable SSH without further work. The
Raspberry Pi will run headless from the start, and there is no need to ever connect a display or
a keyboard.

After installation, ssh into the freshly setup Raspberry Pi and install additional packages.
Also, enable SPI:

- Update your installation (`sudo apt update && sudo apt -y upgrade`).
- Install packages: `sudo apt install -y python3-pip python3-venv python3-rpi.gpio`
- Activate SPI: `sudo raspi-config`; Go to "Interface Options"; Go to "SPI"; Enable SPI;
While you are at it: Do change the default password! Exit the tool and reboot.  

## Use the APA102 project as a library
The library was originally built as an educational piece of software. It shows how the protocol
for APA102 LEDs works. Most of this is explained in the form of comments in the source code.
If you are interested in this, then follow up with the chapter after this one.
If all you need is the library itself for your own projects, then this chapter is enough to get you started.

Install the library like this: `sudo pip3 install apa102-pi`. 
This will install the library, and its dependencies for all users. 

Note: If you want to install the library into a virtual env, you must create the venv with the option `--system-site-packages`. This is necessary to get access to the shared RPi.GPIO library.

To verify the installation, download the test script from Github:
`curl https://raw.githubusercontent.com/tinue/apa102-pi/main/runcolorcycle.py -o runcolorcycle.py`.
To run, type `python3 ./runcolorcycle.py`.
 
## Full installation into a Python virtual environment
To retrieve the full library including source code, and use a virtual env in the process, this is what you need to do:
- Install the git client: `sudo apt install -y git`  
- Create a development directory and change into it: `mkdir ~/Development && cd ~/Development`  
- Get the APA102 Library and sample light programs: `git clone https://github.com/tinue/apa102-pi.git && cd apa102-pi`  
- Create the virtual environment: `python3 -m venv --system-site-packages ./venv`
- Activate the virtual env: `source venv/bin/activate`
- Install the dependencies: `python -m pip install .` (this will also install the library itself from the checked out source)
- To remove the just installed library, and use the source code instead, do this: `python -m pip uninstall apa102-pi`
- You might want to set the number of LEDs to match your strip: `nano runcolorcycle.py`; Update the number, Ctrl-X and "Yes" to save.  
- Run the sample lightshow: `./runcolorcycle.py`.

## Full installation using Ansible
If you know [Ansible](https://www.ansible.com), you can use the role `apa102_install` from directory `AnsiblePlaybook`.
This role installs everything that is outlined in the chapter above automatically. Once the role has executed, you can
ssh into the Raspberry Pi, activate the venv and run the sample program.

## Troubleshooting
### Strip remains dark
The number one reason for this problem is that MOSI and SCLK are swapped. You can't rely on the colors of the wires,
they seem to change with every batch of APA102 strips that are produced. To resolve, swap the two data
wires and try again.  
If it still does not work, then you might need a level shifter. Before you do this, you can try to lower the
supply voltage for the strip. According to the APA102 data sheets, a "one" signal is detected as a percentage of
the supply voltage: The lower the supply voltage, the higher the chance that 3.3 Volts is still detected
as a "one".

### Flicker
Sometimes the end of large strips flickers. It seems that there is a correlation amongst three variables:
* SPI bus speed
* Overall brightness of the strip
* Length of the strip

It turns out that you can only have two out of three: On a long, bright strip you will have to lower the bus speed 
significantly.  
Check the apa102.py driver: Default is 8MHz (`BUS_SPEED_HZ = 8000000`). You may have to go as low as 1.5MHz, 
i.e. `BUS_SPEED_HZ = 1500000`. This means that all light programs with lots of updates and zero wait
(e.g. rainbow) will run much slower.

### Brightness
There is a default global brightness value in the driver itself (apa102.py, line 90). Of this parameter, the LED
controller chip interprets only the first 5 bits, snd ignores the rest. Therefore, everything >= 31 is 100% brightness.
The value is set to 1/8th of the maximum (i.e. 8), and can be changed either by patching apa102.py, or by setting
the value from your application. Check `sample.py` to see how this is done.

## Release history
- 1.0.0 (2015-04-13): Initial version
- 1.1.0 (2015-12-04): Add documentation
- 1.1.1 (2015-12-11): Rewrote the examples, driver itself is unchanged
- 1.2.0 (2015-12-17): Fixes for reported problems; Update all of the color samples; Decouple number of steps from number of LEDs
- 1.3.0 (2016-03-25): Merged changes from @kapacuk: Allow strips with different color coding than RGB
- 1.3.1 (2016-03-27): Merged 'rotate' method from @kapacuk; Fixed errors from previous merge
- 1.3.2 (2016-12-25): Fixed error related to 'rotate'; Removed annoying messages on console; Added a debug method
- 1.3.3 (2017-04-14): Merged pull request #19 from @DurandA; Cleanup; Update README.MD, No functional changes
- 1.4.0 (2017-04-16): Update code to better comply with the Python style guide (PEP 8); Merged pull request from @jmb
- 1.4.1 (2017-08-26): Tested with Raspbian Stretch; Update Readme.
- 2.0.0 (2017-11-05): Exchanged the SPI library to Adafruit_Python_GPIO. This allows to support devices that do not use hardware SPI, for example the Pimoroni Blinkt! or the Phat Beat.
- 2.0.1 (2018-01-19): Tiny release: Added a sample
- 2.0.2 (2018-05-25): No change in the driver; Slight restructuring of the templates and schemes to allow easier change of the SPI pins; Additional sample specific to the the Pimoroni Blinkt!
- 2.1.0 (2018-06-08): Make the library installable
- 2.1.1 (2019-03-15): Enable Chip Select (thanks @grandinquisitor); Simplify installation (thanks @nielstron)
- 2.2.0 (2019-03-16): First version that is available on PyPi (pip 3 install); Renamed package for compliancy with PEP 8.
- 2.2.1 (2019-09-20): Nothing new, just a re-test of the library with Raspbian Buster
- 2.3.0 (2019-11-24): Untested fix for SK9822 type LEDs; Fix name space; Update readme. Note: The namespace fix breaks compatibility with the previous version, hence the minor upgrade in the version number.
- 2.4.0 (2020-05-28): SPI: Switch from the deprecated Adafruit_GPIO to the Adafruit CircuitPython libraries; Re-test with Raspberry Pi OS 2020-05-27.
- 2.4.1 (2020-12-04): Remove global brightness parameter from the constructor; Re-test with Raspberry Pi OS 2020-12-02 (kernel 5.4) and latest Adafruit libraries. Fix default global brightness: The "conservative" value of 31 was actually 100%, because this is a 5 bit value. Also changing the branch names in Github to reflect current standards.
- 2.5.0 (2021-12-27): Add methods get_pixel and get_pixel_rgb, support to use all hardware SPI buses on RPI 4 (by explicit choice between hardware spi and bitbanging), thanks @KAN-PC046!  Test with Raspberry Pi OS bullseye and Python 3.9. Add instructions on using a virtual env. Note: The interface changes, so the minor version is getting increased.
- 2.5.1 (2023-01-14): Really tiny release: One bugfix (thanks @leewillis77); Use logging instead of writing to console to reduce output.
- 2.5.2 (2024-01-26): Change in packaging to allow installation via Ansible; no change in the library. Also, re-test with Pi 5 and latest Raspberry Pi OS.
- 2.5.3 (2024-09-06): No change in the library itself. Upgrade Github actions due to security vulnerability; Fix misspelling in readme (thanks @ion-mironov)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "apa102-pi",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">3",
    "maintainer_email": null,
    "keywords": "apa102, led, SK9822, superled, dotstar, raspberry pi",
    "author": null,
    "author_email": "Martin Erzberger <martin@erzberger.ch>",
    "download_url": "https://files.pythonhosted.org/packages/28/22/e4cfa2ef45d240a5217726bc7369cee9e58a9845305763a9b31a7fc43b69/apa102_pi-2.5.3.tar.gz",
    "platform": null,
    "description": "# apa102-pi\n\n## Introduction\nApa102-pi is a pure Python library to drive APA102 and SK9822 type LED strands. It is supposed to work on a Raspberry\nPi, and is not tested on any other platform.\n\nBe advised that I consider this library to be \"done\", and don't plan to develop more functionality.\nI still monitor the Github page for issues or pull requests, and will release minor updates\nfrom time to time.\n\nAPA102 LEDs are typically 5050 type LEDs with an additional driver chip per LED.\nThe driver chip takes care of receiving the desired colour via its input lines, and then holding\nthis colour until a new command arrives.\n\nDepending on the LEDs vendor, they might be called \"APA102\", \"SK9822\", \"Superled\", or \"DotStar\".\nThey must not be confused with the three-wire WS2812 LEDs, also known as \"NeoPixel\".\n\nThe really nice part about the driver chip is this: Once it has received its own colour command,\nit forwards any further colour commands from its input to its output lines.\nThis allows to easily chain multiple LEDs together. Colour command #1 lights the first LED,\ncommand #2 the next LED, and so forth. Sending for example 300 colour commands does light\nan entire 5 Meter, 60 LEDs per Meter strip.\n\nSome APA102 pictures are available [here](https://tinue.github.io/apa102-pi/)\n\n## Purpose\nThe library takes care of the details on sending colour commands.\nIt is supposed to be educational, and is therefore written in Python.\nThe library is fast enough to produce nice colour effects on a 300 LED strand, even though it is running\nvia the Python interpreter. However, if you need something really fast, e.g. to drive a\nsmall \"display\" based on APA102 LEDs with 15 frames per second, then you have to look elsewhere.\n\n## Prerequisites\n* A Raspberry Pi, running an up-to-date version of Raspbian / Raspberry Pi OS (32 or 64 bit edition). To date, Raspberry \nPi OS, December 2023 (based on Debian bookworm) is out, and the library works fine with this release. It should run on all\nRaspberry Pi models, from Zero to 5. Note that I did not test older models in a long time, so there are no guarantees.\n* If hardware SPI is used: SPI enabled and active (`raspi-config`, Interface Options, SPI, \\<Yes\\>);\nThe SPI must be free and unused.\n* For software SPI (bit bang mode): Two free GPIO pins\n* Three libraries from Adafruit: [Adafruit-Blinka](https://github.com/adafruit/Adafruit_Blinka), \n[adafruit-circuitpython-bitbangio](https://github.com/adafruit/Adafruit_CircuitPython_BitbangIO),\nand [adafruit-circuitpython-busdevice](https://github.com/adafruit/Adafruit_CircuitPython_BusDevice).\nThese libraries will be installed automatically if you follow the steps in\n[Use the APA102 project as a library](#use-the-apa102-project-as-a-library).\n\nFor a permanent installation, a 10$ Raspberry Pi Zero W can be dedicated to the task of driving the LEDs.\nThe connector to the LED stripe would be soldered directly to the correct ports on the board.\nFor development purposes, a Raspberry Pi 4 Model B is a better choice due to its greater speed.\nEven the 1GB model is more than enough for this purpose.\n\n## Wiring\nThe Raspberry Pi is a 3.3 volt device, and the APA102 LEDs are 5 volt devices. \nTherefore, it is possible that the first LED driver chip does not properly detect the 3.3 volt SPI signal from\nthe Raspberry Pi.  \nThe first chip will amplify the signal to 5 volts before passing it on, so it is really only the first chip\nthat must detect the 3.3 volt signal.  \nTo avoid this risk, use a 74AHCT125 or 74AHC125 level shifter for both the clock and the MOSI signal.\nIn my limited testing with four different strips from various Chinese sources I had no issues without\na level shifter, but your experience might be different.\n\nWithout a level shifter, the wiring is very simple:\n\n- LED ground to one of the Raspberry ground pins  \n- LED Data to Raspberry SPI MOSI  \n- LED Clock to Raspberry SPI SCLK\n\nA note about \"chip select\": The Raspberry Pi's SPI0 bus has two hardware Chip Select pins: CE0 and CE1. They correspond\nto the devices `/dev/spidev0.0` and `/dev/spidev0.1`. A typical SPI device has one Chip Select input line. So, on\na stock Raspberry Pi one can connect two SPI devices: Both share SCLK, MOSI and MISO, and each one uses its own Chip\nSelect. You might be wondering where the Chip Select input line is on an LED strip. Answer: There is none. You \ntherefore can't disable the Strip from reading data on SCLK/MOSI, at least not without additional hardware. For\nexample, you can wire the chip select GPIO of the Raspberry Pi to the level shifter \"output-enable\" pin.\n\nThe Adafruit library does not use or support the hardware chip select pins of the Raspberry Pi. Instead, any\nfree GPIO pin can be used. Because this is multiplexed in software, it is very slow. The feature supports\ne.g. sensors, where you have a lot of them (more than two), and each sensor only sends or\nreceives a limited amount of data.  \nThe apa102-pi library attempts to use this software multiplexing if a CE value is passed on driver initialization.\nThe strip will update a lot slower if this is used. It is still a bit faster than bitbang, though.\nPlease note that I have not tested this feature, because I never assembled the hardware required for this.\n\nThe LED strip uses a lot of power (roughly 20mA per LED, i.e. 60mA for one bright white dot).\nIf you try to power the LEDs from the Raspberry Pi 5V output, you will most likely immediately\nkill the Raspberry! Therefore, I recommend not to connect the power line of the LED with the Raspberry. \nTo be on the safe side, use a separate USB power supply for the Raspberry, and a strong 5V supply \nfor the LEDs. If you use a level shifter, power it from the 5V power supply as well.\n\nHaving said this, you *can* power the Raspberry from the same power supply as the LED strips\n(instead of using an extra USB power supply). If you decide to do this, make sure to never plug\na USB power supply to the Raspberry Pi, or you risk that the LEDs try to take power through the Raspberry.\n\nAll combined, this is my extremely low-tech wiring diagram:\n\n![Wiring Diagram](Wiring.jpg)\n\nAnd here it is, the finished contraption running a \"rainbow\" program:\n\n![Raspberry Pi Zero driving APA102 LEDs](Finished.jpg)\n\nThis is a Raspberry Pi Zero W with a Phat Beat amplifier on top. The amplifier's \"VU meter\" is simply\na bunch of APA 102 LEDs; They show the \"Rainbow\" color scheme:\n\n![Raspberry Pi Zero W with Phat Beat](PhatBeat.jpg)\n\nPlugged into the USB port is a WLAN stick (nowadays I use a Raspberry Pi Zero W, of course).\nThis way I can reprogram the light show from my desk, even if the strips sit outside \nas a Christmas light. Compare this to an Arduino/WS2812 based installation: To reprogram one has\nto take the Arduino inside, or a laptop outside.\n\n\nThis is a Raspberry Pi 4 with a 3D RGB Xmas Tree from Pi Hut:\n\n![Raspberry Pi 4 with Xmas tree](xmastree.jpg)\n\n## Quick Raspberry Pi setup\nBecause the Raspberry Pi Zero runs headless, I recommend using the Raspberry Pi OS *Lite* image.\nThis image only contains the bare minimum of packages, and some packages have be added manually.\n\nI suggest to use the [Raspberry Pi Imager](https://www.raspberrypi.com/software/) for installation.\nThis software allows to setup hostname, WiFi and enable SSH without further work. The\nRaspberry Pi will run headless from the start, and there is no need to ever connect a display or\na keyboard.\n\nAfter installation, ssh into the freshly setup Raspberry Pi and install additional packages.\nAlso, enable SPI:\n\n- Update your installation (`sudo apt update && sudo apt -y upgrade`).\n- Install packages: `sudo apt install -y python3-pip python3-venv python3-rpi.gpio`\n- Activate SPI: `sudo raspi-config`; Go to \"Interface Options\"; Go to \"SPI\"; Enable SPI;\nWhile you are at it: Do change the default password! Exit the tool and reboot.  \n\n## Use the APA102 project as a library\nThe library was originally built as an educational piece of software. It shows how the protocol\nfor APA102 LEDs works. Most of this is explained in the form of comments in the source code.\nIf you are interested in this, then follow up with the chapter after this one.\nIf all you need is the library itself for your own projects, then this chapter is enough to get you started.\n\nInstall the library like this: `sudo pip3 install apa102-pi`. \nThis will install the library, and its dependencies for all users. \n\nNote: If you want to install the library into a virtual env, you must create the venv with the option `--system-site-packages`. This is necessary to get access to the shared RPi.GPIO library.\n\nTo verify the installation, download the test script from Github:\n`curl https://raw.githubusercontent.com/tinue/apa102-pi/main/runcolorcycle.py -o runcolorcycle.py`.\nTo run, type `python3 ./runcolorcycle.py`.\n \n## Full installation into a Python virtual environment\nTo retrieve the full library including source code, and use a virtual env in the process, this is what you need to do:\n- Install the git client: `sudo apt install -y git`  \n- Create a development directory and change into it: `mkdir ~/Development && cd ~/Development`  \n- Get the APA102 Library and sample light programs: `git clone https://github.com/tinue/apa102-pi.git && cd apa102-pi`  \n- Create the virtual environment: `python3 -m venv --system-site-packages ./venv`\n- Activate the virtual env: `source venv/bin/activate`\n- Install the dependencies: `python -m pip install .` (this will also install the library itself from the checked out source)\n- To remove the just installed library, and use the source code instead, do this: `python -m pip uninstall apa102-pi`\n- You might want to set the number of LEDs to match your strip: `nano runcolorcycle.py`; Update the number, Ctrl-X and \"Yes\" to save.  \n- Run the sample lightshow: `./runcolorcycle.py`.\n\n## Full installation using Ansible\nIf you know [Ansible](https://www.ansible.com), you can use the role `apa102_install` from directory `AnsiblePlaybook`.\nThis role installs everything that is outlined in the chapter above automatically. Once the role has executed, you can\nssh into the Raspberry Pi, activate the venv and run the sample program.\n\n## Troubleshooting\n### Strip remains dark\nThe number one reason for this problem is that MOSI and SCLK are swapped. You can't rely on the colors of the wires,\nthey seem to change with every batch of APA102 strips that are produced. To resolve, swap the two data\nwires and try again.  \nIf it still does not work, then you might need a level shifter. Before you do this, you can try to lower the\nsupply voltage for the strip. According to the APA102 data sheets, a \"one\" signal is detected as a percentage of\nthe supply voltage: The lower the supply voltage, the higher the chance that 3.3 Volts is still detected\nas a \"one\".\n\n### Flicker\nSometimes the end of large strips flickers. It seems that there is a correlation amongst three variables:\n* SPI bus speed\n* Overall brightness of the strip\n* Length of the strip\n\nIt turns out that you can only have two out of three: On a long, bright strip you will have to lower the bus speed \nsignificantly.  \nCheck the apa102.py driver: Default is 8MHz (`BUS_SPEED_HZ = 8000000`). You may have to go as low as 1.5MHz, \ni.e. `BUS_SPEED_HZ = 1500000`. This means that all light programs with lots of updates and zero wait\n(e.g. rainbow) will run much slower.\n\n### Brightness\nThere is a default global brightness value in the driver itself (apa102.py, line 90). Of this parameter, the LED\ncontroller chip interprets only the first 5 bits, snd ignores the rest. Therefore, everything >= 31 is 100% brightness.\nThe value is set to 1/8th of the maximum (i.e. 8), and can be changed either by patching apa102.py, or by setting\nthe value from your application. Check `sample.py` to see how this is done.\n\n## Release history\n- 1.0.0 (2015-04-13): Initial version\n- 1.1.0 (2015-12-04): Add documentation\n- 1.1.1 (2015-12-11): Rewrote the examples, driver itself is unchanged\n- 1.2.0 (2015-12-17): Fixes for reported problems; Update all of the color samples; Decouple number of steps from number of LEDs\n- 1.3.0 (2016-03-25): Merged changes from @kapacuk: Allow strips with different color coding than RGB\n- 1.3.1 (2016-03-27): Merged 'rotate' method from @kapacuk; Fixed errors from previous merge\n- 1.3.2 (2016-12-25): Fixed error related to 'rotate'; Removed annoying messages on console; Added a debug method\n- 1.3.3 (2017-04-14): Merged pull request #19 from @DurandA; Cleanup; Update README.MD, No functional changes\n- 1.4.0 (2017-04-16): Update code to better comply with the Python style guide (PEP 8); Merged pull request from @jmb\n- 1.4.1 (2017-08-26): Tested with Raspbian Stretch; Update Readme.\n- 2.0.0 (2017-11-05): Exchanged the SPI library to Adafruit_Python_GPIO. This allows to support devices that do not use hardware SPI, for example the Pimoroni Blinkt! or the Phat Beat.\n- 2.0.1 (2018-01-19): Tiny release: Added a sample\n- 2.0.2 (2018-05-25): No change in the driver; Slight restructuring of the templates and schemes to allow easier change of the SPI pins; Additional sample specific to the the Pimoroni Blinkt!\n- 2.1.0 (2018-06-08): Make the library installable\n- 2.1.1 (2019-03-15): Enable Chip Select (thanks @grandinquisitor); Simplify installation (thanks @nielstron)\n- 2.2.0 (2019-03-16): First version that is available on PyPi (pip 3 install); Renamed package for compliancy with PEP 8.\n- 2.2.1 (2019-09-20): Nothing new, just a re-test of the library with Raspbian Buster\n- 2.3.0 (2019-11-24): Untested fix for SK9822 type LEDs; Fix name space; Update readme. Note: The namespace fix breaks compatibility with the previous version, hence the minor upgrade in the version number.\n- 2.4.0 (2020-05-28): SPI: Switch from the deprecated Adafruit_GPIO to the Adafruit CircuitPython libraries; Re-test with Raspberry Pi OS 2020-05-27.\n- 2.4.1 (2020-12-04): Remove global brightness parameter from the constructor; Re-test with Raspberry Pi OS 2020-12-02 (kernel 5.4) and latest Adafruit libraries. Fix default global brightness: The \"conservative\" value of 31 was actually 100%, because this is a 5 bit value. Also changing the branch names in Github to reflect current standards.\n- 2.5.0 (2021-12-27): Add methods get_pixel and get_pixel_rgb, support to use all hardware SPI buses on RPI 4 (by explicit choice between hardware spi and bitbanging), thanks @KAN-PC046!  Test with Raspberry Pi OS bullseye and Python 3.9. Add instructions on using a virtual env. Note: The interface changes, so the minor version is getting increased.\n- 2.5.1 (2023-01-14): Really tiny release: One bugfix (thanks @leewillis77); Use logging instead of writing to console to reduce output.\n- 2.5.2 (2024-01-26): Change in packaging to allow installation via Ansible; no change in the library. Also, re-test with Pi 5 and latest Raspberry Pi OS.\n- 2.5.3 (2024-09-06): No change in the library itself. Upgrade Github actions due to security vulnerability; Fix misspelling in readme (thanks @ion-mironov)\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Driver for APA102 LEDs on a Raspberry Pi",
    "version": "2.5.3",
    "project_urls": {
        "Homepage": "https://github.com/tinue/apa102-pi",
        "Issues": "https://github.com/tinue/apa102-pi/issues"
    },
    "split_keywords": [
        "apa102",
        " led",
        " sk9822",
        " superled",
        " dotstar",
        " raspberry pi"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e6e43e07280795c5c0263dfb4ba764d40dea974440f2e04330cffe1424eb38d7",
                "md5": "221058d08f56aaf77bf86da8a24372b9",
                "sha256": "2fbf9b68ca20b568d0cf28216a71a1c2015e24259a80710eda18c43dc034c06d"
            },
            "downloads": -1,
            "filename": "apa102_pi-2.5.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "221058d08f56aaf77bf86da8a24372b9",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">3",
            "size": 24508,
            "upload_time": "2024-09-06T08:30:20",
            "upload_time_iso_8601": "2024-09-06T08:30:20.463121Z",
            "url": "https://files.pythonhosted.org/packages/e6/e4/3e07280795c5c0263dfb4ba764d40dea974440f2e04330cffe1424eb38d7/apa102_pi-2.5.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2822e4cfa2ef45d240a5217726bc7369cee9e58a9845305763a9b31a7fc43b69",
                "md5": "ae7b82da41c8927ef7de176d010364f8",
                "sha256": "6e6a937d94531a4da83c8a7a401599611ccb9994827fe655fffb4fd89d31266a"
            },
            "downloads": -1,
            "filename": "apa102_pi-2.5.3.tar.gz",
            "has_sig": false,
            "md5_digest": "ae7b82da41c8927ef7de176d010364f8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">3",
            "size": 28804,
            "upload_time": "2024-09-06T08:30:21",
            "upload_time_iso_8601": "2024-09-06T08:30:21.869509Z",
            "url": "https://files.pythonhosted.org/packages/28/22/e4cfa2ef45d240a5217726bc7369cee9e58a9845305763a9b31a7fc43b69/apa102_pi-2.5.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-06 08:30:21",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "tinue",
    "github_project": "apa102-pi",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "adafruit-circuitpython-bitbangio",
            "specs": []
        },
        {
            "name": "adafruit-circuitpython-busdevice",
            "specs": []
        }
    ],
    "lcname": "apa102-pi"
}
        
Elapsed time: 1.31218s