summaryrefslogtreecommitdiff
path: root/wasp/drivers
diff options
context:
space:
mode:
authorDaniel Thompson <daniel@redfelineninja.org.uk>2021-01-17 17:44:21 (GMT)
committerDaniel Thompson <daniel@redfelineninja.org.uk>2021-01-17 17:44:21 (GMT)
commit6b41c8f3db1778826ec8556f8900878a8f32c87a (patch)
tree8b65647a30cbf54f7a4bc314b4d4adcabda4701a /wasp/drivers
parent5abae5a7f63f6841744ad63e7c8bbbb1d8452b37 (diff)
drivers: st7789: Pre-allocate a memoryview
Reduce the cost of slicing the linebuffer by pre-allocating a memoryview. Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>
Diffstat (limited to 'wasp/drivers')
-rw-r--r--wasp/drivers/st7789.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/wasp/drivers/st7789.py b/wasp/drivers/st7789.py
index e689e4e..817c414 100644
--- a/wasp/drivers/st7789.py
+++ b/wasp/drivers/st7789.py
@@ -44,7 +44,7 @@ class ST7789(object):
"""
self.width = width
self.height = height
- self.linebuffer = bytearray(2 * width)
+ self.linebuffer = memoryview(bytearray(2 * width))
self.init_display()
def init_display(self):
@@ -167,7 +167,7 @@ class ST7789(object):
self.set_window(x, y, w, h)
# Populate the line buffer
- buf = memoryview(self.linebuffer)[0:2*w]
+ buf = self.linebuffer[0:2*w]
for xi in range(0, 2*w, 2):
buf[xi] = bg >> 8
buf[xi+1] = bg & 0xff