Skip to content

Adding type annotations #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 23 additions & 16 deletions adafruit_pixel_framebuf.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,21 @@
"""

# imports
try:
from circuitpython_typing.led import FillBasedColorUnion
except ImportError:
pass

from micropython import const
import adafruit_framebuf
from adafruit_led_animation.grid import PixelGrid
from micropython import const

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

HORIZONTAL = const(1)
VERTICAL = const(2)
HORIZONTAL: int = const(1)
VERTICAL: int = const(2)


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

"""

# pylint: disable=too-many-arguments
def __init__(
self,
pixels,
width,
height,
orientation=HORIZONTAL,
alternating=True,
reverse_x=False,
reverse_y=False,
top=0,
bottom=0,
rotation=0,
): # pylint: disable=too-many-arguments
pixels: FillBasedColorUnion,
width: int,
height: int,
orientation: int = HORIZONTAL,
alternating: bool = True,
reverse_x: bool = False,
reverse_y: bool = False,
top: int = 0,
bottom: int = 0,
rotation: int = 0,
) -> None:
self._width = width
self._height = height

Expand All @@ -103,11 +110,11 @@ def __init__(
)
self.rotation = rotation

def blit(self):
def blit(self) -> None:
"""blit is not yet implemented"""
raise NotImplementedError()

def display(self):
def display(self) -> None:
"""Copy the raw buffer changes to the grid and show"""
for _y in range(self._height):
for _x in range(self._width):
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
Adafruit-Blinka
adafruit-circuitpython-framebuf>=1.4.2
adafruit-circuitpython-led-animation
adafruit-circuitpython-typing ~=1.4