Skip to content

Commit 9cd001b

Browse files
Added stubbed out type versions, fixed num types, added None return types.
1 parent 2e27636 commit 9cd001b

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

adafruit_sharpmemorydisplay.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,22 @@
2727
2828
"""
2929
# pylint: enable=line-too-long
30-
from __future__ import annotations
30+
31+
32+
try:
33+
from __future__ import annotations
34+
from busio import SPI
35+
from digitalio import DigitalInOut
36+
from circuitpython_typing.pil import Image
37+
except ImportError:
38+
pass
3139

3240
import adafruit_framebuf
3341
from adafruit_bus_device.spi_device import SPIDevice
3442
from micropython import const
3543

3644
try:
37-
from PIL import Image
3845
import numpy
39-
from digitalio import DigitalInOut
4046
except ImportError:
4147
numpy = None
4248

@@ -48,7 +54,7 @@
4854
_SHARPMEM_BIT_CLEAR = const(0x20) # in lsb
4955

5056

51-
def reverse_bit(num: float):
57+
def reverse_bit(num: int) -> int:
5258
"""Turn an LSB byte to an MSB byte, and vice versa. Used for SPI as
5359
it is LSB for the SHARP, but 99% of SPI implementations are MSB only!"""
5460
result = 0
@@ -67,10 +73,10 @@ class SharpMemoryDisplay(adafruit_framebuf.FrameBuffer):
6773

6874
def __init__(
6975
self,
70-
spi: SPIDevice,
76+
spi: SPI,
7177
scs_pin: DigitalInOut,
72-
width: float,
73-
height: float,
78+
width: int,
79+
height: int,
7480
*,
7581
baudrate=2000000,
7682
):
@@ -89,7 +95,7 @@ def __init__(
8995
# Set the vcom bit to a defined state
9096
self._vcom = True
9197

92-
def show(self):
98+
def show(self) -> None:
9399
"""write out the frame buffer via SPI, we use MSB SPI only so some
94100
bit-swapping is required.
95101
"""
@@ -116,7 +122,7 @@ def show(self):
116122
image_buffer.extend(self._buf)
117123
spi.write(image_buffer)
118124

119-
def image(self, img: Image):
125+
def image(self, img: Image) -> None:
120126
"""Set buffer to value of Python Imaging Library image. The image should
121127
be in 1 bit mode and a size equal to the display size."""
122128
# determine our effective width/height, taking rotation into account

0 commit comments

Comments
 (0)