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
@@ -51,7 +60,16 @@ class Adafruit_SSD1675(Adafruit_EPD):
51
60
52
61
# pylint: disable=too-many-arguments
53
62
def __init__ (
54
- self , width , height , spi , * , cs_pin , dc_pin , sramcs_pin , rst_pin , busy_pin
63
+ self ,
64
+ width : int ,
65
+ height : int ,
66
+ spi : SPI ,
67
+ * ,
68
+ cs_pin : DigitalInOut ,
69
+ dc_pin : DigitalInOut ,
70
+ sramcs_pin : DigitalInOut ,
71
+ rst_pin : DigitalInOut ,
72
+ busy_pin : DigitalInOut
55
73
):
56
74
super ().__init__ (
57
75
width , height , spi , cs_pin , dc_pin , sramcs_pin , rst_pin , busy_pin
@@ -89,13 +107,13 @@ def __init__(
89
107
self .set_color_buffer (0 , True )
90
108
# pylint: enable=too-many-arguments
91
109
92
- def begin (self , reset = True ):
110
+ def begin (self , reset : bool = True ) -> None :
93
111
"""Begin communication with the display and set basic settings"""
94
112
if reset :
95
113
self .hardware_reset ()
96
114
self .power_down ()
97
115
98
- def busy_wait (self ):
116
+ def busy_wait (self ) -> None :
99
117
"""Wait for display to be done with current task, either by polling the
100
118
busy pin, or pausing"""
101
119
if self ._busy :
@@ -104,7 +122,7 @@ def busy_wait(self):
104
122
else :
105
123
time .sleep (0.5 )
106
124
107
- def power_up (self ):
125
+ def power_up (self ) -> None :
108
126
"""Power up the display in preparation for writing RAM and updating"""
109
127
self .hardware_reset ()
110
128
time .sleep (0.1 )
@@ -147,20 +165,20 @@ def power_up(self):
147
165
148
166
self .busy_wait ()
149
167
150
- def power_down (self ):
168
+ def power_down (self ) -> None :
151
169
"""Power down the display - required when not actively displaying!"""
152
170
self .command (_SSD1675_DEEP_SLEEP , bytearray ([0x01 ]))
153
171
time .sleep (0.1 )
154
172
155
- def update (self ):
173
+ def update (self ) -> None :
156
174
"""Update the display from internal memory"""
157
175
self .command (_SSD1675_DISP_CTRL2 , bytearray ([0xC7 ]))
158
176
self .command (_SSD1675_MASTER_ACTIVATE )
159
177
self .busy_wait ()
160
178
if not self ._busy :
161
179
time .sleep (3 ) # wait 3 seconds
162
180
163
- def write_ram (self , index ) :
181
+ def write_ram (self , index : Union [ 0 , 1 ]) -> Any :
164
182
"""Send the one byte command for starting the RAM write process. Returns
165
183
the byte read at the same time over SPI. index is the RAM buffer, can be
166
184
0 or 1 for tri-color displays."""
@@ -170,7 +188,9 @@ def write_ram(self, index):
170
188
return self .command (_SSD1675_WRITE_RAM2 , end = False )
171
189
raise RuntimeError ("RAM index must be 0 or 1" )
172
190
173
- def set_ram_address (self , x , y ): # pylint: disable=unused-argument, no-self-use
191
+ def set_ram_address (
192
+ self , x : int , y : int
193
+ ) -> None : # pylint: disable=unused-argument, no-self-use
174
194
"""Set the RAM address location, not used on this chipset but required by
175
195
the superclass"""
176
196
self .command (_SSD1675_SET_RAMXCOUNT , bytearray ([x ]))
0 commit comments