1
- # SPDX-FileCopyrightText: 2025 Liz Clark for Adafruit Industries
1
+ # SPDX-FileCopyrightText: 2024
2
2
#
3
3
# SPDX-License-Identifier: MIT
4
4
5
5
"""
6
6
`adafruit_epd.uc8179` - Adafruit UC8179 - ePaper display driver
7
7
====================================================================================
8
8
CircuitPython driver for Adafruit UC8179 display breakouts
9
- * Author(s): Liz Clark
9
+ * Author(s): Your Name Here
10
10
"""
11
11
12
12
import time
52
52
class Adafruit_UC8179 (Adafruit_EPD ):
53
53
"""driver class for Adafruit UC8179 ePaper display breakouts"""
54
54
55
- # Default initialization sequence
56
- _default_init_code = bytes ([
57
- _UC8179_POWERSETTING , 4 ,
58
- 0x07 , # VGH=20V
59
- 0x07 , # VGL=-20V
60
- 0x3F , # VDH=15V
61
- 0x3F , # VDL=-15V
62
-
63
- _UC8179_POWERON , 0 ,
64
- 0xFF , 100 , # busy wait
65
-
66
- _UC8179_PANELSETTING , 1 ,
67
- 0b010111 , # BW OTP LUT
68
-
69
- _UC8179_TRES , 4 ,
70
- 0x02 , 0x88 , 0x01 , 0xE0 ,
71
-
72
- _UC8179_DUALSPI , 1 , 0x00 ,
73
-
74
- _UC8179_WRITE_VCOM , 2 , 0x10 , 0x07 ,
75
- _UC8179_TCON , 1 , 0x22 ,
76
-
77
- 0xFE # End marker
78
- ])
79
-
80
55
def __init__ (
81
56
self ,
82
57
width : int ,
@@ -125,32 +100,18 @@ def __init__(
125
100
# Set up which frame buffer is which color
126
101
self .set_black_buffer (0 , True )
127
102
self .set_color_buffer (1 , False )
128
-
103
+
129
104
# UC8179 uses single byte transactions
130
105
self ._single_byte_tx = True
131
106
132
- # Custom init code if needed
133
- self ._epd_init_code = None
134
-
135
107
# Default refresh delay (from Adafruit_EPD base class in Arduino)
136
108
self .default_refresh_delay = 15 # seconds
137
109
# pylint: enable=too-many-arguments
138
110
139
111
def begin (self , reset : bool = True ) -> None :
140
112
"""Begin communication with the display and set basic settings"""
141
- # Direct port of Arduino begin() method
142
-
143
- # Note: Arduino sets _data_entry_mode = THINKINK_UC8179
144
- # This appears to be specific to SRAM organization for this chip
145
-
146
113
if reset :
147
114
self .hardware_reset ()
148
-
149
- # Black buffer defaults to inverted (0 means black)
150
- self .set_black_buffer (0 , True )
151
- # Red/color buffer defaults to not inverted (1 means red)
152
- self .set_color_buffer (1 , False )
153
-
154
115
self .power_down ()
155
116
156
117
def busy_wait (self ) -> None :
@@ -170,24 +131,50 @@ def busy_wait(self) -> None:
170
131
def power_up (self ) -> None :
171
132
"""Power up the display in preparation for writing RAM and updating"""
172
133
self .hardware_reset ()
173
-
174
- # Use custom init code if provided, otherwise use default
175
- init_code = self ._epd_init_code if self ._epd_init_code else self ._default_init_code
176
-
177
- # Process initialization sequence
178
- self ._command_list (init_code )
179
-
180
- # Set display resolution (using WIDTH and HEIGHT macros in Arduino)
134
+
135
+ # Power setting
136
+ self .command (
137
+ _UC8179_POWERSETTING ,
138
+ bytearray (
139
+ [
140
+ 0x07 , # VGH=20V
141
+ 0x07 , # VGL=-20V
142
+ 0x3F , # VDH=15V
143
+ 0x3F , # VDL=-15V
144
+ ]
145
+ ),
146
+ )
147
+
148
+ # Power on
149
+ self .command (_UC8179_POWERON )
150
+ time .sleep (0.1 ) # 100ms delay
151
+ self .busy_wait ()
152
+
153
+ # Panel setting
154
+ self .command (_UC8179_PANELSETTING , bytearray ([0b010111 ])) # BW OTP LUT
155
+
156
+ # Resolution setting
181
157
self .command (
182
158
_UC8179_TRES ,
183
- bytearray ([self ._width >> 8 , self ._width & 0xFF , self ._height >> 8 , self ._height & 0xFF ]),
159
+ bytearray (
160
+ [self ._width >> 8 , self ._width & 0xFF , self ._height >> 8 , self ._height & 0xFF ]
161
+ ),
184
162
)
185
163
164
+ # Dual SPI setting
165
+ self .command (_UC8179_DUALSPI , bytearray ([0x00 ]))
166
+
167
+ # VCOM setting
168
+ self .command (_UC8179_WRITE_VCOM , bytearray ([0x10 , 0x07 ]))
169
+
170
+ # TCON setting
171
+ self .command (_UC8179_TCON , bytearray ([0x22 ]))
172
+
186
173
def power_down (self ) -> None :
187
174
"""Power down the display - required when not actively displaying!"""
188
175
self .command (_UC8179_POWEROFF )
189
176
self .busy_wait ()
190
-
177
+
191
178
# Only deep sleep if we have a reset pin to wake it up
192
179
if self ._rst :
193
180
self .command (_UC8179_DEEPSLEEP , bytearray ([0x05 ]))
@@ -196,12 +183,12 @@ def power_down(self) -> None:
196
183
def update (self ) -> None :
197
184
"""Update the display from internal memory"""
198
185
self .command (_UC8179_DISPLAYREFRESH )
199
- time .sleep (0.1 )
186
+ time .sleep (0.1 ) # 100ms delay
200
187
self .busy_wait ()
201
-
188
+
202
189
if not self ._busy :
203
190
# If no busy pin, use default refresh delay
204
- time .sleep (self .default_refresh_delay / 1000.0 )
191
+ time .sleep (self .default_refresh_delay )
205
192
206
193
def write_ram (self , index : Literal [0 , 1 ]) -> int :
207
194
"""Send the one byte command for starting the RAM write process. Returns
@@ -224,29 +211,3 @@ def set_ram_window(self, x1: int, y1: int, x2: int, y2: int) -> None: # noqa: P
224
211
the superclass"""
225
212
# Not used in UC8179 chip
226
213
pass
227
-
228
- def _command_list (self , init_sequence : bytes ) -> None :
229
- """Process a command list for initialization"""
230
- i = 0
231
- while i < len (init_sequence ):
232
- cmd = init_sequence [i ]
233
- i += 1
234
-
235
- # Check for end marker
236
- if cmd == 0xFE :
237
- break
238
-
239
- # Get number of data bytes
240
- num_data = init_sequence [i ]
241
- i += 1
242
-
243
- # Check for delay command (0xFF)
244
- if cmd == 0xFF :
245
- time .sleep (num_data / 1000.0 )
246
- else :
247
- # Send command with data if any
248
- if num_data > 0 :
249
- self .command (cmd , bytearray (init_sequence [i :i + num_data ]))
250
- i += num_data
251
- else :
252
- self .command (cmd )
0 commit comments