Open phantomsixthplayer opened 2 years ago
Thank you for your detailed report.
RGBMatrix is continuously scanned by software inside the microcontroller using a timer interrupts. NeoPixel has to disable interrupts in order to correctly 'bit bang' the WS2812 protocol. So in this case it is unfortunately going to lead to the matrix glitching or blanking. You may get different results if you can use SPI as the neopixel communication method instead: https://learn.adafruit.com/circuitpython-neopixels-using-spi
I am not sure why MP3 playback would ever disable interrupts for a long period of time, so that is worth investigating further as a core bug. There may also turn out to be a reason that interrupts have to be disabled e.g., when reading mp3 data from flash, but I don't know it just offhand.
@jepler thanks SPI resolved label flicker cause from NeoPixels. Lets see if anyone has any info on the audio side.
I was unable to identify any reasons that MP3 playback or audio playback would disable interrupts long enough to interfere with the RGBMatrix display, so that is still a surprise and needs further investigation.
np, if anyone has any ideas to try help narrow it down let me know.
I've just noticed the following:
Audio file is 2 minutes long audio file plays only for 1 minute before entering another function speaker.stop() is used as 1 minute left on previous audio file next audio file starts and you hear an audible pop as well as labels flicker
Audio file is 2 minutes long audio file plays for 2 minutes before entering another function (no repeat) speaker.stop() is used next audio file starts and the labels flicker
Audio file is 2 minutes long audio file plays for 2 minutes before entering another function (no repeat) speaker.stop() has been commented out next audio file starts and the labels flicker very subtlety
Not sure if this helps identify anything. I decided to try wave format and the issue does not occur from the file I tested.
wav file: https://learn.adafruit.com/circuitpython-essentials/circuitpython-audio-out
import displayio
import rgbmatrix
import board
import framebufferio
from adafruit_display_shapes.rect import Rect
import audioio
import audiocore
from time import sleep
import gc
# RGBMatrix
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)
# display groups
sg = displayio.Group()
# start screen graphics to help see flicker
sg_bg0 = Rect(0, 1, 64, 6, fill=0xFF0000)
sg_bg1 = Rect(0, 7, 64, 6, fill=0xFFFF00)
sg_bg2 = Rect(0, 13, 64, 6, fill=0x00FF00)
sg_bg3 = Rect(0, 19, 64, 6, fill=0x00FFFF)
sg_bg4 = Rect(0, 25, 64, 6, fill=0xFF00FF)
sg.append(sg_bg0)
sg.append(sg_bg1)
sg.append(sg_bg2)
sg.append(sg_bg3)
sg.append(sg_bg4)
# audio
wave_file = open("StreetChicken.wav", "rb")
wave = audiocore.WaveFile(wave_file)
audio = audioio.AudioOut(board.A0)
# variables
screen_states = {
1: "start_screen"
}
screen_state = "start_screen"
def start_screen():
global screen_state
# show start screen
display.show(sg)
while screen_state == screen_states[1]:
sleep(3)
# play and repeat audio
if not audio.playing:
audio.play(wave)
# variables
screens = {
"start_screen": start_screen
}
# main loop, run approriate screen function given screen state
while True:
gc.collect()
screens[screen_state]()
CircuitPython version
Code/REPL
Behavior
NeoPixels and MP3Decoder cause labels to flicker when they activate.
Description
NeoPixels: Tried the RGBMatrix + NeoPixels and the labels flicker when NeoPixels activate. I noticed the lower you go with the number of pixels the less visible the flicker, tried 20, 10, 5 and 1. Having it set to one is the least noticeable if at all. If the NeoPixels are static and the colour only changes at the specified times (30, 20, 10 seconds) that is when the label will flicker. This test is independent of the Audio playing.
MP3Decoder: Tried the RGBMatrix + MP3 Playback and the labels flicker when audio starts, so in this example at 60 and 11 seconds.
I am using:
Unfortunately the flicker shows up on camera less noticeable:
Other notes: Metro M4, NeoPixels, Speaker and RGBMatrix share the 10A power supply, also tried powering each individually. Tried powering the NeoPixels and RGBMatrix with a source other than 10A, still the same. Purchased another Metro M4 and no difference also tried on a Feather M4 Express.
Additional information
When I used 'from adafruit_display_text import bitmap_label as label' instead of 'from adafruit_display_text import label' in combination with time() that specific label would flicker extremely fast, not sure if somehow related.
Other troubleshooting