Skip to content

Added better documentation, new example, requirements need fixed adafruit_framebuf #3

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 3 commits into from
Sep 21, 2020
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
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ repos:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
exclude: \.png$
14 changes: 13 additions & 1 deletion adafruit_pixel_framebuf.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@ class PixelFramebuffer(adafruit_framebuf.FrameBuffer):
"""
NeoPixel and Dotstar FrameBuffer for easy drawing and text on a
grid of either kind of pixel

:param strip: An object that implements the Neopixel or Dotstar protocol.
:param width: Framebuffer width.
:param height: Framebuffer height.
:param orientation: Orientation of the strip pixels - HORIZONTAL (default) or VERTICAL.
: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).
:param tuple top: (x, y) coordinates of grid top left corner (Optional)
:param tuple bottom: (x, y) coordinates of grid bottom right corner (Optional)
:param int rotation: A value of 0-3 representing the rotation of the framebuffer (default 0)

"""

def __init__(
Expand Down Expand Up @@ -96,7 +108,7 @@ def blit(self):
raise NotImplementedError()

def display(self):
"""Copy the raw buffer to the grid and show"""
"""Copy the raw buffer changes to the grid and show"""
for _y in range(self._height):
for _x in range(self._width):
index = (_y * self.stride + _x) * 3
Expand Down
Binary file added examples/blinka_16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions examples/blinka_16x16.png.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# SPDX-FileCopyrightText: 2020 Melissa LeBlanc-Williams, written for Adafruit Industries
# SPDX-License-Identifier: MIT
2 changes: 1 addition & 1 deletion examples/pixel_framebuf_16x16_animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
pixel_framebuf.line(0, 0, pixel_width - 1, pixel_height - 1, 0x00FF00)
pixel_framebuf.line(0, pixel_width - 1, pixel_height - 1, 0, 0x00FF00)
pixel_framebuf.fill_rect(2, 3, 12, 10, 0x000000)
pixel_framebuf.text(text, 16 - i, 4, 0xFFFF00)
pixel_framebuf.text(text, pixel_width - i, 4, 0xFFFF00)
pixel_framebuf.rect(1, 2, 14, 12, 0xFF0000)
pixel_framebuf.line(0, 2, 0, 14, 0x000088)
pixel_framebuf.line(pixel_width - 1, 2, pixel_width - 1, 14, 0x000088)
Expand Down
38 changes: 38 additions & 0 deletions examples/pixel_framebuf_pillow_image.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# SPDX-FileCopyrightText: 2020 Melissa LeBlanc-Williams, written for Adafruit Industries
# SPDX-License-Identifier: MIT
"""
Be sure to check the learn guides for more usage information.

This example is for use on (Linux) computers that are using CPython with
Adafruit Blinka to support CircuitPython libraries. CircuitPython does
not support PIL/pillow (python imaging library)!

Author(s): Melissa LeBlanc-Williams for Adafruit Industries
"""
import board
import neopixel
from PIL import Image
from adafruit_pixel_framebuf import PixelFramebuffer

pixel_pin = board.D18
pixel_width = 16
pixel_height = 16

pixels = neopixel.NeoPixel(
pixel_pin, pixel_width * pixel_height, brightness=0.1, auto_write=False,
)

pixel_framebuf = PixelFramebuffer(pixels, pixel_width, pixel_height, reverse_x=True,)

# Make a black background in RGBA Mode
image = Image.new("RGBA", (pixel_width, pixel_height))

# Open the icon
icon = Image.open("blinka_16x16.png")

# Alpha blend the icon onto the background
image.alpha_composite(icon)

# Convert the image to RGB and display it
pixel_framebuf.image(image.convert("RGB"))
pixel_framebuf.display()
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
# SPDX-License-Identifier: MIT

Adafruit-Blinka
adafruit-circuitpython-framebuf
adafruit-circuitpython-framebuf>=1.4.2
adafruit-circuitpython-led-animation
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
author_email="[email protected]",
install_requires=[
"Adafruit-Blinka",
"adafruit-circuitpython-framebuf",
"adafruit-circuitpython-framebuf>=1.4.2",
"adafruit-circuitpython-led-animation",
],
# Choose your license
Expand Down