Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
rm-hull committed Oct 26, 2020
1 parent c1c2a2e commit 54e9909
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions luma/lcd/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ def display(self, image):
self.command(0x2B, top >> 8, top & 0xFF, (bottom - 1) >> 8, (bottom - 1) & 0xFF) # Set row addr
self.command(0x2C) # Memory write

self.data(image.tobytes())
self.data(list(image.tobytes()))

def contrast(self, level):
"""
Expand Down Expand Up @@ -1020,16 +1020,16 @@ def display(self, image):
for image_segment, bounding_box in self.framebuffer.redraw(image):
self._cleanup_custom(image_segment)
# Expand bounding box to align to cell boundaries (5,8)
x0, y0, x1, y1 = bounding_box
x0 = x0 // 5 * 5
x1 = x1 // 5 * 5 if not x1 % 5 else (x1 // 5 + 1) * 5
y0 = y0 // 8 * 8
y1 = y1 // 8 * 8 if not y1 % 8 else (y1 // 8 + 1) * 8
bounding_box = (x0, y0, x1, y1)

for j in range(y0 // 8, y1 // 8):
left, top, right, bottom = bounding_box
left = left // 5 * 5
right = right // 5 * 5 if not right % 5 else (right // 5 + 1) * 5
top = top // 8 * 8
bottom = bottom // 8 * 8 if not bottom % 8 else (bottom // 8 + 1) * 8
bounding_box = (left, top, right, bottom)

for j in range(top // 8, bottom // 8):
buf = []
for i in range(x0 // 5, x1 // 5):
for i in range(left // 5, right // 5):
img = image.crop((i * 5, j * 8, (i + 1) * 5, (j + 1) * 8))
bytes = img.tobytes()
c = self.glyph_index[bytes] if bytes in self.glyph_index else \
Expand All @@ -1038,7 +1038,7 @@ def display(self, image):
self._make_custom(img)
c = self._custom.get(bytes, ord(self._undefined))
buf.append(c)
self.command(self._const.DDRAMADDR | (self._const.LINES[j] + (x0 // 5)))
self.command(self._const.DDRAMADDR | (self._const.LINES[j] + (left // 5)))
self.data(buf)

def _make_custom(self, img):
Expand Down

0 comments on commit 54e9909

Please sign in to comment.