summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Thompson <daniel@redfelineninja.org.uk>2021-02-25 07:36:15 (GMT)
committerDaniel Thompson <daniel@redfelineninja.org.uk>2021-02-25 07:36:15 (GMT)
commit1cb1d96ef4c650934a82ef0b0ae0b47ba100dbaf (patch)
treea026305bbf8c374d69c521dae4bc07ea04fdbb0b
parentcabe6f143c92e47b3ef2fdf8fe949a97ec9ffcd7 (diff)
boards: simulator: Pick up out-of-bounds drawing
Currently, if we ask the simulator to draw out-of-bounds then it will do exactly that, it will draw outside of the "screen" and corrupt the pixels of the watch frame that surrounds it. This is an obviously poor simulation of the real watch and when the out-of-bounds error is only an out-by-one error can be easily overlooked until we load the code on the device. Let's just throw an exception if we draw out-of-bounds. That can easily be picked up during testing. Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
-rw-r--r--wasp/boards/simulator/display.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/wasp/boards/simulator/display.py b/wasp/boards/simulator/display.py
index cb97cda..0756473 100644
--- a/wasp/boards/simulator/display.py
+++ b/wasp/boards/simulator/display.py
@@ -60,12 +60,16 @@ class ST7789Sim(object):
elif self.cmd == CASET:
self.colclip[0] = (data[0] << 8) + data[1]
+ assert(self.colclip[0] >= 0 and self.colclip[0] <= 240)
self.colclip[1] = (data[2] << 8) + data[3]
+ assert(self.colclip[1] >= 0 and self.colclip[1] <= 240)
self.x = self.colclip[0]
elif self.cmd == RASET:
self.rowclip[0] = (data[0] << 8) + data[1]
+ assert(self.rowclip[0] >= 0 and self.rowclip[0] <= 240)
self.rowclip[1] = (data[2] << 8) + data[3]
+ assert(self.rowclip[1] >= 0 and self.rowclip[1] <= 240)
self.y = self.rowclip[0]
elif self.cmd == RAMWR: