Open jwilts opened 4 years ago
Hi
I want to use my LED Matrix to display the temp of a MAX6675 Module with a Thermocouple. The MAX6675 will use SPI0 and I need to have the LED Matrix using SPI1. I've been trying to figure this out can you help?
Thanks
luma.core.interface.serial
has a peripheral method by bitbang as SPI. This is the only way I see that can solve this problem without the help of the maintainers or contributors who seem to be either no longer active or have abandoned the library.
Instead of defining a serial object as you would normally do:
from luma.core.interface.serial import spi
...
'serial = spi(port=0, device=0, gpio_DC=23, gpio_RST=24)',
Now you do it like this:
from luma.core.interface.serial import bitbang
...
'serial = bitbang(SCLK=21, SDA=20, CE=16, DC=23, RST=24)',
Please note that the bitbanging method is slower, as the interface is via software, but the advantage is that you can use any of your unused GPIO pins.
If you need more information, check the docsting of the bitbang class: https://github.com/rm-hull/luma.core/blob/master/luma/core/interface/serial.py#L148
Ok, I found a way to use SPI1.
First check if you have SPI1 enabled. This is done in the terminal with the command ls -l /dev/spi*
.
All SPI ports and devices should be displayed. If SPI1 is enabled, you should see at least one that says /dev/spidev1.*.
If not, it is necessary to activate it. In the terminal type sudo nano /boot/config.txt
. To the end of the text document add dtoverlay=spi1-1cs
, then press ctrl+s to save and ctrl+x to exit. For the changes to take effect, it is necessary to reboot with sudo reboot
.
The default SPI1 pins are as follows:
If you wish, you can also change the pin of CS0 by adding ,cs0_pin=<pin#>
to the line
now check again if SPI1 is already there with ls -l /dev/spi*
.
you should see at least one line ending in /dev/spi1.*.
see that the format is spiP.D.
in the spi object, in the port parameter you will put P (in this case 1 of SPI1) and in device you will put D (as in this example we only enable 1 CS, the value is 0).
from luma.core.interface.serial import spi
...
'serial = spi(port=1, device=0, gpio_DC=23, gpio_RST=24)',
References: https://github.com/rm-hull/luma.examples/issues/78 https://raspberrypi.stackexchange.com/questions/73346/how-to-enable-spi1-and-spi0-at-the-same-time#73844 https://blog.stabel.family/raspberry-pi-4-multiple-spis-and-the-device-tree/
Hi this is a bit of a Noob Question but I am hoping that you can give me some direction on how to configure the matrix to run on SPI1 instead of SPI0
I have the same problem on both a Raspberry Pi3 and and PiZero W.
Type of Raspberry Pi
Pi 3 and Pi zero
Linux Kernel version
I am running 4.18.97-v7+ #1294 as my kernel.
Expected behaviour
I am able to get the Max7219 8x8 matrix working properly, however I need to add another SPI device (RC422 RFID Reader) and the two do not seem to want to work sharing the CS pin (pin 24). (Text on the Max7219 gets garbled and stilted and theRC422 does not work) From my research (and limited knowledge) I understand that I should be able to move to CS1 (PIN 26) and this in theory should solve my issue.
I am using this as my initialization code for the Max7219:
Actual behaviour
I have tried changing port=1, and device=1 but neither results in anything appearing on the matrix.
port=1 ==> "SPI Device Not Found" device=1 ==> No error raised, but matrix does not update.
Edit -- I have continued to try to get this working (without any success) I understand that I have to toggle the value on CS to LOW for any SPI device that I want to activate. I have tried manually forcing the GPIO to high and low between the RC522 and the Max7219 but that doesn't appear to do anything.
Anyone who can help with this problem I would be extremely grateful as I am stumped on my project until I can get past this blocking issue.