Skip to content

Commit 1904165

Browse files
committed
Merge remote-tracking branch 'origin/fix-annotations-il0398.py' into fix-annotations-epd.py
2 parents 81fb192 + 61d59ad commit 1904165

File tree

1 file changed

+29
-9
lines changed

1 file changed

+29
-9
lines changed

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

@@ -49,8 +58,17 @@ class Adafruit_IL0398(Adafruit_EPD):
4958

5059
# pylint: disable=too-many-arguments
5160
def __init__(
52-
self, width, height, spi, *, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin
53-
):
61+
self,
62+
width: int,
63+
height: int,
64+
spi: SPI,
65+
*,
66+
cs_pin: DigitalInOut,
67+
dc_pin: DigitalInOut,
68+
sramcs_pin: DigitalInOut,
69+
rst_pin: DigitalInOut,
70+
busy_pin: DigitalInOut
71+
) -> None:
5472
super().__init__(
5573
width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin
5674
)
@@ -76,13 +94,13 @@ def __init__(
7694
self.set_color_buffer(1, True)
7795
# pylint: enable=too-many-arguments
7896

79-
def begin(self, reset=True):
97+
def begin(self, reset: bool = True) -> None:
8098
"""Begin communication with the display and set basic settings"""
8199
if reset:
82100
self.hardware_reset()
83101
self.power_down()
84102

85-
def busy_wait(self):
103+
def busy_wait(self) -> None:
86104
"""Wait for display to be done with current task, either by polling the
87105
busy pin, or pausing"""
88106
if self._busy:
@@ -92,7 +110,7 @@ def busy_wait(self):
92110
else:
93111
time.sleep(0.5)
94112

95-
def power_up(self):
113+
def power_up(self) -> None:
96114
"""Power up the display in preparation for writing RAM and updating"""
97115
self.hardware_reset()
98116
self.busy_wait()
@@ -111,22 +129,22 @@ def power_up(self):
111129
self.command(_IL0398_RESOLUTION, bytearray([_b0, _b1, _b2, _b3]))
112130
time.sleep(0.05)
113131

114-
def power_down(self):
132+
def power_down(self) -> None:
115133
"""Power down the display - required when not actively displaying!"""
116134
self.command(_IL0398_CDI, bytearray([0xF7]))
117135
self.command(_IL0398_POWER_OFF)
118136
self.busy_wait()
119137
self.command(_IL0398_DEEP_SLEEP, bytearray([0xA5]))
120138

121-
def update(self):
139+
def update(self) -> None:
122140
"""Update the display from internal memory"""
123141
self.command(_IL0398_DISPLAY_REFRESH)
124142
time.sleep(0.1)
125143
self.busy_wait()
126144
if not self._busy:
127145
time.sleep(15) # wait 15 seconds
128146

129-
def write_ram(self, index):
147+
def write_ram(self, index: Union[0, 1]) -> Any:
130148
"""Send the one byte command for starting the RAM write process. Returns
131149
the byte read at the same time over SPI. index is the RAM buffer, can be
132150
0 or 1 for tri-color displays."""
@@ -136,7 +154,9 @@ def write_ram(self, index):
136154
return self.command(_IL0398_DTM2, end=False)
137155
raise RuntimeError("RAM index must be 0 or 1")
138156

139-
def set_ram_address(self, x, y): # pylint: disable=unused-argument, no-self-use
157+
def set_ram_address(
158+
self, x: int, y: int
159+
) -> None: # pylint: disable=unused-argument, no-self-use
140160
"""Set the RAM address location, not used on this chipset but required by
141161
the superclass"""
142162
return # on this chip it does nothing

0 commit comments

Comments
 (0)