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>
This commit is contained in:
Daniel Thompson 2021-02-25 07:36:15 +00:00
parent cabe6f143c
commit 1cb1d96ef4

View file

@ -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: