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