Skip to content

Commit 8342c3f

Browse files
committed
Added requested type annotations to ssd1675.py.
1 parent 077dd70 commit 8342c3f

File tree

1 file changed

+28
-8
lines changed

1 file changed

+28
-8
lines changed

adafruit_epd/ssd1675.py

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@
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+
23+
except ImportError:
24+
pass
25+
1726
__version__ = "0.0.0+auto.0"
1827
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_EPD.git"
1928

@@ -51,7 +60,16 @@ class Adafruit_SSD1675(Adafruit_EPD):
5160

5261
# pylint: disable=too-many-arguments
5362
def __init__(
54-
self, width, height, spi, *, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin
63+
self,
64+
width: int,
65+
height: int,
66+
spi: SPI,
67+
*,
68+
cs_pin: DigitalInOut,
69+
dc_pin: DigitalInOut,
70+
sramcs_pin: DigitalInOut,
71+
rst_pin: DigitalInOut,
72+
busy_pin: DigitalInOut
5573
):
5674
super().__init__(
5775
width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin
@@ -89,13 +107,13 @@ def __init__(
89107
self.set_color_buffer(0, True)
90108
# pylint: enable=too-many-arguments
91109

92-
def begin(self, reset=True):
110+
def begin(self, reset: bool = True) -> None:
93111
"""Begin communication with the display and set basic settings"""
94112
if reset:
95113
self.hardware_reset()
96114
self.power_down()
97115

98-
def busy_wait(self):
116+
def busy_wait(self) -> None:
99117
"""Wait for display to be done with current task, either by polling the
100118
busy pin, or pausing"""
101119
if self._busy:
@@ -104,7 +122,7 @@ def busy_wait(self):
104122
else:
105123
time.sleep(0.5)
106124

107-
def power_up(self):
125+
def power_up(self) -> None:
108126
"""Power up the display in preparation for writing RAM and updating"""
109127
self.hardware_reset()
110128
time.sleep(0.1)
@@ -147,20 +165,20 @@ def power_up(self):
147165

148166
self.busy_wait()
149167

150-
def power_down(self):
168+
def power_down(self) -> None:
151169
"""Power down the display - required when not actively displaying!"""
152170
self.command(_SSD1675_DEEP_SLEEP, bytearray([0x01]))
153171
time.sleep(0.1)
154172

155-
def update(self):
173+
def update(self) -> None:
156174
"""Update the display from internal memory"""
157175
self.command(_SSD1675_DISP_CTRL2, bytearray([0xC7]))
158176
self.command(_SSD1675_MASTER_ACTIVATE)
159177
self.busy_wait()
160178
if not self._busy:
161179
time.sleep(3) # wait 3 seconds
162180

163-
def write_ram(self, index):
181+
def write_ram(self, index: Union[0, 1]) -> Any:
164182
"""Send the one byte command for starting the RAM write process. Returns
165183
the byte read at the same time over SPI. index is the RAM buffer, can be
166184
0 or 1 for tri-color displays."""
@@ -170,7 +188,9 @@ def write_ram(self, index):
170188
return self.command(_SSD1675_WRITE_RAM2, end=False)
171189
raise RuntimeError("RAM index must be 0 or 1")
172190

173-
def set_ram_address(self, x, y): # pylint: disable=unused-argument, no-self-use
191+
def set_ram_address(
192+
self, x: int, y: int
193+
) -> None: # pylint: disable=unused-argument, no-self-use
174194
"""Set the RAM address location, not used on this chipset but required by
175195
the superclass"""
176196
self.command(_SSD1675_SET_RAMXCOUNT, bytearray([x]))

0 commit comments

Comments
 (0)