From 45d59b132fe59308fd78cb3a72486316e9137121 Mon Sep 17 00:00:00 2001 From: Kyle Into Date: Wed, 7 Jan 2026 10:39:54 -0700 Subject: [PATCH 1/2] Improve Waveshare bi-color display rendering with extended palette Related to issue #167 --- src/display/waveshare_display.py | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/display/waveshare_display.py b/src/display/waveshare_display.py index 6e88bb580..d415e2c88 100644 --- a/src/display/waveshare_display.py +++ b/src/display/waveshare_display.py @@ -29,6 +29,34 @@ def split_image_for_bi_color_epd(image): return black_layer, red_layer +def quantize_for_color_epd(image): + """ + Quantize image with extended palette for full-color e-paper displays. + + Uses an extended palette to better map colors like orange, yellow, and pink, + reducing dithering artifacts and blotchy text that occur when these colors are + dithered between available display colors. + """ + black = (0, 0, 0) + white = (255, 255, 255) + red = (255, 0, 0) + orange = (255, 165, 0) + yellow = (255, 255, 0) + green = (0, 255, 0) + blue = (0, 0, 255) + pink = (255, 192, 203) + + # Extended palette for 7-color ACeP displays (black, white, red, orange, yellow, green, blue) + # Including pink helps quantizer make better color choices before hardware mapping + palette_data = [*black, *white, *red, *orange, *yellow, *green, *blue, *pink] + palette_img = Image.new('P', (1, 1)) + palette_img.putpalette(palette_data) + + # Quantize with extended palette - reduces dithering for warm colors + return image.quantize(palette=palette_img, dither=Image.Dither.FLOYDSTEINBERG).convert('RGB') + + + class WaveshareDisplay(AbstractDisplay): """ Handles Waveshare e-paper display dynamically based on device type. @@ -129,7 +157,9 @@ def display_image(self, image, image_settings=[]): # Display the image on the WS display. if not self.bi_color_display: - self.epd_display.display(self.epd_display.getbuffer(image)) + # Apply extended palette quantization for full-color displays + quantized_image = quantize_for_color_epd(image) + self.epd_display.display(self.epd_display.getbuffer(quantized_image)) else: black_layer, red_layer = split_image_for_bi_color_epd(image) From 54f149b8a805fcc6a8ef6748a62927a702fef739 Mon Sep 17 00:00:00 2001 From: Kyle Into Date: Wed, 7 Jan 2026 10:57:12 -0700 Subject: [PATCH 2/2] use only correct colors --- src/display/waveshare_display.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/display/waveshare_display.py b/src/display/waveshare_display.py index d415e2c88..0bb3b40aa 100644 --- a/src/display/waveshare_display.py +++ b/src/display/waveshare_display.py @@ -31,28 +31,24 @@ def split_image_for_bi_color_epd(image): def quantize_for_color_epd(image): """ - Quantize image with extended palette for full-color e-paper displays. + Quantize image with correct palette for E6 (Spectra 6) full-color e-paper displays. - Uses an extended palette to better map colors like orange, yellow, and pink, - reducing dithering artifacts and blotchy text that occur when these colors are - dithered between available display colors. + E6 displays support 6 colors: black, white, red, yellow, green, blue (no orange). + Using the exact hardware color palette reduces dithering artifacts and blotchy text. """ black = (0, 0, 0) white = (255, 255, 255) red = (255, 0, 0) - orange = (255, 165, 0) yellow = (255, 255, 0) green = (0, 255, 0) blue = (0, 0, 255) - pink = (255, 192, 203) - # Extended palette for 7-color ACeP displays (black, white, red, orange, yellow, green, blue) - # Including pink helps quantizer make better color choices before hardware mapping - palette_data = [*black, *white, *red, *orange, *yellow, *green, *blue, *pink] + # E6/Spectra 6 palette: 6 colors (black, white, red, yellow, green, blue) + palette_data = [*black, *white, *red, *yellow, *green, *blue] palette_img = Image.new('P', (1, 1)) palette_img.putpalette(palette_data) - # Quantize with extended palette - reduces dithering for warm colors + # Quantize to hardware-supported colors - reduces dithering return image.quantize(palette=palette_img, dither=Image.Dither.FLOYDSTEINBERG).convert('RGB')