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
@@ -49,8 +58,17 @@ class Adafruit_IL0398(Adafruit_EPD):
49
58
50
59
# pylint: disable=too-many-arguments
51
60
def __init__ (
52
- self , width , height , spi , * , cs_pin , dc_pin , sramcs_pin , rst_pin , busy_pin
53
- ):
61
+ self ,
62
+ width : int ,
63
+ height : int ,
64
+ spi : SPI ,
65
+ * ,
66
+ cs_pin : DigitalInOut ,
67
+ dc_pin : DigitalInOut ,
68
+ sramcs_pin : DigitalInOut ,
69
+ rst_pin : DigitalInOut ,
70
+ busy_pin : DigitalInOut
71
+ ) -> None :
54
72
super ().__init__ (
55
73
width , height , spi , cs_pin , dc_pin , sramcs_pin , rst_pin , busy_pin
56
74
)
@@ -76,13 +94,13 @@ def __init__(
76
94
self .set_color_buffer (1 , True )
77
95
# pylint: enable=too-many-arguments
78
96
79
- def begin (self , reset = True ):
97
+ def begin (self , reset : bool = True ) -> None :
80
98
"""Begin communication with the display and set basic settings"""
81
99
if reset :
82
100
self .hardware_reset ()
83
101
self .power_down ()
84
102
85
- def busy_wait (self ):
103
+ def busy_wait (self ) -> None :
86
104
"""Wait for display to be done with current task, either by polling the
87
105
busy pin, or pausing"""
88
106
if self ._busy :
@@ -92,7 +110,7 @@ def busy_wait(self):
92
110
else :
93
111
time .sleep (0.5 )
94
112
95
- def power_up (self ):
113
+ def power_up (self ) -> None :
96
114
"""Power up the display in preparation for writing RAM and updating"""
97
115
self .hardware_reset ()
98
116
self .busy_wait ()
@@ -111,22 +129,22 @@ def power_up(self):
111
129
self .command (_IL0398_RESOLUTION , bytearray ([_b0 , _b1 , _b2 , _b3 ]))
112
130
time .sleep (0.05 )
113
131
114
- def power_down (self ):
132
+ def power_down (self ) -> None :
115
133
"""Power down the display - required when not actively displaying!"""
116
134
self .command (_IL0398_CDI , bytearray ([0xF7 ]))
117
135
self .command (_IL0398_POWER_OFF )
118
136
self .busy_wait ()
119
137
self .command (_IL0398_DEEP_SLEEP , bytearray ([0xA5 ]))
120
138
121
- def update (self ):
139
+ def update (self ) -> None :
122
140
"""Update the display from internal memory"""
123
141
self .command (_IL0398_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 (_IL0398_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