diff options
| author | Daniel Thompson <daniel@redfelineninja.org.uk> | 2020-12-12 12:32:01 (GMT) |
|---|---|---|
| committer | Daniel Thompson <daniel@redfelineninja.org.uk> | 2020-12-12 12:57:06 (GMT) |
| commit | e3b2c7bf7d7a4cc7dc2cafc28f35e30f44260a21 (patch) | |
| tree | a3e3bf0d79cd63e13707b4ac1c3124d8d3a7a4e5 | |
| parent | c1773a39763cb7eea0a75a0e9f8ac56a95f4b4b4 (diff) | |
boards: simulator: Improve spi.write() simulation
Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
| -rw-r--r-- | wasp/boards/simulator/display.py | 5 | ||||
| -rw-r--r-- | wasp/drivers/st7789.py | 4 |
2 files changed, 7 insertions, 2 deletions
diff --git a/wasp/boards/simulator/display.py b/wasp/boards/simulator/display.py index 8efbb9c..379760c 100644 --- a/wasp/boards/simulator/display.py +++ b/wasp/boards/simulator/display.py @@ -37,6 +37,11 @@ class ST7789Sim(object): self.cmd = 0 def write(self, data): + # Converting data to a memoryview ensures we act more like spi.write() + # when running in a real device (e.g. data must be bytes-like object + # that implements the buffer protocol) + data = memoryview(data) + if len(data) == 1: # Assume if we get a byte at a time then it is command. # This is a simplification do we don't have to track diff --git a/wasp/drivers/st7789.py b/wasp/drivers/st7789.py index 013ee1b..be4b109 100644 --- a/wasp/drivers/st7789.py +++ b/wasp/drivers/st7789.py @@ -181,8 +181,8 @@ class ST7789_SPI(ST7789): Send data to the display as part of an optimized write sequence. - :param bytearray buf: Data, must be in a form that can be directly - consumed by the SPI bus. + :param bytes-like buf: Data, must be in a form that can be directly + consumed by the SPI bus. """ def __init__(self, width, height, spi, cs, dc, res=None, rate=8000000): """Configure the display. |
