Skip to content

Commit af8ef7f

Browse files
committed
Merge remote-tracking branch 'origin/fix-annotations-il91874' into fix-annotations-epd.py
2 parents 1904165 + 207ba7e commit af8ef7f

File tree

1 file changed

+29
-9
lines changed

1 file changed

+29
-9
lines changed

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

@@ -56,8 +65,17 @@ class Adafruit_IL91874(Adafruit_EPD):
5665

5766
# pylint: disable=too-many-arguments
5867
def __init__(
59-
self, width, height, spi, *, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin
60-
):
68+
self,
69+
width: int,
70+
height: int,
71+
spi: SPI,
72+
*,
73+
cs_pin: DigitalInOut,
74+
dc_pin: DigitalInOut,
75+
sramcs_pin: DigitalInOut,
76+
rst_pin: DigitalInOut,
77+
busy_pin: DigitalInOut
78+
) -> None:
6179
super().__init__(
6280
width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin
6381
)
@@ -83,14 +101,14 @@ def __init__(
83101
self.set_color_buffer(1, False)
84102
self._single_byte_tx = True
85103

86-
def begin(self, reset=True):
104+
def begin(self, reset: bool = True) -> None:
87105
"""Begin communication with the display and set basic settings"""
88106
if reset:
89107
self.hardware_reset()
90108

91109
self.power_down()
92110

93-
def busy_wait(self):
111+
def busy_wait(self) -> None:
94112
"""Wait for display to be done with current task, either by polling the
95113
busy pin, or pausing"""
96114
if self._busy:
@@ -99,7 +117,7 @@ def busy_wait(self):
99117
else:
100118
time.sleep(0.5)
101119

102-
def power_up(self):
120+
def power_up(self) -> None:
103121
"""Power up the display in preparation for writing RAM and updating"""
104122
self.hardware_reset()
105123
time.sleep(0.2)
@@ -134,22 +152,22 @@ def power_up(self):
134152
self.command(_IL91874_RESOLUTION, bytearray([_b0, _b1, _b2, _b3]))
135153
self.command(_IL91874_PDRF, bytearray([0x00]))
136154

137-
def power_down(self):
155+
def power_down(self) -> None:
138156
"""Power down the display - required when not actively displaying!"""
139157
self.command(_IL91874_POWER_OFF, bytearray([0x17]))
140158
self.busy_wait()
141159

142160
if self._rst: # Only deep sleep if we can get out of it
143161
self.command(_IL91874_DEEP_SLEEP, bytearray([0xA5]))
144162

145-
def update(self):
163+
def update(self) -> None:
146164
"""Update the display from internal memory"""
147165
self.command(_IL91874_DISPLAY_REFRESH)
148166
self.busy_wait()
149167
if not self._busy:
150168
time.sleep(16) # wait 16 seconds
151169

152-
def write_ram(self, index):
170+
def write_ram(self, index: Union[0, 1]) -> Any:
153171
"""Send the one byte command for starting the RAM write process. Returns
154172
the byte read at the same time over SPI. index is the RAM buffer, can be
155173
0 or 1 for tri-color displays."""
@@ -159,7 +177,9 @@ def write_ram(self, index):
159177
return self.command(_IL91874_DTM2, end=False)
160178
raise RuntimeError("RAM index must be 0 or 1")
161179

162-
def set_ram_address(self, x, y): # pylint: disable=unused-argument, no-self-use
180+
def set_ram_address(
181+
self, x: int, y: int
182+
) -> None: # pylint: disable=unused-argument, no-self-use
163183
"""Set the RAM address location, not used on this chipset but required by
164184
the superclass"""
165185
return # on this chip it does nothing

0 commit comments

Comments
 (0)