@@ -115,29 +115,32 @@ def __init__(
115
115
)
116
116
self .set_black_buffer (0 , True )
117
117
self .set_color_buffer (1 , False )
118
-
118
+
119
119
# Set single byte transactions flag
120
120
self ._single_byte_tx = True
121
-
121
+
122
122
# Set the display update value
123
123
self ._display_update_val = 0xF7
124
-
124
+
125
125
# Default initialization sequence (tri-color mode)
126
- self ._default_init_code = bytes ([
127
- _SSD1683_SW_RESET , 0 , # Software reset
128
- 0xFF , 50 , # Wait for busy (50ms delay)
129
-
130
- _SSD1683_WRITE_BORDER , 1 , # Border waveform control
131
- 0x05 , # Border color/waveform
132
-
133
- _SSD1683_TEMP_CONTROL , 1 , # Temperature control
134
- 0x80 , # Read temp
135
-
136
- _SSD1683_DATA_MODE , 1 , # Data entry mode
137
- 0x03 , # Y decrement, X increment
138
-
139
- 0xFE # End of initialization
140
- ])
126
+ self ._default_init_code = bytes (
127
+ [
128
+ _SSD1683_SW_RESET ,
129
+ 0 , # Software reset
130
+ 0xFF ,
131
+ 50 , # Wait for busy (50ms delay)
132
+ _SSD1683_WRITE_BORDER ,
133
+ 1 , # Border waveform control
134
+ 0x05 , # Border color/waveform
135
+ _SSD1683_TEMP_CONTROL ,
136
+ 1 , # Temperature control
137
+ 0x80 , # Read temp
138
+ _SSD1683_DATA_MODE ,
139
+ 1 , # Data entry mode
140
+ 0x03 , # Y decrement, X increment
141
+ 0xFE , # End of initialization
142
+ ]
143
+ )
141
144
142
145
def begin (self , reset : bool = True ) -> None :
143
146
"""Begin communication with the display and set basic settings"""
@@ -162,20 +165,20 @@ def power_up(self) -> None:
162
165
163
166
# Use custom init code if provided, otherwise use default
164
167
init_code = self ._default_init_code
165
- if hasattr (self , ' _epd_init_code' ) and self ._epd_init_code is not None :
168
+ if hasattr (self , " _epd_init_code" ) and self ._epd_init_code is not None :
166
169
init_code = self ._epd_init_code
167
-
170
+
168
171
# Send initialization sequence
169
172
self ._send_command_list (init_code )
170
173
171
174
# Set RAM window
172
175
self .set_ram_window (0 , 0 , (self ._width // 8 ) - 1 , self ._height - 1 )
173
-
176
+
174
177
# Set RAM address to start position
175
178
self .set_ram_address (0 , 0 )
176
179
177
180
# Set LUT if we have one
178
- if hasattr (self , ' _epd_lut_code' ) and self ._epd_lut_code :
181
+ if hasattr (self , " _epd_lut_code" ) and self ._epd_lut_code :
179
182
self ._send_command_list (self ._epd_lut_code )
180
183
181
184
# Set display size and driver output control
@@ -201,7 +204,7 @@ def update(self) -> None:
201
204
self .command (_SSD1683_DISP_CTRL2 , bytearray ([self ._display_update_val ]))
202
205
self .command (_SSD1683_MASTER_ACTIVATE )
203
206
self .busy_wait ()
204
-
207
+
205
208
if not self ._busy :
206
209
time .sleep (1 ) # wait 1 second
207
210
@@ -219,43 +222,41 @@ def set_ram_address(self, x: int, y: int) -> None:
219
222
"""Set the RAM address location"""
220
223
# set RAM x address count
221
224
self .command (_SSD1683_SET_RAMXCOUNT , bytearray ([x & 0xFF ]))
222
-
225
+
223
226
# set RAM y address count
224
227
self .command (_SSD1683_SET_RAMYCOUNT , bytearray ([y & 0xFF , (y >> 8 ) & 0xFF ]))
225
228
226
229
def set_ram_window (self , x1 : int , y1 : int , x2 : int , y2 : int ) -> None :
227
230
"""Set the RAM window for partial updates"""
228
231
# Set ram X start/end position
229
232
self .command (_SSD1683_SET_RAMXPOS , bytearray ([x1 & 0xFF , x2 & 0xFF ]))
230
-
233
+
231
234
# Set ram Y start/end position
232
- self .command (_SSD1683_SET_RAMYPOS , bytearray ([
233
- y1 & 0xFF , ( y1 >> 8 ) & 0xFF ,
234
- y2 & 0xFF , (y2 >> 8 ) & 0xFF
235
- ]) )
235
+ self .command (
236
+ _SSD1683_SET_RAMYPOS ,
237
+ bytearray ([ y1 & 0xFF , ( y1 >> 8 ) & 0xFF , y2 & 0xFF , (y2 >> 8 ) & 0xFF ]),
238
+ )
236
239
237
240
def _send_command_list (self , init_sequence : bytes ) -> None :
238
241
"""Send a sequence of commands from an initialization list"""
239
242
i = 0
240
243
while i < len (init_sequence ):
241
244
cmd = init_sequence [i ]
242
245
i += 1
243
-
246
+
244
247
if cmd == 0xFE : # End marker
245
248
break
246
249
elif cmd == 0xFF : # Delay marker
247
250
if i < len (init_sequence ):
248
251
delay_ms = init_sequence [i ]
249
252
i += 1
250
253
time .sleep (delay_ms / 1000.0 )
251
- else :
252
- # Regular command
253
- if i < len (init_sequence ):
254
- num_args = init_sequence [i ]
255
- i += 1
256
- if num_args > 0 and (i + num_args ) <= len (init_sequence ):
257
- args = init_sequence [i :i + num_args ]
258
- self .command (cmd , bytearray (args ))
259
- i += num_args
260
- else :
261
- self .command (cmd )
254
+ elif i < len (init_sequence ):
255
+ num_args = init_sequence [i ]
256
+ i += 1
257
+ if num_args > 0 and (i + num_args ) <= len (init_sequence ):
258
+ args = init_sequence [i : i + num_args ]
259
+ self .command (cmd , bytearray (args ))
260
+ i += num_args
261
+ else :
262
+ self .command (cmd )
0 commit comments