circuitpython: RGB Matrix content not displaying correctly on CircuitPython 8.2.3
CircuitPython version
Working:
Adafruit CircuitPython 8.2.2 on 2023-07-31; Adafruit Grand Central M4 Express with samd51p20
Board ID:grandcentral_m4_express
Not working:
Adafruit CircuitPython 8.2.3 on 2023-08-11; Adafruit Grand Central M4 Express with samd51p20
Board ID:grandcentral_m4_express
UF2 Bootloader v3.15.0 SFHWRO
Model: Grand Central M4 Express
Board-ID: SAMD51P20A-GrandCentral-v0
adafruit-circuitpython-bundle-8.x-mpy-20230824
Code/REPL
import displayio
import rgbmatrix
import board
import framebufferio
from adafruit_bitmap_font import bitmap_font
from adafruit_display_text.label import Label
import digitalio
import busio
import sdcardio
import storage
import adafruit_debouncer
displayio.release_displays()
matrix = rgbmatrix.RGBMatrix(
width=64,
height=32,
bit_depth=4,
rgb_pins=[board.D8, board.D9, board.D10, board.D11, board.D12, board.D13],
addr_pins=[board.D4, board.D6, board.D3, board.D5],
clock_pin=board.D1,
latch_pin=board.D2,
output_enable_pin=board.D0
)
display = framebufferio.FramebufferDisplay(matrix)
font = bitmap_font.load_font("/fonts/test.pcf")
mg = displayio.Group()
mg_a = Label(font, text="A.A.A.A", color=0x00FF00, x=15, y=6)
mg_h = Label(font, text="H.H.H.H", color=0x00FF00, x=14, y=17)
mg_b = Label(font, text="B.B.B.B", color=0x00FF00, x=15, y=28)
mg.append(mg_a)
mg.append(mg_h)
mg.append(mg_b)
class HiscoreController:
def __init__(self):
spi = busio.SPI(board.SD_SCK, board.SD_MOSI, board.SD_MISO)
sdcard = sdcardio.SDCard(spi, board.SD_CS)
vfs = storage.VfsFat(sdcard)
storage.mount(vfs, "/")
def hiscore(self, value=-1):
if value >= 0:
try:
with open("/hiscore.txt", "w") as hiscore_file:
if value > 9999:
hiscore_file.write(str(value - 10000))
else:
hiscore_file.write(str(value))
except OSError:
pass
else:
if "hiscore.txt" in os.listdir("/"):
try:
with open("/hiscore.txt", "r") as hiscore_file:
score = hiscore_file.read()
return score
except OSError:
pass
class ButtonController:
def __init__(self, btns_and_names):
self.buttons = {}
for name, btn in btns_and_names.items():
button_pin = digitalio.DigitalInOut(btn["obj"])
button_pin.switch_to_input(pull=digitalio.Pull.UP)
self.buttons[name] = adafruit_debouncer.Debouncer(button_pin)
def is_pressed(self, btn_name):
return self.buttons[btn_name].fell
def reset(self):
for btn in self.buttons.values():
btn.update()
def update(self):
for btn in self.buttons.values():
btn.update()
hiscore_ctrl = HiscoreController()
buttons = ButtonController(
btns_and_names = {
"reset": {"num": 1, "obj": board.D27}
}
)
def menu(screen_state):
reset = False
display.show(mg)
buttons.reset()
while screen_state == menu:
buttons.update()
if buttons.is_pressed("reset"):
hiscore_ctrl.hiscore(value=0)
reset = True
screens = {
menu: menu
}
screen_state = menu
while True:
current_screen = screens[screen_state]
screen_state = current_screen(screen_state)
Behavior
When I run CircuitPython 8.2.2, the RGB Matrix displays content correctly.
https://github.com/adafruit/circuitpython/assets/22541984/74018af0-e5d5-4bdc-997f-600f1dd09850
When I run CircuitPython 8.2.3, the RGB Matrix displays content incorrectly.
https://github.com/adafruit/circuitpython/assets/22541984/d46d3e68-794c-4598-8ccc-62a310ed17ae
Description
No response
Additional information
No response
About this issue
- Original URL
- State: closed
- Created 10 months ago
- Comments: 44 (1 by maintainers)
I encountered an issue that sounded similar, but wasn’t. I wanted to document my issue for anyone who stumbles upon this thread.
Issue: I’m working with a Metro ESP32-S2 and the Adafruit RGB Matrix Shield. I had a pretty easy time getting a 32x64 matrix up and running, but ran into issues later on in the development process. I found that running code.py worked just fine, but when I dropped into the REPL, I wound up with white lines across my screen when I called
displayio.release_displays()
and couldn’t connect to the matrix after that. When I restarted the board, my code.py was able to run the matrix with no issues.Solution: Once you’ve created an instance of
rgbmatrix.RGBMatrix
, you can’t create another. Don’t forget that if your code.py sets up an RGBMatrix before you can get into the REPL, you’re not going to be able to create a new one yourself. I suspect that re-initializing all the pins might fix things, but if all else fails, try deleting or altering your code.py and try again.@dhalbert & @jepler just wanted to update you that I tried the latest Circuit Python version 9 and the matrix worked with the sample 2 line scrolling but when I used my code I ended getting memory allocation errors, understanding that its in beta, will check back in other revisions. In my instance currently the only solution still is to use adafruit-circuitpython-grandcentral_m4_express-en_GB-8.2.2.uf2
fwiw I received a feedback on Learn that some RGB Matrix project, possibly the “two line” scroller isn’t working in any stable version since 8.2.2:
The feedback did not give information about what specific boards/products were used, so it’s impossible to know if this is the “sigh, doesn’t look like it’s going to work, but we don’t understand why” problem on some boards without level shifting, or whether it’s something else.
I will close this because it seems the problem is fundamentally missing level-shifting. @phantomsixthplayer thanks for all your testing.
I think the new/old matrix thing is a red herring. We can try to make the duty cycle configurable. We can try to boost the drive strength. But without level shifting, all that might seem like it’s fixed, but the temperature swings 20 degrees and things inexplicably go haywire because it was all a lucky edge case.
Scope trace, special CircuitPython build:
Same, Arduino lib 1.6.2:
The timing is identical, down to the clock cycle, even the every-8th-bit delay. I cannot explain why this would work with the Arduino library and not with CircuitPython built against the same code and generating the same clock signal, and on the same hardware. Defies all explanation. I am out of ideas and probably unfit for my job.
OOF, quite right. I apologize, had my wires (figuratively) crossed. Writing the Grand Central CircuitPython 8.2.2 or 8.2.5 firmware should revive it, it’ll just still have the wonky matrix timing until we have an updated version for that board.