Skip to content

Commit 66d1b6e

Browse files
Merge pull request #9 from RossK1/adding_type_hints
Adding type annotations
2 parents dc1cd60 + b432829 commit 66d1b6e

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

adafruit_pixel_framebuf.py

+23-16
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,21 @@
3838
"""
3939

4040
# imports
41+
try:
42+
from circuitpython_typing.led import FillBasedColorUnion
43+
except ImportError:
44+
pass
4145

42-
from micropython import const
4346
import adafruit_framebuf
4447
from adafruit_led_animation.grid import PixelGrid
48+
from micropython import const
4549

4650
__version__ = "0.0.0+auto.0"
4751
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_Pixel_Framebuf.git"
4852

49-
HORIZONTAL = const(1)
50-
VERTICAL = const(2)
53+
HORIZONTAL: int = const(1)
54+
VERTICAL: int = const(2)
55+
5156

5257
# pylint: disable=too-many-function-args
5358
class PixelFramebuffer(adafruit_framebuf.FrameBuffer):
@@ -59,6 +64,7 @@ class PixelFramebuffer(adafruit_framebuf.FrameBuffer):
5964
:param width: Framebuffer width.
6065
:param height: Framebuffer height.
6166
:param orientation: Orientation of the strip pixels - HORIZONTAL (default) or VERTICAL.
67+
HORIZONTAL and VERTICAL are primitive integers created by micropython.const(x).
6268
:param alternating: Whether the strip alternates direction from row to row (default True).
6369
:param reverse_x: Whether the strip X origin is on the right side (default False).
6470
:param reverse_y: Whether the strip Y origin is on the bottom (default False).
@@ -68,19 +74,20 @@ class PixelFramebuffer(adafruit_framebuf.FrameBuffer):
6874
6975
"""
7076

77+
# pylint: disable=too-many-arguments
7178
def __init__(
7279
self,
73-
pixels,
74-
width,
75-
height,
76-
orientation=HORIZONTAL,
77-
alternating=True,
78-
reverse_x=False,
79-
reverse_y=False,
80-
top=0,
81-
bottom=0,
82-
rotation=0,
83-
): # pylint: disable=too-many-arguments
80+
pixels: FillBasedColorUnion,
81+
width: int,
82+
height: int,
83+
orientation: int = HORIZONTAL,
84+
alternating: bool = True,
85+
reverse_x: bool = False,
86+
reverse_y: bool = False,
87+
top: int = 0,
88+
bottom: int = 0,
89+
rotation: int = 0,
90+
) -> None:
8491
self._width = width
8592
self._height = height
8693

@@ -103,11 +110,11 @@ def __init__(
103110
)
104111
self.rotation = rotation
105112

106-
def blit(self):
113+
def blit(self) -> None:
107114
"""blit is not yet implemented"""
108115
raise NotImplementedError()
109116

110-
def display(self):
117+
def display(self) -> None:
111118
"""Copy the raw buffer changes to the grid and show"""
112119
for _y in range(self._height):
113120
for _x in range(self._width):

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
Adafruit-Blinka
66
adafruit-circuitpython-framebuf>=1.4.2
77
adafruit-circuitpython-led-animation
8+
adafruit-circuitpython-typing ~=1.4

0 commit comments

Comments
 (0)