-
Notifications
You must be signed in to change notification settings - Fork 11
Limit the number of writes to improve performance #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,9 +28,9 @@ | |
""" | ||
# pylint: enable=line-too-long | ||
|
||
from micropython import const | ||
import adafruit_framebuf | ||
from adafruit_bus_device.spi_device import SPIDevice | ||
from micropython import const | ||
|
||
try: | ||
import numpy | ||
|
@@ -85,23 +85,26 @@ def show(self): | |
|
||
with self.spi_device as spi: | ||
|
||
_imageBuf = bytearray() | ||
# toggle the VCOM bit | ||
self._buf[0] = _SHARPMEM_BIT_WRITECMD | ||
if self._vcom: | ||
self._buf[0] |= _SHARPMEM_BIT_VCOM | ||
self._vcom = not self._vcom | ||
spi.write(self._buf) | ||
_imageBuf.extend(self._buf) | ||
|
||
slice_from = 0 | ||
line_len = self.width // 8 | ||
for line in range(self.height): | ||
self._buf[0] = reverse_bit(line + 1) | ||
spi.write(self._buf) | ||
spi.write(memoryview(self.buffer[slice_from : slice_from + line_len])) | ||
_imageBuf.extend(self._buf) | ||
_imageBuf.extend( | ||
self.buffer[slice_from: slice_from + line_len]) | ||
slice_from += line_len | ||
self._buf[0] = 0 | ||
spi.write(self._buf) | ||
spi.write(self._buf) # we send one last 0 byte | ||
_imageBuf.extend(self._buf) | ||
_imageBuf.extend(self._buf) | ||
spi.write(_imageBuf) | ||
|
||
def image(self, img): | ||
"""Set buffer to value of Python Imaging Library image. The image should | ||
|
@@ -135,7 +138,7 @@ def image(self, img): | |
self.buf[i] = 0 | ||
# Iterate through the pixels | ||
for x in range(width): # yes this double loop is slow, | ||
for y in range(height): # but these displays are small! | ||
for y in range(height): # but these displays are small! | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was this a manual? My guess this whitespace change is what's making There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Automatically formatted by VS Code. I'm not sure what There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, it's just that the CI will continue to complain. If you want to be extra sure, you can run pre-commit yourself, and let it decide what how to format everything. Pre-commit is what the CI uses, so that's the surest way. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
if img.mode == "RGB": | ||
self.pixel(x, y, pixels[(x, y)]) | ||
elif pixels[(x, y)]: | ||
|
Uh oh!
There was an error while loading. Please reload this page.