Skip to content

Disable matrix refresh during update using image() (Fixes #78) #86

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

Merged
merged 2 commits into from
Mar 10, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions adafruit_ht16k33/matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,13 @@ def image(self, img):
)
# Grab all the pixels from the image, faster than getpixel.
pixels = img.convert("1").load()
auto_write = self.auto_write
self._auto_write = False
# Iterate through the pixels
for x in range(self.columns): # yes this double loop is slow,
for y in range(self.rows): # but these displays are small!
self.pixel(x, y, pixels[(x, y)])
self._auto_write = auto_write
if self._auto_write:
self.show()

Expand Down Expand Up @@ -214,6 +217,8 @@ def image(self, img):
)
# Grab all the pixels from the image, faster than getpixel.
pixels = img.convert("RGB").load()
auto_write = self.auto_write
self._auto_write = False
# Iterate through the pixels
for x in range(self.columns): # yes this double loop is slow,
for y in range(self.rows): # but these displays are small!
Expand All @@ -226,5 +231,6 @@ def image(self, img):
else:
# Unknown color, default to LED off.
self.pixel(x, y, self.LED_OFF)
self._auto_write = auto_write
if self._auto_write:
self.show()