Skip to content

Font not displaying in the P4 Led but the program is running #1804

@robinsonkarunya

Description

@robinsonkarunya

I'm not getting output in led pannel but the program is running
This is the program :
import time
from rgbmatrix import RGBMatrix, RGBMatrixOptions, graphics

---------- Setup LED Matrix ----------

options = RGBMatrixOptions()
options.rows = 40
options.cols = 80
options.chain_length = 2
options.parallel = 1
options.multiplexing = 20
options.gpio_slowdown = 4
options.hardware_mapping = 'regular'

matrix = RGBMatrix(options=options)
canvas = matrix.CreateFrameCanvas()

---------- Static Text Display Function ----------

def display_static_text():
font = graphics.Font()
font.LoadFont("/home/pi/rpi-rgb-led-matrix/fonts/smallfont.bdf") # Larger font
font_height = font.height

text = "Magneto Dynamics"
text_color = graphics.Color(255, 255, 0)

# Get text width to center it
text_width = graphics.DrawText(canvas, font, 0, 0, text_color, text)
x_pos = (canvas.width - text_width) // 2
y_pos = ((canvas.height - font_height) // 2) + font_height

canvas.Clear()
graphics.DrawText(canvas, font, x_pos, y_pos, text_color, text)
matrix.SwapOnVSync(canvas)

---------- Main ----------

try:
display_static_text()
while True:
time.sleep(1) # Keeps running to hold the display
except KeyboardInterrupt:
print("Stopped.")
canvas.Clear()
matrix.SwapOnVSync(canvas)

This is terminal output 👍 :
python new2.py
FYI: not running as root which means we can't properly control timing unless this is a real-time kernel. Expect color degradation. Consider running as root with sudo.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions