Skip to content

Commit d986bb3

Browse files
committed
Merge remote-tracking branch 'origin/fix-annotations-ssd1675.py' into fix-annotations-epd.py
2 parents 5119e0c + f732181 commit d986bb3

File tree

2 files changed

+57
-17
lines changed

2 files changed

+57
-17
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]))

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

@@ -72,8 +81,17 @@ class Adafruit_SSD1680(Adafruit_EPD):
7281

7382
# pylint: disable=too-many-arguments
7483
def __init__(
75-
self, width, height, spi, *, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin
76-
):
84+
self,
85+
width: int,
86+
height: int,
87+
spi: SPI,
88+
*,
89+
cs_pin: DigitalInOut,
90+
dc_pin: DigitalInOut,
91+
sramcs_pin: DigitalInOut,
92+
rst_pin: DigitalInOut,
93+
busy_pin: DigitalInOut
94+
) -> None:
7795
super().__init__(
7896
width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin
7997
)
@@ -110,13 +128,13 @@ def __init__(
110128
self.set_color_buffer(1, False)
111129
# pylint: enable=too-many-arguments
112130

113-
def begin(self, reset=True):
131+
def begin(self, reset: bool = True) -> None:
114132
"""Begin communication with the display and set basic settings"""
115133
if reset:
116134
self.hardware_reset()
117135
self.power_down()
118136

119-
def busy_wait(self):
137+
def busy_wait(self) -> None:
120138
"""Wait for display to be done with current task, either by polling the
121139
busy pin, or pausing"""
122140
if self._busy:
@@ -125,7 +143,7 @@ def busy_wait(self):
125143
else:
126144
time.sleep(0.5)
127145

128-
def power_up(self):
146+
def power_up(self) -> None:
129147
"""Power up the display in preparation for writing RAM and updating"""
130148
self.hardware_reset()
131149
self.busy_wait()
@@ -160,20 +178,20 @@ def power_up(self):
160178
self.command(_SSD1680_SET_RAMYCOUNT, bytearray([self._height - 1, 0]))
161179
self.busy_wait()
162180

163-
def power_down(self):
181+
def power_down(self) -> None:
164182
"""Power down the display - required when not actively displaying!"""
165183
self.command(_SSD1680_DEEP_SLEEP, bytearray([0x01]))
166184
time.sleep(0.1)
167185

168-
def update(self):
186+
def update(self) -> None:
169187
"""Update the display from internal memory"""
170188
self.command(_SSD1680_DISP_CTRL2, bytearray([0xF4]))
171189
self.command(_SSD1680_MASTER_ACTIVATE)
172190
self.busy_wait()
173191
if not self._busy:
174192
time.sleep(3) # wait 3 seconds
175193

176-
def write_ram(self, index):
194+
def write_ram(self, index: Union[0, 1]) -> Any:
177195
"""Send the one byte command for starting the RAM write process. Returns
178196
the byte read at the same time over SPI. index is the RAM buffer, can be
179197
0 or 1 for tri-color displays."""
@@ -183,7 +201,9 @@ def write_ram(self, index):
183201
return self.command(_SSD1680_WRITE_REDRAM, end=False)
184202
raise RuntimeError("RAM index must be 0 or 1")
185203

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

0 commit comments

Comments
 (0)