27
27
28
28
"""
29
29
# 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
31
39
32
40
import adafruit_framebuf
33
41
from adafruit_bus_device .spi_device import SPIDevice
34
42
from micropython import const
35
43
36
44
try :
37
- from PIL import Image
38
45
import numpy
39
- from digitalio import DigitalInOut
40
46
except ImportError :
41
47
numpy = None
42
48
48
54
_SHARPMEM_BIT_CLEAR = const (0x20 ) # in lsb
49
55
50
56
51
- def reverse_bit (num : float ) :
57
+ def reverse_bit (num : int ) -> int :
52
58
"""Turn an LSB byte to an MSB byte, and vice versa. Used for SPI as
53
59
it is LSB for the SHARP, but 99% of SPI implementations are MSB only!"""
54
60
result = 0
@@ -67,10 +73,10 @@ class SharpMemoryDisplay(adafruit_framebuf.FrameBuffer):
67
73
68
74
def __init__ (
69
75
self ,
70
- spi : SPIDevice ,
76
+ spi : SPI ,
71
77
scs_pin : DigitalInOut ,
72
- width : float ,
73
- height : float ,
78
+ width : int ,
79
+ height : int ,
74
80
* ,
75
81
baudrate = 2000000 ,
76
82
):
@@ -89,7 +95,7 @@ def __init__(
89
95
# Set the vcom bit to a defined state
90
96
self ._vcom = True
91
97
92
- def show (self ):
98
+ def show (self ) -> None :
93
99
"""write out the frame buffer via SPI, we use MSB SPI only so some
94
100
bit-swapping is required.
95
101
"""
@@ -116,7 +122,7 @@ def show(self):
116
122
image_buffer .extend (self ._buf )
117
123
spi .write (image_buffer )
118
124
119
- def image (self , img : Image ):
125
+ def image (self , img : Image ) -> None :
120
126
"""Set buffer to value of Python Imaging Library image. The image should
121
127
be in 1 bit mode and a size equal to the display size."""
122
128
# determine our effective width/height, taking rotation into account
0 commit comments