|
28 | 28 | """ |
29 | 29 | # pylint: enable=line-too-long |
30 | 30 |
|
31 | | -from micropython import const |
32 | 31 | import adafruit_framebuf |
33 | 32 | from adafruit_bus_device.spi_device import SPIDevice |
| 33 | +from micropython import const |
34 | 34 |
|
35 | 35 | try: |
36 | 36 | import numpy |
@@ -85,23 +85,25 @@ def show(self): |
85 | 85 |
|
86 | 86 | with self.spi_device as spi: |
87 | 87 |
|
| 88 | + image_buffer = bytearray() |
88 | 89 | # toggle the VCOM bit |
89 | 90 | self._buf[0] = _SHARPMEM_BIT_WRITECMD |
90 | 91 | if self._vcom: |
91 | 92 | self._buf[0] |= _SHARPMEM_BIT_VCOM |
92 | 93 | self._vcom = not self._vcom |
93 | | - spi.write(self._buf) |
| 94 | + image_buffer.extend(self._buf) |
94 | 95 |
|
95 | 96 | slice_from = 0 |
96 | 97 | line_len = self.width // 8 |
97 | 98 | for line in range(self.height): |
98 | 99 | self._buf[0] = reverse_bit(line + 1) |
99 | | - spi.write(self._buf) |
100 | | - spi.write(memoryview(self.buffer[slice_from : slice_from + line_len])) |
| 100 | + image_buffer.extend(self._buf) |
| 101 | + image_buffer.extend(self.buffer[slice_from : slice_from + line_len]) |
101 | 102 | slice_from += line_len |
102 | 103 | self._buf[0] = 0 |
103 | | - spi.write(self._buf) |
104 | | - spi.write(self._buf) # we send one last 0 byte |
| 104 | + image_buffer.extend(self._buf) |
| 105 | + image_buffer.extend(self._buf) |
| 106 | + spi.write(image_buffer) |
105 | 107 |
|
106 | 108 | def image(self, img): |
107 | 109 | """Set buffer to value of Python Imaging Library image. The image should |
@@ -135,7 +137,7 @@ def image(self, img): |
135 | 137 | self.buf[i] = 0 |
136 | 138 | # Iterate through the pixels |
137 | 139 | for x in range(width): # yes this double loop is slow, |
138 | | - for y in range(height): # but these displays are small! |
| 140 | + for y in range(height): # but these displays are small! |
139 | 141 | if img.mode == "RGB": |
140 | 142 | self.pixel(x, y, pixels[(x, y)]) |
141 | 143 | elif pixels[(x, y)]: |
|
0 commit comments