14
14
import adafruit_framebuf
15
15
from adafruit_epd .epd import Adafruit_EPD
16
16
17
+ try :
18
+ from typing import Union , Any
19
+ from busio import SPI
20
+ from digitalio import DigitalInOut
21
+
22
+ except ImportError :
23
+ pass
24
+
17
25
__version__ = "0.0.0+auto.0"
18
26
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_EPD.git"
19
27
@@ -72,8 +80,17 @@ class Adafruit_SSD1681(Adafruit_EPD):
72
80
73
81
# pylint: disable=too-many-arguments
74
82
def __init__ (
75
- self , width , height , spi , * , cs_pin , dc_pin , sramcs_pin , rst_pin , busy_pin
76
- ):
83
+ self ,
84
+ width : int ,
85
+ height : int ,
86
+ spi : SPI ,
87
+ * ,
88
+ cs_pin : DigitalInOut ,
89
+ dc_pin : DigitalInOut ,
90
+ sramcs_pin : DigitalInOut ,
91
+ rst_pin : DigitalInOut ,
92
+ busy_pin : DigitalInOut
93
+ ) -> None :
77
94
super ().__init__ (
78
95
width , height , spi , cs_pin , dc_pin , sramcs_pin , rst_pin , busy_pin
79
96
)
@@ -101,13 +118,13 @@ def __init__(
101
118
self .set_color_buffer (1 , False )
102
119
# pylint: enable=too-many-arguments
103
120
104
- def begin (self , reset = True ):
121
+ def begin (self , reset : bool = True ) -> None :
105
122
"""Begin communication with the display and set basic settings"""
106
123
if reset :
107
124
self .hardware_reset ()
108
125
self .power_down ()
109
126
110
- def busy_wait (self ):
127
+ def busy_wait (self ) -> None :
111
128
"""Wait for display to be done with current task, either by polling the
112
129
busy pin, or pausing"""
113
130
if self ._busy :
@@ -116,7 +133,7 @@ def busy_wait(self):
116
133
else :
117
134
time .sleep (0.5 )
118
135
119
- def power_up (self ):
136
+ def power_up (self ) -> None :
120
137
"""Power up the display in preparation for writing RAM and updating"""
121
138
self .hardware_reset ()
122
139
self .busy_wait ()
@@ -143,20 +160,20 @@ def power_up(self):
143
160
144
161
self .busy_wait ()
145
162
146
- def power_down (self ):
163
+ def power_down (self ) -> None :
147
164
"""Power down the display - required when not actively displaying!"""
148
165
self .command (_SSD1681_DEEP_SLEEP , bytearray ([0x01 ]))
149
166
time .sleep (0.1 )
150
167
151
- def update (self ):
168
+ def update (self ) -> None :
152
169
"""Update the display from internal memory"""
153
170
self .command (_SSD1681_DISP_CTRL2 , bytearray ([0xF7 ]))
154
171
self .command (_SSD1681_MASTER_ACTIVATE )
155
172
self .busy_wait ()
156
173
if not self ._busy :
157
174
time .sleep (3 ) # wait 3 seconds
158
175
159
- def write_ram (self , index ) :
176
+ def write_ram (self , index : Union [ 0 , 1 ]) -> Any :
160
177
"""Send the one byte command for starting the RAM write process. Returns
161
178
the byte read at the same time over SPI. index is the RAM buffer, can be
162
179
0 or 1 for tri-color displays."""
@@ -166,7 +183,9 @@ def write_ram(self, index):
166
183
return self .command (_SSD1681_WRITE_REDRAM , end = False )
167
184
raise RuntimeError ("RAM index must be 0 or 1" )
168
185
169
- def set_ram_address (self , x , y ): # pylint: disable=unused-argument, no-self-use
186
+ def set_ram_address (
187
+ self , x : int , y : int
188
+ ) -> None : # pylint: disable=unused-argument, no-self-use
170
189
"""Set the RAM address location, not used on this chipset but required by
171
190
the superclass"""
172
191
# Set RAM X address counter
0 commit comments