14
14
import adafruit_framebuf
15
15
from adafruit_epd .epd import Adafruit_EPD
16
16
17
+ try :
18
+ """Needed for type annotations"""
19
+ from typing import Union , Any
20
+ from busio import SPI
21
+ from digitalio import DigitalInOut
22
+
23
+ except ImportError :
24
+ pass
25
+
17
26
__version__ = "0.0.0+auto.0"
18
27
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_EPD.git"
19
28
@@ -77,8 +86,17 @@ class Adafruit_SSD1675B(Adafruit_EPD):
77
86
78
87
# pylint: disable=too-many-arguments
79
88
def __init__ (
80
- self , width , height , spi , * , cs_pin , dc_pin , sramcs_pin , rst_pin , busy_pin
81
- ):
89
+ self ,
90
+ width : int ,
91
+ height : int ,
92
+ spi : SPI ,
93
+ * ,
94
+ cs_pin : DigitalInOut ,
95
+ dc_pin : DigitalInOut ,
96
+ sramcs_pin : DigitalInOut ,
97
+ rst_pin : DigitalInOut ,
98
+ busy_pin : DigitalInOut
99
+ ) -> None :
82
100
super ().__init__ (
83
101
width , height , spi , cs_pin , dc_pin , sramcs_pin , rst_pin , busy_pin
84
102
)
@@ -115,13 +133,13 @@ def __init__(
115
133
self .set_color_buffer (0 , True )
116
134
# pylint: enable=too-many-arguments
117
135
118
- def begin (self , reset = True ):
136
+ def begin (self , reset : bool = True ) -> None :
119
137
"""Begin communication with the display and set basic settings"""
120
138
if reset :
121
139
self .hardware_reset ()
122
140
self .power_down ()
123
141
124
- def busy_wait (self ):
142
+ def busy_wait (self ) -> None :
125
143
"""Wait for display to be done with current task, either by polling the
126
144
busy pin, or pausing"""
127
145
if self ._busy :
@@ -130,7 +148,7 @@ def busy_wait(self):
130
148
else :
131
149
time .sleep (0.5 )
132
150
133
- def power_up (self ):
151
+ def power_up (self ) -> None :
134
152
"""Power up the display in preparation for writing RAM and updating"""
135
153
self .hardware_reset ()
136
154
time .sleep (0.1 )
@@ -189,20 +207,20 @@ def power_up(self):
189
207
190
208
self .busy_wait ()
191
209
192
- def power_down (self ):
210
+ def power_down (self ) -> None :
193
211
"""Power down the display - required when not actively displaying!"""
194
212
self .command (_SSD1675B_DEEP_SLEEP , bytearray ([0x01 ]))
195
213
time .sleep (0.1 )
196
214
197
- def update (self ):
215
+ def update (self ) -> None :
198
216
"""Update the display from internal memory"""
199
217
self .command (_SSD1675B_DISP_CTRL2 , bytearray ([0xC7 ]))
200
218
self .command (_SSD1675B_MASTER_ACTIVATE )
201
219
self .busy_wait ()
202
220
if not self ._busy :
203
221
time .sleep (3 ) # wait 3 seconds
204
222
205
- def write_ram (self , index ) :
223
+ def write_ram (self , index : Union [ 0 , 1 ]) -> Any :
206
224
"""Send the one byte command for starting the RAM write process. Returns
207
225
the byte read at the same time over SPI. index is the RAM buffer, can be
208
226
0 or 1 for tri-color displays."""
@@ -212,7 +230,9 @@ def write_ram(self, index):
212
230
return self .command (_SSD1675B_WRITE_RAM2 , end = False )
213
231
raise RuntimeError ("RAM index must be 0 or 1" )
214
232
215
- def set_ram_address (self , x , y ): # pylint: disable=unused-argument, no-self-use
233
+ def set_ram_address (
234
+ self , x : int , y : int
235
+ ) -> None : # pylint: disable=unused-argument, no-self-use
216
236
"""Set the RAM address location, not used on this chipset but required by
217
237
the superclass"""
218
238
self .command (_SSD1675B_SET_RAMXCOUNT , bytearray ([x ]))
0 commit comments