diff --git a/.github/workflows/pythonpublish.yml b/.github/workflows/pythonpublish.yml index 50769b1..0c562c7 100644 --- a/.github/workflows/pythonpublish.yml +++ b/.github/workflows/pythonpublish.yml @@ -10,7 +10,7 @@ jobs: steps: - uses: actions/checkout@v1 with: - ref: master + ref: main - name: Set up Python uses: actions/setup-python@v1 with: diff --git a/.github/workflows/pythonpublishprerelease.yml b/.github/workflows/pythonpublishprerelease.yml index 4618691..eee0cd3 100644 --- a/.github/workflows/pythonpublishprerelease.yml +++ b/.github/workflows/pythonpublishprerelease.yml @@ -10,7 +10,7 @@ jobs: steps: - uses: actions/checkout@v1 with: - ref: development + ref: develop - name: Set up Python uses: actions/setup-python@v1 with: diff --git a/README.md b/README.md index 02b3ced..074f54e 100644 --- a/README.md +++ b/README.md @@ -27,10 +27,10 @@ via the Python interpreter. However, if you need something really fast, e.g. to 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. To date, Raspberry Pi OS 2020-08-20 +* A Raspberry Pi, running an up-to-date version of Raspbian / Raspberry Pi OS. To date, Raspberry Pi OS 2020-12-02 is out, and the library works fine with this release. It should run on all Raspberry Pi models, from Zero to 4. -* If hardware SPI is used: SPI enabled and active (`raspi-config`, Interfacing Options, SPI, \); +* If hardware SPI is used: SPI enabled and active (`raspi-config`, Interface Options, SPI, \); 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), @@ -131,7 +131,7 @@ Next, install additional packages and enable SPI: - Update your installation (`sudo apt update && sudo apt -y upgrade`). - Install packages: `sudo apt install -y python3-pip python3-rpi.gpio` -- Activate SPI: `sudo raspi-config`; Go to "Interfacing Options"; Go to "SPI"; Enable SPI; +- 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 @@ -144,7 +144,7 @@ Install the library like this: `sudo pip3 install apa102-pi`. This will install the library, and its dependencies for all users. To verify the installation, download the test script from Github: -`curl https://raw.githubusercontent.com/tinue/apa102-pi/master/runcolorcycle.py -o runcolorcycle.py`. +`curl https://raw.githubusercontent.com/tinue/apa102-pi/main/runcolorcycle.py -o runcolorcycle.py`. To run, type `python3 ./runcolorcycle.py`. ## Full installation @@ -170,6 +170,12 @@ Check the apa102.py driver: Default is 8MHz (`BUS_SPEED_HZ = 8000000`). You may 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 @@ -192,4 +198,7 @@ i.e. `BUS_SPEED_HZ = 1500000`. This means that all light programs with lots of u 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-08-31): Remove global brightness parameter from the constructor; Re-test with Raspberry Pi OS 2020-08-20 (kernel 5.7) and latest Adafruit libraries. \ No newline at end of file +- 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. \ No newline at end of file diff --git a/apa102_pi/driver/apa102.py b/apa102_pi/driver/apa102.py index 3da78af..cc974f4 100644 --- a/apa102_pi/driver/apa102.py +++ b/apa102_pi/driver/apa102.py @@ -87,7 +87,7 @@ def __init__(self, num_led=8, order='rgb', mosi=10, sclk=11, ce=None, bus_speed_ self.num_led = num_led order = order.lower() # Just in case someone use CAPS here. self.rgb = RGB_MAP.get(order, RGB_MAP['rgb']) - self.global_brightness = 31 # Use a conservative brightness that should not overload the power supply. + self.global_brightness = 4 # This is a 5 bit value, i.e. from 0 to 31. Conservative 1/8th, change if desired. self.use_bitbang = False # Two raw SPI devices exist: Bitbang (software) and hardware SPI. self.use_ce = False # If true, use the BusDevice abstraction layer on top of the raw SPI device diff --git a/sample.py b/sample.py index 6f45551..6a330a4 100755 --- a/sample.py +++ b/sample.py @@ -6,8 +6,8 @@ # Initialize the library and the strip strip = apa102.APA102(num_led=430, mosi=10, sclk=11, order='rbg') -# Lower the brightness -strip.set_global_brightness(20) +# Increase the brightness to 100% (from the default of 12.5%) +strip.set_global_brightness(31) # Turn off all pixels (sometimes a few light up when the strip gets power) strip.clear_strip() diff --git a/setup.py b/setup.py index b7ebe2f..6d313e7 100755 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="apa102-pi", - version="2.4.0", + version="2.4.1", author="Martin Erzberger", author_email="martin@erzberger.ch", description="Driver for APA102 LEDs on a Raspberry Pi",