8
8
CircuitPython driver for Adafruit SSD1680 display breakouts
9
9
* Author(s): Melissa LeBlanc-Williams Mikey Sklar
10
10
"""
11
+ import time
11
12
from micropython import const
12
13
import adafruit_framebuf
13
14
from adafruit_epd .epd import Adafruit_EPD
14
- import time
15
15
16
16
# Define all SSD1680 constants
17
17
_SSD1680_DRIVER_CONTROL = const (0x01 )
30
30
class Adafruit_SSD1680 (Adafruit_EPD ):
31
31
"""Driver for SSD1680 ePaper display, default driver."""
32
32
33
+ # pylint: disable=too-many-arguments
33
34
def __init__ (self , width , height , spi , * , cs_pin , dc_pin , sramcs_pin , rst_pin , busy_pin ):
35
+ # Call parent class's __init__ to initialize sram and other attributes
34
36
super ().__init__ (width , height , spi , cs_pin , dc_pin , sramcs_pin , rst_pin , busy_pin )
35
37
36
38
self .cs_pin = cs_pin
@@ -40,8 +42,10 @@ def __init__(self, width, height, spi, *, cs_pin, dc_pin, sramcs_pin, rst_pin, b
40
42
self .busy_pin = busy_pin
41
43
42
44
self .initialize_buffers (width , height )
45
+ # pylint: enable=too-many-arguments
43
46
44
47
def initialize_buffers (self , width , height ):
48
+ """Initialize width height stride buffers"""
45
49
stride = width
46
50
if stride % 8 != 0 :
47
51
stride += 8 - stride % 8
@@ -80,16 +84,22 @@ def power_up(self):
80
84
self .command (_SSD1680_SW_RESET )
81
85
self .busy_wait ()
82
86
83
- self .command (_SSD1680_DRIVER_CONTROL , bytearray ([self ._height - 1 , (self ._height - 1 ) >> 8 , 0x00 ]))
87
+ self .command (
88
+ _SSD1680_DRIVER_CONTROL ,
89
+ bytearray ([self ._height - 1 , (self ._height - 1 ) >> 8 , 0x00 ]),
90
+ )
84
91
self .command (_SSD1680_DATA_MODE , bytearray ([0x03 ]))
85
92
self .command (_SSD1680_SET_RAMXPOS , bytearray ([0x01 , 0x10 ]))
86
- self .command (_SSD1680_SET_RAMYPOS , bytearray ([0 , 0 , self ._height - 1 , (self ._height - 1 ) >> 8 ]))
93
+ self .command (
94
+ _SSD1680_SET_RAMYPOS ,
95
+ bytearray ([0 , 0 , self ._height - 1 , (self ._height - 1 ) >> 8 ]),
96
+ )
87
97
88
98
def write_ram (self , index ):
89
99
"""Write to RAM for SSD1680."""
90
100
if index == 0 :
91
101
return self .command (_SSD1680_WRITE_BWRAM , end = False )
92
- elif index == 1 :
102
+ if index == 1 :
93
103
return self .command (_SSD1680_WRITE_REDRAM , end = False )
94
104
else :
95
105
raise RuntimeError ("RAM index must be 0 or 1" )
@@ -112,13 +122,15 @@ def power_down(self):
112
122
self .command (_SSD1680_DEEP_SLEEP , bytearray ([0x01 ]))
113
123
time .sleep (0.1 )
114
124
115
-
116
125
class Adafruit_SSD1680Z (Adafruit_SSD1680 ):
117
126
"""Driver for SSD1680Z ePaper display, overriding SSD1680 settings."""
118
127
128
+ # pylint: disable=too-many-arguments
119
129
def __init__ (self , width , height , spi , * , cs_pin , dc_pin , sramcs_pin , rst_pin , busy_pin ):
130
+ # Call the parent class's __init__() to initialize attributes
120
131
super ().__init__ (width , height , spi , cs_pin = cs_pin , dc_pin = dc_pin ,
121
132
sramcs_pin = sramcs_pin , rst_pin = rst_pin , busy_pin = busy_pin )
133
+ # pylint: enable=too-many-arguments
122
134
123
135
def power_up (self ):
124
136
"""Power up sequence specifically for SSD1680Z."""
@@ -127,10 +139,16 @@ def power_up(self):
127
139
self .command (_SSD1680_SW_RESET )
128
140
self .busy_wait ()
129
141
130
- self .command (_SSD1680_DRIVER_CONTROL , bytearray ([self ._height - 1 , (self ._height - 1 ) >> 8 , 0x00 ]))
142
+ self .command (
143
+ _SSD1680_DRIVER_CONTROL ,
144
+ bytearray ([self ._height - 1 , (self ._height - 1 ) >> 8 , 0x00 ]),
145
+ )
131
146
self .command (_SSD1680_DATA_MODE , bytearray ([0x03 ]))
132
147
self .command (_SSD1680_SET_RAMXPOS , bytearray ([0x00 , (self ._width // 8 ) - 1 ]))
133
- self .command (_SSD1680_SET_RAMYPOS , bytearray ([0x00 , 0x00 , self ._height - 1 , (self ._height - 1 ) >> 8 ]))
148
+ self .command (
149
+ _SSD1680_SET_RAMYPOS ,
150
+ bytearray ([0x00 , 0x00 , self ._height - 1 , (self ._height - 1 ) >> 8 ]),
151
+ )
134
152
135
153
def update (self ):
136
154
"""Update the display specifically for SSD1680Z."""
0 commit comments