From 1cb1d96ef4c650934a82ef0b0ae0b47ba100dbaf Mon Sep 17 00:00:00 2001 From: Daniel Thompson Date: Thu, 25 Feb 2021 07:36:15 +0000 Subject: [PATCH] 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 --- wasp/boards/simulator/display.py | 4 ++++ 1 file changed, 4 insertions(+) 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: