@@ -63,13 +63,17 @@ def __init__(
6363 sramcs_pin : DigitalInOut ,
6464 rst_pin : DigitalInOut ,
6565 busy_pin : DigitalInOut ,
66+ tri_color : bool = False ,
6667 ) -> None :
6768 # Adjust height to be divisible by 8 (direct from Arduino)
6869 if (height % 8 ) != 0 :
6970 height += 8 - (height % 8 )
7071
7172 super ().__init__ (width , height , spi , cs_pin , dc_pin , sramcs_pin , rst_pin , busy_pin )
7273
74+ # Store whether this is a tricolor display
75+ self ._tri_color = tri_color
76+
7377 # Calculate buffer sizes exactly as Arduino does: width * height / 8
7478 self ._buffer1_size = width * height // 8
7579 self ._buffer2_size = self ._buffer1_size
@@ -98,14 +102,19 @@ def __init__(
98102 )
99103
100104 # Set up which frame buffer is which color
101- self .set_black_buffer (0 , True )
102- self .set_color_buffer (1 , False )
105+ if self ._tri_color :
106+ self .set_black_buffer (0 , False )
107+ self .set_color_buffer (1 , False )
108+ # Tricolor has longer refresh time
109+ self .default_refresh_delay = 13 # seconds
110+ else :
111+ # Monochrome settings
112+ self .set_black_buffer (0 , True )
113+ self .set_color_buffer (1 , False )
114+ self .default_refresh_delay = 15 # seconds
103115
104116 # UC8179 uses single byte transactions
105117 self ._single_byte_tx = False
106-
107- # Default refresh delay (from Adafruit_EPD base class in Arduino)
108- self .default_refresh_delay = 15 # seconds
109118 # pylint: enable=too-many-arguments
110119
111120 def begin (self , reset : bool = True ) -> None :
@@ -150,8 +159,13 @@ def power_up(self) -> None:
150159 time .sleep (0.1 ) # 100ms delay
151160 self .busy_wait ()
152161
153- # Panel setting
154- self .command (_UC8179_PANELSETTING , bytearray ([0b011111 ])) # BW OTP LUT
162+ # Panel setting - different for tricolor vs monochrome
163+ if self ._tri_color :
164+ # Tricolor display: 0b000111 (0x07) - Tricolor OTP LUT
165+ self .command (_UC8179_PANELSETTING , bytearray ([0b000111 ]))
166+ else :
167+ # Monochrome display: 0b010111 (0x17) - BW OTP LUT
168+ self .command (_UC8179_PANELSETTING , bytearray ([0b010111 ]))
155169
156170 # Resolution setting
157171 self .command (
@@ -164,8 +178,13 @@ def power_up(self) -> None:
164178 # Dual SPI setting
165179 self .command (_UC8179_DUALSPI , bytearray ([0x00 ]))
166180
167- # VCOM setting
168- self .command (_UC8179_WRITE_VCOM , bytearray ([0x10 , 0x07 ]))
181+ # VCOM setting - different for tricolor
182+ if self ._tri_color :
183+ # Tricolor VCOM setting
184+ self .command (_UC8179_WRITE_VCOM , bytearray ([0x90 , 0x07 ]))
185+ else :
186+ # Monochrome VCOM setting
187+ self .command (_UC8179_WRITE_VCOM , bytearray ([0x10 , 0x07 ]))
169188
170189 # TCON setting
171190 self .command (_UC8179_TCON , bytearray ([0x22 ]))
0 commit comments