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
@@ -63,8 +72,17 @@ class Adafruit_UC8151D(Adafruit_EPD):
6372
6473 # pylint: disable=too-many-arguments
6574 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 :
6886 super ().__init__ (
6987 width , height , spi , cs_pin , dc_pin , sramcs_pin , rst_pin , busy_pin
7088 )
@@ -90,13 +108,13 @@ def __init__(
90108 self .set_color_buffer (1 , True )
91109 # pylint: enable=too-many-arguments
92110
93- def begin (self , reset = True ):
111+ def begin (self , reset : bool = True ) -> None :
94112 """Begin communication with the display and set basic settings"""
95113 if reset :
96114 self .hardware_reset ()
97115 self .power_down ()
98116
99- def busy_wait (self ):
117+ def busy_wait (self ) -> None :
100118 """Wait for display to be done with current task, either by polling the
101119 busy pin, or pausing"""
102120 if self ._busy :
@@ -105,7 +123,7 @@ def busy_wait(self):
105123 else :
106124 time .sleep (0.5 )
107125
108- def power_up (self ):
126+ def power_up (self ) -> None :
109127 """Power up the display in preparation for writing RAM and updating"""
110128 self .hardware_reset ()
111129 self .busy_wait ()
@@ -119,22 +137,22 @@ def power_up(self):
119137 self .command (_UC8151D_CDI , bytearray ([0x97 ]))
120138 time .sleep (0.05 )
121139
122- def power_down (self ):
140+ def power_down (self ) -> None :
123141 """Power down the display - required when not actively displaying!"""
124142 self .command (_UC8151D_CDI , bytearray ([0xF7 ]))
125143 self .command (_UC8151D_POWER_OFF )
126144 self .busy_wait ()
127145 self .command (_UC8151D_DEEP_SLEEP , bytearray ([0xA5 ]))
128146
129- def update (self ):
147+ def update (self ) -> None :
130148 """Update the display from internal memory"""
131149 self .command (_UC8151D_DISPLAY_REFRESH )
132150 time .sleep (0.1 )
133151 self .busy_wait ()
134152 if not self ._busy :
135153 time .sleep (15 ) # wait 15 seconds
136154
137- def write_ram (self , index ) :
155+ def write_ram (self , index : Union [ 0 , 1 ]) -> Any :
138156 """Send the one byte command for starting the RAM write process. Returns
139157 the byte read at the same time over SPI. index is the RAM buffer, can be
140158 0 or 1 for tri-color displays."""
@@ -144,7 +162,9 @@ def write_ram(self, index):
144162 return self .command (_UC8151D_DTM2 , end = False )
145163 raise RuntimeError ("RAM index must be 0 or 1" )
146164
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
148168 """Set the RAM address location, not used on this chipset but required by
149169 the superclass"""
150170 return # on this chip it does nothing
0 commit comments