Skip to content

Matrix on SPI1 vs SPI0 #221

@jwilts

Description

@jwilts

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:

from luma.led_matrix.device import max7219
from luma.core.interface.serial import spi, noop
from luma.core.render import canvas
from luma.core.virtual import viewport
from luma.core.legacy import text, show_message
from luma.core.legacy.font import proportional, CP437_FONT, TINY_FONT, SINCLAIR_FONT, LCD_FONT

import RPi.GPIO as GPIO
from mfrc522 import SimpleMFRC522

#!/usr/bin/env python
import time 
import RPi.GPIO as GPIO

# Setup gpio
# GPIO.setwarnings(False)
GPIO.setmode (GPIO.BOARD)
GPIO.setup(24,GPIO.OUT)
GPIO.setup(26,GPIO.OUT)

# Turn 8x8 matrix on
GPIO.output(24,GPIO.LOW)

# create matrix device
serial = spi(port=0, device=0, gpio=noop())
device = max7219(serial, cascaded=4, block_orientation=-90)
print("Created device")

show_message(device, "test", fill="white", font=proportional(CP437_FONT), scroll_delay=0.1)

# Turn 8x8 matrix Off
GPIO.output(24,GPIO.HIGH)

# turn RFID reader on
GPIO.output(26,GPIO.LOW)

reader = SimpleMFRC522()

try:
        print("Put RFID on Pad")
        id, text = reader.read()
        print(id)
        print(text)
finally:
        GPIO.cleanup()

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions