From 0bc85b1044ab938ee17d713cb9c0ca9eb9912f55 Mon Sep 17 00:00:00 2001 From: Liz Date: Mon, 22 Sep 2025 12:46:44 -0400 Subject: [PATCH 1/3] update uc8179 for tricolor --- adafruit_epd/uc8179.py | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/adafruit_epd/uc8179.py b/adafruit_epd/uc8179.py index 9bf5968..fc4ec93 100644 --- a/adafruit_epd/uc8179.py +++ b/adafruit_epd/uc8179.py @@ -63,6 +63,7 @@ def __init__( sramcs_pin: DigitalInOut, rst_pin: DigitalInOut, busy_pin: DigitalInOut, + tri_color: bool = False, ) -> None: # Adjust height to be divisible by 8 (direct from Arduino) if (height % 8) != 0: @@ -70,6 +71,9 @@ def __init__( super().__init__(width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin) + # Store whether this is a tricolor display + self._tri_color = tri_color + # Calculate buffer sizes exactly as Arduino does: width * height / 8 self._buffer1_size = width * height // 8 self._buffer2_size = self._buffer1_size @@ -98,14 +102,19 @@ def __init__( ) # Set up which frame buffer is which color - self.set_black_buffer(0, True) - self.set_color_buffer(1, False) + if self._tri_color: + self.set_black_buffer(0, False) + self.set_color_buffer(1, False) + # Tricolor has longer refresh time + self.default_refresh_delay = 13 # seconds + else: + # Monochrome settings + self.set_black_buffer(0, True) + self.set_color_buffer(1, False) + self.default_refresh_delay = 15 # seconds # UC8179 uses single byte transactions self._single_byte_tx = False - - # Default refresh delay (from Adafruit_EPD base class in Arduino) - self.default_refresh_delay = 15 # seconds # pylint: enable=too-many-arguments def begin(self, reset: bool = True) -> None: @@ -150,8 +159,13 @@ def power_up(self) -> None: time.sleep(0.1) # 100ms delay self.busy_wait() - # Panel setting - self.command(_UC8179_PANELSETTING, bytearray([0b011111])) # BW OTP LUT + # Panel setting - different for tricolor vs monochrome + if self._tri_color: + # Tricolor display: 0b000111 (0x07) - Tricolor OTP LUT + self.command(_UC8179_PANELSETTING, bytearray([0b000111])) + else: + # Monochrome display: 0b010111 (0x17) - BW OTP LUT + self.command(_UC8179_PANELSETTING, bytearray([0b010111])) # Resolution setting self.command( @@ -164,8 +178,13 @@ def power_up(self) -> None: # Dual SPI setting self.command(_UC8179_DUALSPI, bytearray([0x00])) - # VCOM setting - self.command(_UC8179_WRITE_VCOM, bytearray([0x10, 0x07])) + # VCOM setting - different for tricolor + if self._tri_color: + # Tricolor VCOM setting + self.command(_UC8179_WRITE_VCOM, bytearray([0x90, 0x07])) + else: + # Monochrome VCOM setting + self.command(_UC8179_WRITE_VCOM, bytearray([0x10, 0x07])) # TCON setting self.command(_UC8179_TCON, bytearray([0x22])) From 66799976cfcb12cf5fe9951935c1caa68e881241 Mon Sep 17 00:00:00 2001 From: Liz Date: Mon, 22 Sep 2025 13:44:18 -0400 Subject: [PATCH 2/3] panelsetting and inits --- adafruit_epd/uc8179.py | 4 ++-- examples/epd_bitmap.py | 9 +++++++++ examples/epd_pillow_demo.py | 9 +++++++++ examples/epd_pillow_image.py | 9 +++++++++ examples/epd_simpletest.py | 11 ++++++++++- 5 files changed, 39 insertions(+), 3 deletions(-) diff --git a/adafruit_epd/uc8179.py b/adafruit_epd/uc8179.py index fc4ec93..5e4ca11 100644 --- a/adafruit_epd/uc8179.py +++ b/adafruit_epd/uc8179.py @@ -162,10 +162,10 @@ def power_up(self) -> None: # Panel setting - different for tricolor vs monochrome if self._tri_color: # Tricolor display: 0b000111 (0x07) - Tricolor OTP LUT - self.command(_UC8179_PANELSETTING, bytearray([0b000111])) + self.command(_UC8179_PANELSETTING, bytearray([0b001111])) else: # Monochrome display: 0b010111 (0x17) - BW OTP LUT - self.command(_UC8179_PANELSETTING, bytearray([0b010111])) + self.command(_UC8179_PANELSETTING, bytearray([0b011111])) # Resolution setting self.command( diff --git a/examples/epd_bitmap.py b/examples/epd_bitmap.py index 3e18441..15c33c2 100644 --- a/examples/epd_bitmap.py +++ b/examples/epd_bitmap.py @@ -52,6 +52,15 @@ rst_pin=rst, busy_pin=busy, ) +''' display = Adafruit_UC8179(800, 480, # 7.5" tricolor 800x480 display + spi, + cs_pin=ecs, + dc_pin=dc, + sramcs_pin=srcs, + rst_pin=rst, + busy_pin=busy, + tri_color = True +)''' # IF YOU HAVE A 2.13" FLEXIBLE DISPLAY OR! # UC8179 5.83" or 7.5" displays diff --git a/examples/epd_pillow_demo.py b/examples/epd_pillow_demo.py index 2579322..0e983fe 100644 --- a/examples/epd_pillow_demo.py +++ b/examples/epd_pillow_demo.py @@ -71,6 +71,15 @@ rst_pin=rst, busy_pin=busy, ) +''' display = Adafruit_UC8179(800, 480, # 7.5" tricolor 800x480 display + spi, + cs_pin=ecs, + dc_pin=dc, + sramcs_pin=srcs, + rst_pin=rst, + busy_pin=busy, + tri_color = True +)''' # IF YOU HAVE A 2.13" FLEXIBLE DISPLAY OR! # UC8179 5.83" or 7.5" displays diff --git a/examples/epd_pillow_image.py b/examples/epd_pillow_image.py index e7c75dd..4e00a1a 100644 --- a/examples/epd_pillow_image.py +++ b/examples/epd_pillow_image.py @@ -61,6 +61,15 @@ rst_pin=rst, busy_pin=busy, ) +''' display = Adafruit_UC8179(800, 480, # 7.5" tricolor 800x480 display + spi, + cs_pin=ecs, + dc_pin=dc, + sramcs_pin=srcs, + rst_pin=rst, + busy_pin=busy, + tri_color = True +)''' # IF YOU HAVE A 2.13" FLEXIBLE DISPLAY OR! # UC8179 5.83" or 7.5" displays diff --git a/examples/epd_simpletest.py b/examples/epd_simpletest.py index bef35dd..a47f5fd 100644 --- a/examples/epd_simpletest.py +++ b/examples/epd_simpletest.py @@ -55,9 +55,18 @@ rst_pin=rst, busy_pin=busy, ) +''' display = Adafruit_UC8179(800, 480, # 7.5" tricolor 800x480 display + spi, + cs_pin=ecs, + dc_pin=dc, + sramcs_pin=srcs, + rst_pin=rst, + busy_pin=busy, + tri_color = True +)''' # IF YOU HAVE A 2.13" FLEXIBLE DISPLAY OR! -# UC8179 5.83" or 7.5" displays +# UC8179 5.83" or 7.5" monochrome displays # uncomment these lines! # display.set_black_buffer(1, False) # display.set_color_buffer(1, False) From 59965ce54bc2541af0f9fd9a44cd28fa4d30d352 Mon Sep 17 00:00:00 2001 From: Liz Date: Mon, 22 Sep 2025 13:48:20 -0400 Subject: [PATCH 3/3] pre-commit --- examples/epd_bitmap.py | 4 ++-- examples/epd_pillow_demo.py | 4 ++-- examples/epd_pillow_image.py | 4 ++-- examples/epd_simpletest.py | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/epd_bitmap.py b/examples/epd_bitmap.py index 15c33c2..9f7037e 100644 --- a/examples/epd_bitmap.py +++ b/examples/epd_bitmap.py @@ -52,7 +52,7 @@ rst_pin=rst, busy_pin=busy, ) -''' display = Adafruit_UC8179(800, 480, # 7.5" tricolor 800x480 display +""" display = Adafruit_UC8179(800, 480, # 7.5" tricolor 800x480 display spi, cs_pin=ecs, dc_pin=dc, @@ -60,7 +60,7 @@ rst_pin=rst, busy_pin=busy, tri_color = True -)''' +)""" # IF YOU HAVE A 2.13" FLEXIBLE DISPLAY OR! # UC8179 5.83" or 7.5" displays diff --git a/examples/epd_pillow_demo.py b/examples/epd_pillow_demo.py index 0e983fe..529bb0e 100644 --- a/examples/epd_pillow_demo.py +++ b/examples/epd_pillow_demo.py @@ -71,7 +71,7 @@ rst_pin=rst, busy_pin=busy, ) -''' display = Adafruit_UC8179(800, 480, # 7.5" tricolor 800x480 display +""" display = Adafruit_UC8179(800, 480, # 7.5" tricolor 800x480 display spi, cs_pin=ecs, dc_pin=dc, @@ -79,7 +79,7 @@ rst_pin=rst, busy_pin=busy, tri_color = True -)''' +)""" # IF YOU HAVE A 2.13" FLEXIBLE DISPLAY OR! # UC8179 5.83" or 7.5" displays diff --git a/examples/epd_pillow_image.py b/examples/epd_pillow_image.py index 4e00a1a..561521d 100644 --- a/examples/epd_pillow_image.py +++ b/examples/epd_pillow_image.py @@ -61,7 +61,7 @@ rst_pin=rst, busy_pin=busy, ) -''' display = Adafruit_UC8179(800, 480, # 7.5" tricolor 800x480 display +""" display = Adafruit_UC8179(800, 480, # 7.5" tricolor 800x480 display spi, cs_pin=ecs, dc_pin=dc, @@ -69,7 +69,7 @@ rst_pin=rst, busy_pin=busy, tri_color = True -)''' +)""" # IF YOU HAVE A 2.13" FLEXIBLE DISPLAY OR! # UC8179 5.83" or 7.5" displays diff --git a/examples/epd_simpletest.py b/examples/epd_simpletest.py index a47f5fd..25f3a80 100644 --- a/examples/epd_simpletest.py +++ b/examples/epd_simpletest.py @@ -55,7 +55,7 @@ rst_pin=rst, busy_pin=busy, ) -''' display = Adafruit_UC8179(800, 480, # 7.5" tricolor 800x480 display +""" display = Adafruit_UC8179(800, 480, # 7.5" tricolor 800x480 display spi, cs_pin=ecs, dc_pin=dc, @@ -63,7 +63,7 @@ rst_pin=rst, busy_pin=busy, tri_color = True -)''' +)""" # IF YOU HAVE A 2.13" FLEXIBLE DISPLAY OR! # UC8179 5.83" or 7.5" monochrome displays