Skip to content

Commit 3b7e9b4

Browse files
committed
Added requested type annotations to ssd1675b.py.
1 parent 5a89c94 commit 3b7e9b4

File tree

1 file changed

+29
-9
lines changed

1 file changed

+29
-9
lines changed

adafruit_epd/ssd1675b.py

Lines changed: 29 additions & 9 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

@@ -77,8 +86,17 @@ class Adafruit_SSD1675B(Adafruit_EPD):
7786

7887
# pylint: disable=too-many-arguments
7988
def __init__(
80-
self, width, height, spi, *, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin
81-
):
89+
self,
90+
width: int,
91+
height: int,
92+
spi: SPI,
93+
*,
94+
cs_pin: DigitalInOut,
95+
dc_pin: DigitalInOut,
96+
sramcs_pin: DigitalInOut,
97+
rst_pin: DigitalInOut,
98+
busy_pin: DigitalInOut
99+
) -> None:
82100
super().__init__(
83101
width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin
84102
)
@@ -115,13 +133,13 @@ def __init__(
115133
self.set_color_buffer(0, True)
116134
# pylint: enable=too-many-arguments
117135

118-
def begin(self, reset=True):
136+
def begin(self, reset: bool = True) -> None:
119137
"""Begin communication with the display and set basic settings"""
120138
if reset:
121139
self.hardware_reset()
122140
self.power_down()
123141

124-
def busy_wait(self):
142+
def busy_wait(self) -> None:
125143
"""Wait for display to be done with current task, either by polling the
126144
busy pin, or pausing"""
127145
if self._busy:
@@ -130,7 +148,7 @@ def busy_wait(self):
130148
else:
131149
time.sleep(0.5)
132150

133-
def power_up(self):
151+
def power_up(self) -> None:
134152
"""Power up the display in preparation for writing RAM and updating"""
135153
self.hardware_reset()
136154
time.sleep(0.1)
@@ -189,20 +207,20 @@ def power_up(self):
189207

190208
self.busy_wait()
191209

192-
def power_down(self):
210+
def power_down(self) -> None:
193211
"""Power down the display - required when not actively displaying!"""
194212
self.command(_SSD1675B_DEEP_SLEEP, bytearray([0x01]))
195213
time.sleep(0.1)
196214

197-
def update(self):
215+
def update(self) -> None:
198216
"""Update the display from internal memory"""
199217
self.command(_SSD1675B_DISP_CTRL2, bytearray([0xC7]))
200218
self.command(_SSD1675B_MASTER_ACTIVATE)
201219
self.busy_wait()
202220
if not self._busy:
203221
time.sleep(3) # wait 3 seconds
204222

205-
def write_ram(self, index):
223+
def write_ram(self, index: Union[0, 1]) -> Any:
206224
"""Send the one byte command for starting the RAM write process. Returns
207225
the byte read at the same time over SPI. index is the RAM buffer, can be
208226
0 or 1 for tri-color displays."""
@@ -212,7 +230,9 @@ def write_ram(self, index):
212230
return self.command(_SSD1675B_WRITE_RAM2, end=False)
213231
raise RuntimeError("RAM index must be 0 or 1")
214232

215-
def set_ram_address(self, x, y): # pylint: disable=unused-argument, no-self-use
233+
def set_ram_address(
234+
self, x: int, y: int
235+
) -> None: # pylint: disable=unused-argument, no-self-use
216236
"""Set the RAM address location, not used on this chipset but required by
217237
the superclass"""
218238
self.command(_SSD1675B_SET_RAMXCOUNT, bytearray([x]))

0 commit comments

Comments
 (0)