Skip to content

Commit eb4391f

Browse files
committed
Added requested type annotations to ssd1680.py.
1 parent 5a89c94 commit eb4391f

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

adafruit_epd/ssd1680.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
import adafruit_framebuf
1515
from 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+
1723
__version__ = "0.0.0+auto.0"
1824
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_EPD.git"
1925

@@ -72,8 +78,10 @@ class Adafruit_SSD1680(Adafruit_EPD):
7278

7379
# pylint: disable=too-many-arguments
7480
def __init__(
75-
self, width, height, spi, *, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin
76-
):
81+
self, width: int, height: int, spi: SPI, *, cs_pin: DigitalInOut,
82+
dc_pin: DigitalInOut, sramcs_pin: DigitalInOut, rst_pin: DigitalInOut,
83+
busy_pin: DigitalInOut
84+
) -> None:
7785
super().__init__(
7886
width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin
7987
)
@@ -110,13 +118,13 @@ def __init__(
110118
self.set_color_buffer(1, False)
111119
# pylint: enable=too-many-arguments
112120

113-
def begin(self, reset=True):
121+
def begin(self, reset: bool=True) -> None:
114122
"""Begin communication with the display and set basic settings"""
115123
if reset:
116124
self.hardware_reset()
117125
self.power_down()
118126

119-
def busy_wait(self):
127+
def busy_wait(self) -> None:
120128
"""Wait for display to be done with current task, either by polling the
121129
busy pin, or pausing"""
122130
if self._busy:
@@ -125,7 +133,7 @@ def busy_wait(self):
125133
else:
126134
time.sleep(0.5)
127135

128-
def power_up(self):
136+
def power_up(self) -> None:
129137
"""Power up the display in preparation for writing RAM and updating"""
130138
self.hardware_reset()
131139
self.busy_wait()
@@ -160,20 +168,20 @@ def power_up(self):
160168
self.command(_SSD1680_SET_RAMYCOUNT, bytearray([self._height - 1, 0]))
161169
self.busy_wait()
162170

163-
def power_down(self):
171+
def power_down(self) -> None:
164172
"""Power down the display - required when not actively displaying!"""
165173
self.command(_SSD1680_DEEP_SLEEP, bytearray([0x01]))
166174
time.sleep(0.1)
167175

168-
def update(self):
176+
def update(self) -> None:
169177
"""Update the display from internal memory"""
170178
self.command(_SSD1680_DISP_CTRL2, bytearray([0xF4]))
171179
self.command(_SSD1680_MASTER_ACTIVATE)
172180
self.busy_wait()
173181
if not self._busy:
174182
time.sleep(3) # wait 3 seconds
175183

176-
def write_ram(self, index):
184+
def write_ram(self, index: Union[0, 1]) -> Any:
177185
"""Send the one byte command for starting the RAM write process. Returns
178186
the byte read at the same time over SPI. index is the RAM buffer, can be
179187
0 or 1 for tri-color displays."""
@@ -183,7 +191,7 @@ def write_ram(self, index):
183191
return self.command(_SSD1680_WRITE_REDRAM, end=False)
184192
raise RuntimeError("RAM index must be 0 or 1")
185193

186-
def set_ram_address(self, x, y): # pylint: disable=unused-argument, no-self-use
194+
def set_ram_address(self, x: int, y: int) -> None: # pylint: disable=unused-argument, no-self-use
187195
"""Set the RAM address location, not used on this chipset but required by
188196
the superclass"""
189197
# Set RAM X address counter

0 commit comments

Comments
 (0)