Closed Lee-Stratford closed 1 year ago
Is it bitbang or hardware SPI that you want to use? Also, I think you use the API the"old" way, and this no longer works. For SPI bus 1 (2nd bus), you would use: strip = apa102.APA102(num_led=5, spi_bus=1)
I can't test at the moment, but I think with the above initialisation it should work.
Hi
Thank you for your reply.
I am using Hardware SPI port 1 mosi & sclk connected to pins 38 & 40 of the GPIO on the RPi4. I am using a SSD1322 OLED on SPI port 0.
Config.txt contains
dtoverlay=spi1-1cs
Listing available SPI ports
ls /dev/spi*
/dev/spidev0.0 /dev/spidev0.1 /dev/spidev1.0
I have tried
strip = apa102.APA102(num_led=5, spi_bus=1)
But Python spits out an error
strip = apa102.APA102(num_led=10,spi_bus=1) # Initialize the library and the strip
File "/usr/local/lib/python3.9/dist-packages/apa102_pi/driver/apa102.py", line 104, in init
self.check_input(bus_method, global_brightness, mosi, num_led, order, sclk, spi_bus, spi_ports)
File "/usr/local/lib/python3.9/dist-packages/apa102_pi/driver/apa102.py", line 163, in check_input
raise ValueError("Illegal spi_bus not in %s" % list(spi_ports))
ValueError: Illegal spi_bus not in [0, 6, 2, 3, 4, 5]
I have uninstalled the library using ‘sudo pip3 uninstall apa102-pi’ and reinstalled using ‘sudo pip3 install apa102-pi’, but still get the same error above. If I use mosi=20, sclk=21 instead of ‘spi_bus=1’ it should work?
Best Regards
Lee
From: Martin @.> Sent: 31 May 2022 15:53 To: tinue/apa102-pi @.> Cc: Lee-Stratford @.>; Author @.> Subject: Re: [tinue/apa102-pi] Bit Banging Not Working (Issue #52)
Is it bitbang or hardware SPI that you want to use? Also, I think you use the API the"old" way, and this no longer works. For SPI bus 1 (2nd bus), you would use: strip = apa102.APA102(num_led=5, spi_bus=1)
I can't test at the moment, but I think with the above initialisation it should work.
— Reply to this email directly, view it on GitHub https://github.com/tinue/apa102-pi/issues/52#issuecomment-1142241653 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AL42EWWEEXVOQ7KMB2XTZODVMYRUJANCNFSM5XLMIDOQ . You are receiving this because you authored the thread. https://github.com/notifications/beacon/AL42EWTB4TSD5HY6TX5SXFDVMYRUJA5CNFSM5XLMIDO2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOIQKTS5I.gif Message ID: @.***>
Can't say I understand it, but when I check the source code of the Adafruit library that lies underneath of apa102-pi, it appears that you need to use spi_bus number 6 for pins 38/40. Please give this a try. It's most likely a typo in their library...
I tried it and got the same result. Also tried everything between 0 – 6 but just get
OS error: /dev/spidev2.0 does not exist etc
Regards
Lee
From: Martin @.> Sent: 31 May 2022 19:06 To: tinue/apa102-pi @.> Cc: Lee-Stratford @.>; Author @.> Subject: Re: [tinue/apa102-pi] Bit Banging Not Working (Issue #52)
Can't say I understand it, but when I check the source code of the Adafruit library that lies underneath of apa102-pi, it appears that you need to use spi_bus number 6 for pins 38/40. Please give this a try. It's most likely a typo in their library...
— Reply to this email directly, view it on GitHub https://github.com/tinue/apa102-pi/issues/52#issuecomment-1142449835 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AL42EWVJ5LUSGP3IVFV7MJLVMZIIBANCNFSM5XLMIDOQ . You are receiving this because you authored the thread. https://github.com/notifications/beacon/AL42EWSU6OFFEKXIANFJUSLVMZIIBA5CNFSM5XLMIDO2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOIQMGNKY.gif Message ID: @.***>
I fixed the typo in the Adafruit library, and now it's working on SPI bus 1. If I get to it I'll raise a pull request with them to get it fixed.
In the meantime, the file to edit is:
.venv/lib/python3.9/site-packages/adafruit_blinka/microcontroller/bcm2711/pin.py
That is if you installed as recommended into a virtual env. Otherwise you will have to find the file by yourself.
At the end of the file you will see the spiPorts definition. Simply change the 6 to a 1 and save.
Hi
Great, I will have a play as I’m not really a Python programmer, just a basic noob lol but know my way around.
I’m surprised that this issue hasn’t been picked up beforehand. I’d be grateful if you could raise the issue with Adafruit and get them to sort it out.
Many Thanks for helping 😊
Lee
From: Martin @.> Sent: 31 May 2022 20:14 To: tinue/apa102-pi @.> Cc: Lee-Stratford @.>; Author @.> Subject: Re: [tinue/apa102-pi] Bit Banging Not Working (Issue #52)
I fixed the typo in the Adafruit library, and now it's working on SPI bus 1. If I get to it I'll raise a pull request with them to get it fixed. In the meantime, the file to edit is: .venv/lib/python3.9/site-packages/adafruit_blinka/microcontroller/bcm2711/pin.py
That is if you installed as recommended into a virtual env. Otherwise you will have to find the file by yourself.
At the end of the file you will see the spiPorts definition. Simply change the 6 to a 1 and save.
— Reply to this email directly, view it on GitHub https://github.com/tinue/apa102-pi/issues/52#issuecomment-1142546920 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AL42EWWK2IYXRYLE2FSXWFTVMZQI3ANCNFSM5XLMIDOQ . You are receiving this because you authored the thread. https://github.com/notifications/beacon/AL42EWVBPI6G2DFAIZ42CDDVMZQI3A5CNFSM5XLMIDO2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOIQM6D2A.gif Message ID: @. @.> >
Bingo! got it working on SPI1 after changing pin.py 😊
Just one thing, I keep getting ‘Use hardware SPI’ displayed in the Python Shell. Is there anyway of disabling this notification?
Best Regards
Lee
From: Martin @.> Sent: 31 May 2022 20:14 To: tinue/apa102-pi @.> Cc: Lee-Stratford @.>; Author @.> Subject: Re: [tinue/apa102-pi] Bit Banging Not Working (Issue #52)
I fixed the typo in the Adafruit library, and now it's working on SPI bus 1. If I get to it I'll raise a pull request with them to get it fixed. In the meantime, the file to edit is: .venv/lib/python3.9/site-packages/adafruit_blinka/microcontroller/bcm2711/pin.py
That is if you installed as recommended into a virtual env. Otherwise you will have to find the file by yourself.
At the end of the file you will see the spiPorts definition. Simply change the 6 to a 1 and save.
— Reply to this email directly, view it on GitHub https://github.com/tinue/apa102-pi/issues/52#issuecomment-1142546920 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AL42EWWK2IYXRYLE2FSXWFTVMZQI3ANCNFSM5XLMIDOQ . You are receiving this because you authored the thread. https://github.com/notifications/beacon/AL42EWVBPI6G2DFAIZ42CDDVMZQI3A5CNFSM5XLMIDO2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOIQM6D2A.gif Message ID: @.***>
Good to hear. Adafruit accepted by pull request a long time ago. Possibly if you get their latest version of the library, the issue is gone without patching. About the "hardwares pi": Please check the "debug" branch. The output will not be there.
This should no longer be an issue, because the Adafruit libraries have been updated.
Hi
I'm having problems driving APA102 LED using the second SPI port (GPIO20 (pin 38) & GPIO21 (pin 40)) on a Raspberry Pi 4 v1.4 using Bullseye OS 64 bit. Second SPI port activated in config.txt as dtoverlay=spi1-1cs.
I used to be able to use the second SPI port on previous versions of Raspian (not used APA102 in quite a while now), but now I can't.
I changed the mosi and sclk to use the second SPI port, but it ignores the bit banging and uses the first SPI port (GPIO10 & GPIO11) instead.
strip = apa102.APA102(num_led=5, mosi=20, sclk=21, order='rgb') # Initialize the library and the strip strip.set_global_brightness(2) strip.clear_strip()
Does anyone else have this problem?
Lee