mirror of
https://gitlab1.ptb.de/waltem01/Matrix
synced 2024-09-17 10:09:43 +00:00
45 lines
955 B
Python
45 lines
955 B
Python
#!/usr/bin/env python
|
|
from deps.samplebase import SampleBase
|
|
from rgbmatrix import graphics
|
|
|
|
from flask import Flask, jsonify
|
|
import time
|
|
|
|
|
|
|
|
app = Flask(__name__)
|
|
count = 0
|
|
|
|
@app.route('/api/test', methods=['GET'])
|
|
def get_data():
|
|
app.matrix.text = f"Test #{++count}"
|
|
data = {"success": True}
|
|
return jsonify(data)
|
|
|
|
|
|
class Text(SampleBase):
|
|
def __init__(self, *args, **kwargs):
|
|
super(Text, self).__init__(*args, **kwargs)
|
|
self.text = ""
|
|
|
|
def run(self):
|
|
offscreen_canvas = self.matrix.CreateFrameCanvas()
|
|
font = graphics.Font()
|
|
font.LoadFont("deps/fonts/9x18B.bdf")
|
|
text_color = graphics.Color(255, 255, 255)
|
|
|
|
while True:
|
|
offscreen_canvas.Clear()
|
|
graphics.DrawText(offscreen_canvas, font, 0, 18, text_color, self.text)
|
|
offscreen_canvas = self.matrix.SwapOnVSync(offscreen_canvas)
|
|
|
|
time.sleep(0.05)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
app.matrix = Text()
|
|
app.run(debug=True)
|
|
|
|
if not app.matrix.process():
|
|
app.matrix.print_help()
|