Skip to content

Commit a93e442

Browse files
author
rdagger
committed
Fix color byte order in draw_text8x8
1 parent fa5ee40 commit a93e442

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

ili9341.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -617,18 +617,15 @@ def draw_text8x8(self, x, y, text, color, background=0,
617617
# Confirm coordinates in boundary
618618
if self.is_off_grid(x, y, x + 7, y + 7):
619619
return
620-
# Rearrange color
621-
r = (color & 0xF800) >> 8
622-
g = (color & 0x07E0) >> 3
623-
b = (color & 0x1F) << 3
624620
buf = bytearray(w * 16)
625621
fbuf = FrameBuffer(buf, w, h, RGB565)
626622
if background != 0:
627-
bg_r = (background & 0xF800) >> 8
628-
bg_g = (background & 0x07E0) >> 3
629-
bg_b = (background & 0x1F) << 3
630-
fbuf.fill(color565(bg_b, bg_r, bg_g))
631-
fbuf.text(text, 0, 0, color565(b, r, g))
623+
# Swap background color bytes to correct for framebuf endianness
624+
b_color = ((background & 0xFF) << 8) | ((background & 0xFF00) >> 8)
625+
fbuf.fill(b_color)
626+
# Swap text color bytes to correct for framebuf endianness
627+
t_color = ((color & 0x00FF) << 8) | ((color & 0xFF00) >> 8)
628+
fbuf.text(text, 0, 0, t_color)
632629
if rotate == 0:
633630
self.block(x, y, x + w - 1, y + (h - 1), buf)
634631
elif rotate == 90:

0 commit comments

Comments
 (0)