Matrix/API/main.py
2023-11-22 16:21:15 +01:00

33 lines
893 B
Python

#!/usr/bin/env python
from samplebase import SampleBase
from rgbmatrix import graphics
import time
class Test(SampleBase):
def __init__(self, *args, **kwargs):
super(Test, self).__init__(*args, **kwargs)
self.parser.add_argument("-t", "--text", help="The text to scroll on the RGB LED panel", default="Hello world!")
def run(self):
offscreen_canvas = self.matrix.CreateFrameCanvas()
font = graphics.Font()
font.LoadFont("deps/fonts/7x13.bdf")
textColor = graphics.Color(255, 255, 0)
pos = offscreen_canvas.width
my_text = self.args.text
offscreen_canvas.Clear()
graphics.DrawText(offscreen_canvas, font, pos, 10, textColor, my_text)
offscreen_canvas = self.matrix.SwapOnVSync(offscreen_canvas)
while True:
time.sleep(0.05)
# Main function
if __name__ == "__main__":
test = Test()
if (not test.process()):
test.print_help()