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