1414import adafruit_framebuf
1515from adafruit_epd .epd import Adafruit_EPD
1616
17+ try :
18+ from typing import Union , Any
19+ from busio import SPI
20+ from digitalio import DigitalInOut
21+
22+ except ImportError :
23+ pass
24+
1725__version__ = "0.0.0+auto.0"
1826__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_EPD.git"
1927
@@ -72,8 +80,17 @@ class Adafruit_SSD1681(Adafruit_EPD):
7280
7381 # pylint: disable=too-many-arguments
7482 def __init__ (
75- self , width , height , spi , * , cs_pin , dc_pin , sramcs_pin , rst_pin , busy_pin
76- ):
83+ self ,
84+ width : int ,
85+ height : int ,
86+ spi : SPI ,
87+ * ,
88+ cs_pin : DigitalInOut ,
89+ dc_pin : DigitalInOut ,
90+ sramcs_pin : DigitalInOut ,
91+ rst_pin : DigitalInOut ,
92+ busy_pin : DigitalInOut
93+ ) -> None :
7794 super ().__init__ (
7895 width , height , spi , cs_pin , dc_pin , sramcs_pin , rst_pin , busy_pin
7996 )
@@ -101,13 +118,13 @@ def __init__(
101118 self .set_color_buffer (1 , False )
102119 # pylint: enable=too-many-arguments
103120
104- def begin (self , reset = True ):
121+ def begin (self , reset : bool = True ) -> None :
105122 """Begin communication with the display and set basic settings"""
106123 if reset :
107124 self .hardware_reset ()
108125 self .power_down ()
109126
110- def busy_wait (self ):
127+ def busy_wait (self ) -> None :
111128 """Wait for display to be done with current task, either by polling the
112129 busy pin, or pausing"""
113130 if self ._busy :
@@ -116,7 +133,7 @@ def busy_wait(self):
116133 else :
117134 time .sleep (0.5 )
118135
119- def power_up (self ):
136+ def power_up (self ) -> None :
120137 """Power up the display in preparation for writing RAM and updating"""
121138 self .hardware_reset ()
122139 self .busy_wait ()
@@ -143,20 +160,20 @@ def power_up(self):
143160
144161 self .busy_wait ()
145162
146- def power_down (self ):
163+ def power_down (self ) -> None :
147164 """Power down the display - required when not actively displaying!"""
148165 self .command (_SSD1681_DEEP_SLEEP , bytearray ([0x01 ]))
149166 time .sleep (0.1 )
150167
151- def update (self ):
168+ def update (self ) -> None :
152169 """Update the display from internal memory"""
153170 self .command (_SSD1681_DISP_CTRL2 , bytearray ([0xF7 ]))
154171 self .command (_SSD1681_MASTER_ACTIVATE )
155172 self .busy_wait ()
156173 if not self ._busy :
157174 time .sleep (3 ) # wait 3 seconds
158175
159- def write_ram (self , index ) :
176+ def write_ram (self , index : Union [ 0 , 1 ]) -> Any :
160177 """Send the one byte command for starting the RAM write process. Returns
161178 the byte read at the same time over SPI. index is the RAM buffer, can be
162179 0 or 1 for tri-color displays."""
@@ -166,7 +183,9 @@ def write_ram(self, index):
166183 return self .command (_SSD1681_WRITE_REDRAM , end = False )
167184 raise RuntimeError ("RAM index must be 0 or 1" )
168185
169- def set_ram_address (self , x , y ): # pylint: disable=unused-argument, no-self-use
186+ def set_ram_address (
187+ self , x : int , y : int
188+ ) -> None : # pylint: disable=unused-argument, no-self-use
170189 """Set the RAM address location, not used on this chipset but required by
171190 the superclass"""
172191 # Set RAM X address counter
0 commit comments