mirror of
https://gitlab1.ptb.de/waltem01/Matrix
synced 2024-11-14 00:43:50 +00:00
set pixel endpoint
This commit is contained in:
parent
a7ae976d67
commit
3bac768b06
23
API/main.py
23
API/main.py
@ -27,6 +27,23 @@ def display_text():
|
||||
|
||||
return jsonify(response)
|
||||
|
||||
@api.route('/pixel', methods=['POST'])
|
||||
def set_pixel():
|
||||
response = { 'success': True }
|
||||
try:
|
||||
global matrix
|
||||
|
||||
data = request.get_json()
|
||||
x_coord = data.get('x')
|
||||
y_coord = data.get('y')
|
||||
|
||||
matrix.pixel(x_coord, y_coord)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
response['success'] = False
|
||||
|
||||
return jsonify(response)
|
||||
|
||||
@api.route('/update', methods=['GET'])
|
||||
def update_matrix():
|
||||
response = { 'success': True }
|
||||
@ -63,6 +80,12 @@ class Matrix(SampleBase):
|
||||
self.canvas = self.matrix.SwapOnVSync(self.canvas)
|
||||
self.clear()
|
||||
|
||||
def set_color(self, r, g, b):
|
||||
self.color = graphics.Color(r, g, b)
|
||||
|
||||
def pixel(self, x, y):
|
||||
self.canvas.SetPixel(x, y, self.color.red, self.color.green, self.color.blue)
|
||||
|
||||
def text(self, x, y, t):
|
||||
graphics.DrawText(self.canvas, self.font, x*9, (y+1)*18, self.color, t)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user