Skip to content

Commit 5119e0c

Browse files
committed
Merge remote-tracking branch 'origin/fix-annotations-ssd1608.py' into fix-annotations-epd.py
2 parents b55613c + 22eeabb commit 5119e0c

File tree

1 file changed

+29
-9
lines changed

1 file changed

+29
-9
lines changed

adafruit_epd/ssd1608.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

@@ -57,8 +66,17 @@ class Adafruit_SSD1608(Adafruit_EPD):
5766

5867
# pylint: disable=too-many-arguments
5968
def __init__(
60-
self, width, height, spi, *, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin
61-
):
69+
self,
70+
width: int,
71+
height: int,
72+
spi: SPI,
73+
*,
74+
cs_pin: DigitalInOut,
75+
dc_pin: DigitalInOut,
76+
sramcs_pin: DigitalInOut,
77+
rst_pin: DigitalInOut,
78+
busy_pin: DigitalInOut
79+
) -> None:
6280
super().__init__(
6381
width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin
6482
)
@@ -80,13 +98,13 @@ def __init__(
8098
self.set_color_buffer(0, True)
8199
# pylint: enable=too-many-arguments
82100

83-
def begin(self, reset=True):
101+
def begin(self, reset: bool = True) -> None:
84102
"""Begin communication with the display and set basic settings"""
85103
if reset:
86104
self.hardware_reset()
87105
self.power_down()
88106

89-
def busy_wait(self):
107+
def busy_wait(self) -> None:
90108
"""Wait for display to be done with current task, either by polling the
91109
busy pin, or pausing"""
92110
if self._busy:
@@ -95,7 +113,7 @@ def busy_wait(self):
95113
else:
96114
time.sleep(0.5)
97115

98-
def power_up(self):
116+
def power_up(self) -> None:
99117
"""Power up the display in preparation for writing RAM and updating"""
100118
self.hardware_reset()
101119
self.busy_wait()
@@ -125,28 +143,30 @@ def power_up(self):
125143
self.command(_SSD1608_WRITE_LUT, _LUT_DATA)
126144
self.busy_wait()
127145

128-
def power_down(self):
146+
def power_down(self) -> None:
129147
"""Power down the display - required when not actively displaying!"""
130148
self.command(_SSD1608_DEEP_SLEEP, bytearray([0x01]))
131149
time.sleep(0.1)
132150

133-
def update(self):
151+
def update(self) -> None:
134152
"""Update the display from internal memory"""
135153
self.command(_SSD1608_DISP_CTRL2, bytearray([0xC7]))
136154
self.command(_SSD1608_MASTER_ACTIVATE)
137155
self.busy_wait()
138156
if not self._busy:
139157
time.sleep(3) # wait 3 seconds
140158

141-
def write_ram(self, index):
159+
def write_ram(self, index: Union[0]) -> Any:
142160
"""Send the one byte command for starting the RAM write process. Returns
143161
the byte read at the same time over SPI. index is the RAM buffer, can be
144162
0 or 1 for tri-color displays."""
145163
if index == 0:
146164
return self.command(_SSD1608_WRITE_RAM, end=False)
147165
raise RuntimeError("RAM index must be 0")
148166

149-
def set_ram_address(self, x, y): # pylint: disable=unused-argument, no-self-use
167+
def set_ram_address(
168+
self, x: int, y: int
169+
) -> None: # pylint: disable=unused-argument, no-self-use
150170
"""Set the RAM address location, not used on this chipset but required by
151171
the superclass"""
152172
# Set RAM X address counter

0 commit comments

Comments
 (0)