summaryrefslogtreecommitdiff
path: root/wasp
diff options
context:
space:
mode:
authorDaniel Thompson <daniel@redfelineninja.org.uk>2021-01-10 10:43:50 (GMT)
committerDaniel Thompson <daniel@redfelineninja.org.uk>2021-01-10 10:43:50 (GMT)
commit61c56598de7c1c3b3406345e263d8297fe4082a4 (patch)
treee6cd0c7684039e8a965fcbddacea65b34d5c980e /wasp
parent637f5d6e8a76aed34c8d556c4b4f38a9e634835c (diff)
boards: simulator: Add basic mute simulation
Currently the simulator shows redraw artifacts that are concealed on the real device by using display on/off. We can improve this by avoiding the refresh when the display is off. This does not match the behaviour of the real hardware (which goes dark during transitions) but does make the simulator feel much more comfortable to use. Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
Diffstat (limited to 'wasp')
-rw-r--r--wasp/boards/simulator/display.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/wasp/boards/simulator/display.py b/wasp/boards/simulator/display.py
index 0fa6ef7..cb97cda 100644
--- a/wasp/boards/simulator/display.py
+++ b/wasp/boards/simulator/display.py
@@ -13,6 +13,8 @@ import numpy as np
from PIL import Image
import wasp
+DISPOFF = 0x28
+DISPON = 0x29
CASET = 0x2a
RASET = 0x2b
RAMWR = 0x2c
@@ -35,6 +37,7 @@ class ST7789Sim(object):
self.colclip = [0, WIDTH-1]
self.rowclip = [0, HEIGHT-1]
self.cmd = 0
+ self.mute = False
def write(self, data):
# Converting data to a memoryview ensures we act more like spi.write()
@@ -46,7 +49,14 @@ class ST7789Sim(object):
# Assume if we get a byte at a time then it is command.
# This is a simplification do we don't have to track
# the D/C pin from within the simulator.
- self.cmd = data[0]
+ cmd = data[0]
+ if cmd == DISPOFF:
+ self.mute = True
+ elif cmd == DISPON:
+ self.mute = False
+ window.refresh()
+ else:
+ self.cmd = data[0]
elif self.cmd == CASET:
self.colclip[0] = (data[0] << 8) + data[1]
@@ -91,7 +101,8 @@ class ST7789Sim(object):
# Forcibly release the surface to ensure it is unlocked
del pixelview
- window.refresh()
+ if not self.mute:
+ window.refresh()
class CST816SSim():
def __init__(self):
@@ -268,4 +279,3 @@ def tick(pins):
else:
#print(event)
pass
- window.refresh()