diff --git a/adafruit_epd/uc8179.py b/adafruit_epd/uc8179.py index 9bf5968..5e4ca11 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([0b001111])) + else: + # Monochrome display: 0b010111 (0x17) - BW OTP LUT + self.command(_UC8179_PANELSETTING, bytearray([0b011111])) # 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])) diff --git a/examples/epd_bitmap.py b/examples/epd_bitmap.py index 3e18441..9f7037e 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..529bb0e 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..561521d 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..25f3a80 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)