Skip to content

Commit dab9e2f

Browse files
authored
Merge pull request #3 from makermelissa/main
Added better documentation, new example, requirements need fixed adafruit_framebuf
2 parents 48f8a95 + deaa442 commit dab9e2f

8 files changed

+57
-4
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ repos:
1717
- id: check-yaml
1818
- id: end-of-file-fixer
1919
- id: trailing-whitespace
20+
exclude: \.png$

adafruit_pixel_framebuf.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,18 @@ class PixelFramebuffer(adafruit_framebuf.FrameBuffer):
5454
"""
5555
NeoPixel and Dotstar FrameBuffer for easy drawing and text on a
5656
grid of either kind of pixel
57+
58+
:param strip: An object that implements the Neopixel or Dotstar protocol.
59+
:param width: Framebuffer width.
60+
:param height: Framebuffer height.
61+
:param orientation: Orientation of the strip pixels - HORIZONTAL (default) or VERTICAL.
62+
:param alternating: Whether the strip alternates direction from row to row (default True).
63+
:param reverse_x: Whether the strip X origin is on the right side (default False).
64+
:param reverse_y: Whether the strip Y origin is on the bottom (default False).
65+
:param tuple top: (x, y) coordinates of grid top left corner (Optional)
66+
:param tuple bottom: (x, y) coordinates of grid bottom right corner (Optional)
67+
:param int rotation: A value of 0-3 representing the rotation of the framebuffer (default 0)
68+
5769
"""
5870

5971
def __init__(
@@ -96,7 +108,7 @@ def blit(self):
96108
raise NotImplementedError()
97109

98110
def display(self):
99-
"""Copy the raw buffer to the grid and show"""
111+
"""Copy the raw buffer changes to the grid and show"""
100112
for _y in range(self._height):
101113
for _x in range(self._width):
102114
index = (_y * self.stride + _x) * 3

examples/blinka_16x16.png

3.1 KB
Loading

examples/blinka_16x16.png.license

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# SPDX-FileCopyrightText: 2020 Melissa LeBlanc-Williams, written for Adafruit Industries
2+
# SPDX-License-Identifier: MIT

examples/pixel_framebuf_16x16_animation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
pixel_framebuf.line(0, 0, pixel_width - 1, pixel_height - 1, 0x00FF00)
2424
pixel_framebuf.line(0, pixel_width - 1, pixel_height - 1, 0, 0x00FF00)
2525
pixel_framebuf.fill_rect(2, 3, 12, 10, 0x000000)
26-
pixel_framebuf.text(text, 16 - i, 4, 0xFFFF00)
26+
pixel_framebuf.text(text, pixel_width - i, 4, 0xFFFF00)
2727
pixel_framebuf.rect(1, 2, 14, 12, 0xFF0000)
2828
pixel_framebuf.line(0, 2, 0, 14, 0x000088)
2929
pixel_framebuf.line(pixel_width - 1, 2, pixel_width - 1, 14, 0x000088)
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# SPDX-FileCopyrightText: 2020 Melissa LeBlanc-Williams, written for Adafruit Industries
2+
# SPDX-License-Identifier: MIT
3+
"""
4+
Be sure to check the learn guides for more usage information.
5+
6+
This example is for use on (Linux) computers that are using CPython with
7+
Adafruit Blinka to support CircuitPython libraries. CircuitPython does
8+
not support PIL/pillow (python imaging library)!
9+
10+
Author(s): Melissa LeBlanc-Williams for Adafruit Industries
11+
"""
12+
import board
13+
import neopixel
14+
from PIL import Image
15+
from adafruit_pixel_framebuf import PixelFramebuffer
16+
17+
pixel_pin = board.D18
18+
pixel_width = 16
19+
pixel_height = 16
20+
21+
pixels = neopixel.NeoPixel(
22+
pixel_pin, pixel_width * pixel_height, brightness=0.1, auto_write=False,
23+
)
24+
25+
pixel_framebuf = PixelFramebuffer(pixels, pixel_width, pixel_height, reverse_x=True,)
26+
27+
# Make a black background in RGBA Mode
28+
image = Image.new("RGBA", (pixel_width, pixel_height))
29+
30+
# Open the icon
31+
icon = Image.open("blinka_16x16.png")
32+
33+
# Alpha blend the icon onto the background
34+
image.alpha_composite(icon)
35+
36+
# Convert the image to RGB and display it
37+
pixel_framebuf.image(image.convert("RGB"))
38+
pixel_framebuf.display()

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
# SPDX-License-Identifier: MIT
55

66
Adafruit-Blinka
7-
adafruit-circuitpython-framebuf
7+
adafruit-circuitpython-framebuf>=1.4.2
88
adafruit-circuitpython-led-animation

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
author_email="[email protected]",
3737
install_requires=[
3838
"Adafruit-Blinka",
39-
"adafruit-circuitpython-framebuf",
39+
"adafruit-circuitpython-framebuf>=1.4.2",
4040
"adafruit-circuitpython-led-animation",
4141
],
4242
# Choose your license

0 commit comments

Comments
 (0)