From a7ae976d67f6e57101a7a642d8e6de890a77fdf3 Mon Sep 17 00:00:00 2001 From: waltem01 Date: Thu, 23 Nov 2023 10:44:57 +0100 Subject: [PATCH] error handling and clear method --- API/main.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/API/main.py b/API/main.py index 66a2078..70ab195 100644 --- a/API/main.py +++ b/API/main.py @@ -21,7 +21,8 @@ def display_text(): y_coord = data.get('y') matrix.text(x_coord, y_coord, text) - except: + except Exception as e: + print(e) response['success'] = False return jsonify(response) @@ -33,7 +34,8 @@ def update_matrix(): try: global matrix matrix.update() - except: + except Exception as e: + print(e) response['success'] = False return jsonify(response) @@ -54,9 +56,12 @@ class Matrix(SampleBase): while True: time.sleep(.05) + def clear(self): + self.canvas.Clear() + def update(self): self.canvas = self.matrix.SwapOnVSync(self.canvas) - self.canvas.Clear() + self.clear() def text(self, x, y, t): graphics.DrawText(self.canvas, self.font, x*9, (y+1)*18, self.color, t)