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
@@ -56,8 +65,17 @@ class Adafruit_IL91874(Adafruit_EPD):
56
65
57
66
# pylint: disable=too-many-arguments
58
67
def __init__ (
59
- self , width , height , spi , * , cs_pin , dc_pin , sramcs_pin , rst_pin , busy_pin
60
- ):
68
+ self ,
69
+ width : int ,
70
+ height : int ,
71
+ spi : SPI ,
72
+ * ,
73
+ cs_pin : DigitalInOut ,
74
+ dc_pin : DigitalInOut ,
75
+ sramcs_pin : DigitalInOut ,
76
+ rst_pin : DigitalInOut ,
77
+ busy_pin : DigitalInOut
78
+ ) -> None :
61
79
super ().__init__ (
62
80
width , height , spi , cs_pin , dc_pin , sramcs_pin , rst_pin , busy_pin
63
81
)
@@ -83,14 +101,14 @@ def __init__(
83
101
self .set_color_buffer (1 , False )
84
102
self ._single_byte_tx = True
85
103
86
- def begin (self , reset = True ):
104
+ def begin (self , reset : bool = True ) -> None :
87
105
"""Begin communication with the display and set basic settings"""
88
106
if reset :
89
107
self .hardware_reset ()
90
108
91
109
self .power_down ()
92
110
93
- def busy_wait (self ):
111
+ def busy_wait (self ) -> None :
94
112
"""Wait for display to be done with current task, either by polling the
95
113
busy pin, or pausing"""
96
114
if self ._busy :
@@ -99,7 +117,7 @@ def busy_wait(self):
99
117
else :
100
118
time .sleep (0.5 )
101
119
102
- def power_up (self ):
120
+ def power_up (self ) -> None :
103
121
"""Power up the display in preparation for writing RAM and updating"""
104
122
self .hardware_reset ()
105
123
time .sleep (0.2 )
@@ -134,22 +152,22 @@ def power_up(self):
134
152
self .command (_IL91874_RESOLUTION , bytearray ([_b0 , _b1 , _b2 , _b3 ]))
135
153
self .command (_IL91874_PDRF , bytearray ([0x00 ]))
136
154
137
- def power_down (self ):
155
+ def power_down (self ) -> None :
138
156
"""Power down the display - required when not actively displaying!"""
139
157
self .command (_IL91874_POWER_OFF , bytearray ([0x17 ]))
140
158
self .busy_wait ()
141
159
142
160
if self ._rst : # Only deep sleep if we can get out of it
143
161
self .command (_IL91874_DEEP_SLEEP , bytearray ([0xA5 ]))
144
162
145
- def update (self ):
163
+ def update (self ) -> None :
146
164
"""Update the display from internal memory"""
147
165
self .command (_IL91874_DISPLAY_REFRESH )
148
166
self .busy_wait ()
149
167
if not self ._busy :
150
168
time .sleep (16 ) # wait 16 seconds
151
169
152
- def write_ram (self , index ) :
170
+ def write_ram (self , index : Union [ 0 , 1 ]) -> Any :
153
171
"""Send the one byte command for starting the RAM write process. Returns
154
172
the byte read at the same time over SPI. index is the RAM buffer, can be
155
173
0 or 1 for tri-color displays."""
@@ -159,7 +177,9 @@ def write_ram(self, index):
159
177
return self .command (_IL91874_DTM2 , end = False )
160
178
raise RuntimeError ("RAM index must be 0 or 1" )
161
179
162
- def set_ram_address (self , x , y ): # pylint: disable=unused-argument, no-self-use
180
+ def set_ram_address (
181
+ self , x : int , y : int
182
+ ) -> None : # pylint: disable=unused-argument, no-self-use
163
183
"""Set the RAM address location, not used on this chipset but required by
164
184
the superclass"""
165
185
return # on this chip it does nothing
0 commit comments