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
@@ -72,8 +81,17 @@ class Adafruit_SSD1680(Adafruit_EPD):
72
81
73
82
# pylint: disable=too-many-arguments
74
83
def __init__ (
75
- self , width , height , spi , * , cs_pin , dc_pin , sramcs_pin , rst_pin , busy_pin
76
- ):
84
+ self ,
85
+ width : int ,
86
+ height : int ,
87
+ spi : SPI ,
88
+ * ,
89
+ cs_pin : DigitalInOut ,
90
+ dc_pin : DigitalInOut ,
91
+ sramcs_pin : DigitalInOut ,
92
+ rst_pin : DigitalInOut ,
93
+ busy_pin : DigitalInOut
94
+ ) -> None :
77
95
super ().__init__ (
78
96
width , height , spi , cs_pin , dc_pin , sramcs_pin , rst_pin , busy_pin
79
97
)
@@ -110,13 +128,13 @@ def __init__(
110
128
self .set_color_buffer (1 , False )
111
129
# pylint: enable=too-many-arguments
112
130
113
- def begin (self , reset = True ):
131
+ def begin (self , reset : bool = True ) -> None :
114
132
"""Begin communication with the display and set basic settings"""
115
133
if reset :
116
134
self .hardware_reset ()
117
135
self .power_down ()
118
136
119
- def busy_wait (self ):
137
+ def busy_wait (self ) -> None :
120
138
"""Wait for display to be done with current task, either by polling the
121
139
busy pin, or pausing"""
122
140
if self ._busy :
@@ -125,7 +143,7 @@ def busy_wait(self):
125
143
else :
126
144
time .sleep (0.5 )
127
145
128
- def power_up (self ):
146
+ def power_up (self ) -> None :
129
147
"""Power up the display in preparation for writing RAM and updating"""
130
148
self .hardware_reset ()
131
149
self .busy_wait ()
@@ -160,20 +178,20 @@ def power_up(self):
160
178
self .command (_SSD1680_SET_RAMYCOUNT , bytearray ([self ._height - 1 , 0 ]))
161
179
self .busy_wait ()
162
180
163
- def power_down (self ):
181
+ def power_down (self ) -> None :
164
182
"""Power down the display - required when not actively displaying!"""
165
183
self .command (_SSD1680_DEEP_SLEEP , bytearray ([0x01 ]))
166
184
time .sleep (0.1 )
167
185
168
- def update (self ):
186
+ def update (self ) -> None :
169
187
"""Update the display from internal memory"""
170
188
self .command (_SSD1680_DISP_CTRL2 , bytearray ([0xF4 ]))
171
189
self .command (_SSD1680_MASTER_ACTIVATE )
172
190
self .busy_wait ()
173
191
if not self ._busy :
174
192
time .sleep (3 ) # wait 3 seconds
175
193
176
- def write_ram (self , index ) :
194
+ def write_ram (self , index : Union [ 0 , 1 ]) -> Any :
177
195
"""Send the one byte command for starting the RAM write process. Returns
178
196
the byte read at the same time over SPI. index is the RAM buffer, can be
179
197
0 or 1 for tri-color displays."""
@@ -183,7 +201,9 @@ def write_ram(self, index):
183
201
return self .command (_SSD1680_WRITE_REDRAM , end = False )
184
202
raise RuntimeError ("RAM index must be 0 or 1" )
185
203
186
- def set_ram_address (self , x , y ): # pylint: disable=unused-argument, no-self-use
204
+ def set_ram_address (
205
+ self , x : int , y : int
206
+ ) -> None : # pylint: disable=unused-argument, no-self-use
187
207
"""Set the RAM address location, not used on this chipset but required by
188
208
the superclass"""
189
209
# Set RAM X address counter
0 commit comments