Matrix/API/main.py

33 lines
863 B
Python
Raw Normal View History

2023-11-22 15:21:15 +00:00
#!/usr/bin/env python
from samplebase import SampleBase
from rgbmatrix import graphics
import time
2023-11-22 14:41:13 +00:00
2023-11-22 15:21:15 +00:00
class Test(SampleBase):
2023-11-22 15:22:19 +00:00
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!")
2023-11-22 14:41:13 +00:00
2023-11-22 15:22:19 +00:00
def run(self):
2023-11-22 15:21:15 +00:00
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
2023-11-22 14:41:13 +00:00
2023-11-22 15:21:15 +00:00
offscreen_canvas.Clear()
graphics.DrawText(offscreen_canvas, font, pos, 10, textColor, my_text)
offscreen_canvas = self.matrix.SwapOnVSync(offscreen_canvas)
2023-11-22 14:41:13 +00:00
2023-11-22 15:21:15 +00:00
while True:
time.sleep(0.05)
2023-11-22 14:41:13 +00:00
2023-11-22 15:21:15 +00:00
# Main function
if __name__ == "__main__":
2023-11-22 15:22:19 +00:00
test = Test()
if (not test.process()):
test.print_help()