Skip to content

Commit e163b97

Browse files
added typing for image, scs, and, reverse_bit num
1 parent 7aa8e90 commit e163b97

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

adafruit_sharpmemorydisplay.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@
3333
from micropython import const
3434

3535
try:
36+
from PIL import Image
3637
import numpy
38+
from digitalio import DigitalInOut
3739
except ImportError:
3840
numpy = None
3941

@@ -45,7 +47,7 @@
4547
_SHARPMEM_BIT_CLEAR = const(0x20) # in lsb
4648

4749

48-
def reverse_bit(num):
50+
def reverse_bit(num: float):
4951
"""Turn an LSB byte to an MSB byte, and vice versa. Used for SPI as
5052
it is LSB for the SHARP, but 99% of SPI implementations are MSB only!"""
5153
result = 0
@@ -62,7 +64,15 @@ class SharpMemoryDisplay(adafruit_framebuf.FrameBuffer):
6264

6365
# pylint: disable=too-many-instance-attributes,abstract-method
6466

65-
def __init__(self, spi, scs_pin, width, height, *, baudrate=2000000):
67+
def __init__(
68+
self,
69+
spi: SPIDevice,
70+
scs_pin: DigitalInOut,
71+
width: float,
72+
height: float,
73+
*,
74+
baudrate=2000000
75+
):
6676
scs_pin.switch_to_output(value=True)
6777
self.spi_device = SPIDevice(
6878
spi, scs_pin, cs_active_value=True, baudrate=baudrate
@@ -105,7 +115,7 @@ def show(self):
105115
image_buffer.extend(self._buf)
106116
spi.write(image_buffer)
107117

108-
def image(self, img):
118+
def image(self, img: Image):
109119
"""Set buffer to value of Python Imaging Library image. The image should
110120
be in 1 bit mode and a size equal to the display size."""
111121
# determine our effective width/height, taking rotation into account

0 commit comments

Comments
 (0)