1414import adafruit_framebuf
1515from adafruit_epd .epd import Adafruit_EPD
1616
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+
1726__version__ = "0.0.0+auto.0"
1827__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_EPD.git"
1928
@@ -48,8 +57,17 @@ class Adafruit_IL0373(Adafruit_EPD):
4857
4958 # pylint: disable=too-many-arguments
5059 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 :
5371 super ().__init__ (
5472 width , height , spi , cs_pin , dc_pin , sramcs_pin , rst_pin , busy_pin
5573 )
@@ -75,13 +93,13 @@ def __init__(
7593 self .set_color_buffer (1 , True )
7694 # pylint: enable=too-many-arguments
7795
78- def begin (self , reset = True ):
96+ def begin (self , reset : bool = True ) -> None :
7997 """Begin communication with the display and set basic settings"""
8098 if reset :
8199 self .hardware_reset ()
82100 self .power_down ()
83101
84- def busy_wait (self ):
102+ def busy_wait (self ) -> None :
85103 """Wait for display to be done with current task, either by polling the
86104 busy pin, or pausing"""
87105 if self ._busy :
@@ -90,7 +108,7 @@ def busy_wait(self):
90108 else :
91109 time .sleep (0.5 )
92110
93- def power_up (self ):
111+ def power_up (self ) -> None :
94112 """Power up the display in preparation for writing RAM and updating"""
95113 self .hardware_reset ()
96114 self .busy_wait ()
@@ -112,21 +130,21 @@ def power_up(self):
112130 self .command (_IL0373_VCM_DC_SETTING , bytearray ([0x0A ]))
113131 time .sleep (0.05 )
114132
115- def power_down (self ):
133+ def power_down (self ) -> None :
116134 """Power down the display - required when not actively displaying!"""
117135 self .command (_IL0373_CDI , bytearray ([0x17 ]))
118136 self .command (_IL0373_VCM_DC_SETTING , bytearray ([0x00 ]))
119137 self .command (_IL0373_POWER_OFF )
120138
121- def update (self ):
139+ def update (self ) -> None :
122140 """Update the display from internal memory"""
123141 self .command (_IL0373_DISPLAY_REFRESH )
124142 time .sleep (0.1 )
125143 self .busy_wait ()
126144 if not self ._busy :
127145 time .sleep (15 ) # wait 15 seconds
128146
129- def write_ram (self , index ) :
147+ def write_ram (self , index : Union [ 0 , 1 ]) -> Any :
130148 """Send the one byte command for starting the RAM write process. Returns
131149 the byte read at the same time over SPI. index is the RAM buffer, can be
132150 0 or 1 for tri-color displays."""
@@ -136,7 +154,9 @@ def write_ram(self, index):
136154 return self .command (_IL0373_DTM2 , end = False )
137155 raise RuntimeError ("RAM index must be 0 or 1" )
138156
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
140160 """Set the RAM address location, not used on this chipset but required by
141161 the superclass"""
142162 return # on this chip it does nothing
0 commit comments