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
@@ -48,8 +57,17 @@ class Adafruit_IL0373(Adafruit_EPD):
48
57
49
58
# pylint: disable=too-many-arguments
50
59
def __init__ (
51
- self , width , height , spi , * , cs_pin , dc_pin , sramcs_pin , rst_pin , busy_pin
52
- ):
60
+ self ,
61
+ width : int ,
62
+ height : int ,
63
+ spi : SPI ,
64
+ * ,
65
+ cs_pin : DigitalInOut ,
66
+ dc_pin : DigitalInOut ,
67
+ sramcs_pin : DigitalInOut ,
68
+ rst_pin : DigitalInOut ,
69
+ busy_pin : DigitalInOut
70
+ ) -> None :
53
71
super ().__init__ (
54
72
width , height , spi , cs_pin , dc_pin , sramcs_pin , rst_pin , busy_pin
55
73
)
@@ -75,13 +93,13 @@ def __init__(
75
93
self .set_color_buffer (1 , True )
76
94
# pylint: enable=too-many-arguments
77
95
78
- def begin (self , reset = True ):
96
+ def begin (self , reset : bool = True ) -> None :
79
97
"""Begin communication with the display and set basic settings"""
80
98
if reset :
81
99
self .hardware_reset ()
82
100
self .power_down ()
83
101
84
- def busy_wait (self ):
102
+ def busy_wait (self ) -> None :
85
103
"""Wait for display to be done with current task, either by polling the
86
104
busy pin, or pausing"""
87
105
if self ._busy :
@@ -90,7 +108,7 @@ def busy_wait(self):
90
108
else :
91
109
time .sleep (0.5 )
92
110
93
- def power_up (self ):
111
+ def power_up (self ) -> None :
94
112
"""Power up the display in preparation for writing RAM and updating"""
95
113
self .hardware_reset ()
96
114
self .busy_wait ()
@@ -112,21 +130,21 @@ def power_up(self):
112
130
self .command (_IL0373_VCM_DC_SETTING , bytearray ([0x0A ]))
113
131
time .sleep (0.05 )
114
132
115
- def power_down (self ):
133
+ def power_down (self ) -> None :
116
134
"""Power down the display - required when not actively displaying!"""
117
135
self .command (_IL0373_CDI , bytearray ([0x17 ]))
118
136
self .command (_IL0373_VCM_DC_SETTING , bytearray ([0x00 ]))
119
137
self .command (_IL0373_POWER_OFF )
120
138
121
- def update (self ):
139
+ def update (self ) -> None :
122
140
"""Update the display from internal memory"""
123
141
self .command (_IL0373_DISPLAY_REFRESH )
124
142
time .sleep (0.1 )
125
143
self .busy_wait ()
126
144
if not self ._busy :
127
145
time .sleep (15 ) # wait 15 seconds
128
146
129
- def write_ram (self , index ) :
147
+ def write_ram (self , index : Union [ 0 , 1 ]) -> Any :
130
148
"""Send the one byte command for starting the RAM write process. Returns
131
149
the byte read at the same time over SPI. index is the RAM buffer, can be
132
150
0 or 1 for tri-color displays."""
@@ -136,7 +154,9 @@ def write_ram(self, index):
136
154
return self .command (_IL0373_DTM2 , end = False )
137
155
raise RuntimeError ("RAM index must be 0 or 1" )
138
156
139
- def set_ram_address (self , x , y ): # pylint: disable=unused-argument, no-self-use
157
+ def set_ram_address (
158
+ self , x : int , y : int
159
+ ) -> None : # pylint: disable=unused-argument, no-self-use
140
160
"""Set the RAM address location, not used on this chipset but required by
141
161
the superclass"""
142
162
return # on this chip it does nothing
0 commit comments