Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Displaying External BMPs on the RGB Matrix is resulting in Safe Mode #3184

Closed
makermelissa opened this issue Jul 21, 2020 · 5 comments · Fixed by #3344
Closed

Displaying External BMPs on the RGB Matrix is resulting in Safe Mode #3184

makermelissa opened this issue Jul 21, 2020 · 5 comments · Fixed by #3344

Comments

@makermelissa
Copy link
Collaborator

makermelissa commented Jul 21, 2020

I'm using a Metro M4 WiFi and the RGB Matrix Shield w/ bodge wire. I wrote a simple script that displays a bitmap using the usual displayio method and after a few seconds, it goes into safe mode. I have tried on both latest stable and alpha with the same result.

@makermelissa makermelissa changed the title Displaying External Bs on the RGB Matrix is resulting in Safe Mode Displaying External BMPs on the RGB Matrix is resulting in Safe Mode Jul 21, 2020
@makermelissa
Copy link
Collaborator Author

I noticed using a small palette bitmap doesn't seem to result in this issue, so maybe it's a memory thing.

@makermelissa
Copy link
Collaborator Author

This more specifically happens when bit_depth is 3 or higher.

@jepler
Copy link
Member

jepler commented Jul 23, 2020

Can you send me a complete example? Is it possible this affects only airlift? Here's the example I cooked up based on your description. However, I didn't get any crashes (tested with 5.3.1, 6.0.0-alpha.1, and latest on metro m4 non-airlift):

import board
import displayio
import digitalio
import framebufferio
import rgbmatrix

displayio.release_displays()

for a in [board.A0, board.A1, board.A2, board.A3]:
    d = digitalio.DigitalInOut(a)
    with d:
        d.switch_to_output(True)
    
matrix = rgbmatrix.RGBMatrix(
    width=64,
    height=32,
    bit_depth=5,
    rgb_pins=[board.D2, board.D3, board.D4, board.D5, board.D6, board.D7],
    addr_pins=[board.A0, board.A1, board.A2, board.A3],
    clock_pin=board.A4,
    latch_pin=board.D10,
    output_enable_pin=board.D9,
)

# Wait for the image to load.
display = framebufferio.FramebufferDisplay(matrix)
f = open("/emoji.bmp", "rb")
b1 = displayio.OnDiskBitmap(f)
tg1 = displayio.TileGrid(b1, pixel_shader=displayio.ColorConverter())
g1 = displayio.Group(max_size=3) 
g1.append(tg1)
display.show(g1)
display.refresh()
print("we got to the loop")
while True:
    pass

note also that I didn't hook up a display.

Here's a zip of the bmp I used:
emoji.zip

@makermelissa
Copy link
Collaborator Author

Try this and wait like 30 seconds:

import board
import displayio
import framebufferio
import rgbmatrix
import terminalio

displayio.release_displays()
matrix = rgbmatrix.RGBMatrix(
    width=64, height=32, bit_depth=4,
    rgb_pins=[board.D2, board.D3, board.D4, board.D5, board.D6, board.D7],
    addr_pins=[board.A0, board.A1, board.A2, board.A3],
    clock_pin=board.A4, latch_pin=board.D10, output_enable_pin=board.D9)
display = framebufferio.FramebufferDisplay(matrix, auto_refresh=False)

splash = displayio.Group(max_size=15)
display.show(splash)
        
bg_sprite = displayio.TileGrid(
    displayio.OnDiskBitmap(open("red.bmp", "rb")),
    pixel_shader=displayio.ColorConverter(),
    x=0,
    y=0,
)

splash.append(bg_sprite)
display.refresh(target_frames_per_second=60)

while True:
    pass

Here's the bitmap I used
red.bmp.zip

This could be related to lighting up the fullscreen or something.

@makermelissa
Copy link
Collaborator Author

It could be related to the target_frames_per_second=60. I removed that from my MatrixPortal library and I can get it working solidly at bit_depth=3, but it still fails on 4.

@jepler jepler added this to the 6.x.x - Bug Fixes milestone Aug 9, 2020
jepler added a commit to jepler/Adafruit_Protomatter that referenced this issue Aug 28, 2020
When _PM_begin fails, it leaves the object in a partially-uninitialized
state.  To recover any allocated storage, we need to call _PM_free;
but if the allocation of core->screenData failed, then other internal
pointers such as core->oe.setReg are not set, and the actions in
_PM_stop will cause a HardFault.

This is a partial fix for adafruit/circuitpython#3184.
@jepler jepler linked a pull request Aug 28, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants