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