boards: simulator: Improve spi.write() simulation
Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
This commit is contained in:
parent
c1773a3976
commit
e3b2c7bf7d
2 changed files with 7 additions and 2 deletions
|
@ -37,6 +37,11 @@ class ST7789Sim(object):
|
||||||
self.cmd = 0
|
self.cmd = 0
|
||||||
|
|
||||||
def write(self, data):
|
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:
|
if len(data) == 1:
|
||||||
# Assume if we get a byte at a time then it is command.
|
# Assume if we get a byte at a time then it is command.
|
||||||
# This is a simplification do we don't have to track
|
# This is a simplification do we don't have to track
|
||||||
|
|
|
@ -181,8 +181,8 @@ class ST7789_SPI(ST7789):
|
||||||
|
|
||||||
Send data to the display as part of an optimized write sequence.
|
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
|
:param bytes-like buf: Data, must be in a form that can be directly
|
||||||
consumed by the SPI bus.
|
consumed by the SPI bus.
|
||||||
"""
|
"""
|
||||||
def __init__(self, width, height, spi, cs, dc, res=None, rate=8000000):
|
def __init__(self, width, height, spi, cs, dc, res=None, rate=8000000):
|
||||||
"""Configure the display.
|
"""Configure the display.
|
||||||
|
|
Loading…
Reference in a new issue