error handling and clear method

This commit is contained in:
waltem01 2023-11-23 10:44:57 +01:00
parent f953ac8c62
commit a7ae976d67

View File

@ -21,7 +21,8 @@ def display_text():
y_coord = data.get('y') y_coord = data.get('y')
matrix.text(x_coord, y_coord, text) matrix.text(x_coord, y_coord, text)
except: except Exception as e:
print(e)
response['success'] = False response['success'] = False
return jsonify(response) return jsonify(response)
@ -33,7 +34,8 @@ def update_matrix():
try: try:
global matrix global matrix
matrix.update() matrix.update()
except: except Exception as e:
print(e)
response['success'] = False response['success'] = False
return jsonify(response) return jsonify(response)
@ -54,9 +56,12 @@ class Matrix(SampleBase):
while True: while True:
time.sleep(.05) time.sleep(.05)
def clear(self):
self.canvas.Clear()
def update(self): def update(self):
self.canvas = self.matrix.SwapOnVSync(self.canvas) self.canvas = self.matrix.SwapOnVSync(self.canvas)
self.canvas.Clear() self.clear()
def text(self, x, y, t): def text(self, x, y, t):
graphics.DrawText(self.canvas, self.font, x*9, (y+1)*18, self.color, t) graphics.DrawText(self.canvas, self.font, x*9, (y+1)*18, self.color, t)