Skip to content

Commit e8cfe65

Browse files
committed
example code. fixing todos and docs things
1 parent e9e2ac4 commit e8cfe65

File tree

3 files changed

+81
-18
lines changed

3 files changed

+81
-18
lines changed

README.rst

+33-10
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,10 @@ This is easily achieved by downloading
3636
or individual libraries can be installed using
3737
`circup <https://github.com/adafruit/circup>`_.
3838

39-
.. todo:: Describe the Adafruit product this library works with. For PCBs, you can also add the
40-
image from the assets folder in the PCB's GitHub repo.
39+
* `NeoPixel Products <https://www.adafruit.com/category/168>`_
4140

42-
`Purchase one from the Adafruit shop <http://www.adafruit.com/products/>`_
4341
Installing from PyPI
4442
=====================
45-
.. note:: This library is not available on PyPI yet. Install documentation is included
46-
as a standard element. Stay tuned for PyPI availability!
47-
48-
.. todo:: Remove the above note if PyPI version is/will be available at time of release.
4943

5044
On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from
5145
PyPI <https://pypi.org/project/adafruit-circuitpython-pixelmap/>`_.
@@ -85,7 +79,7 @@ following command to install:
8579

8680
.. code-block:: shell
8781
88-
circup install pixelmap
82+
circup install adafruit_pixelmap
8983
9084
Or the following command to update an existing version:
9185

@@ -96,8 +90,37 @@ Or the following command to update an existing version:
9690
Usage Example
9791
=============
9892

99-
.. todo:: Add a quick, simple example. It and other examples should live in the
100-
examples folder and be included in docs/examples.rst.
93+
.. code-block:: python
94+
95+
import board
96+
import neopixel
97+
import time
98+
from adafruit_pixelmap import PixelMap, horizontal_strip_gridmap, vertical_strip_gridmap
99+
100+
# Update to match the pin connected to your NeoPixels
101+
pixel_pin = board.NEOPIXEL
102+
103+
# Update to match the number of NeoPixels you have connected
104+
pixel_num = 32
105+
106+
pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.1, auto_write=True)
107+
108+
pixel_wing_vertical = PixelMap.vertical_lines(
109+
pixels, 8, 4, horizontal_strip_gridmap(8, alternating=False)
110+
)
111+
pixel_wing_horizontal = PixelMap.horizontal_lines(
112+
pixels, 8, 4, horizontal_strip_gridmap(8, alternating=False)
113+
)
114+
115+
for row in range(len(pixel_wing_horizontal)):
116+
pixels.fill(0x00000)
117+
pixel_wing_horizontal[row] = 0x00ff00
118+
time.sleep(0.3)
119+
120+
for row in range(len(pixel_wing_vertical)):
121+
pixels.fill(0x00000)
122+
pixel_wing_vertical[row] = 0xff00ff
123+
time.sleep(0.3)
101124
102125
Documentation
103126
=============

docs/index.rst

+2-4
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,12 @@ Table of Contents
2424
.. toctree::
2525
:caption: Tutorials
2626

27-
.. todo:: Add any Learn guide links here. If there are none, then simply delete this todo and leave
28-
the toctree above for use later.
27+
Led Animations Guide - Pixel Mapping <https://learn.adafruit.com/circuitpython-led-animations/pixel-mapping>
2928

3029
.. toctree::
3130
:caption: Related Products
3231

33-
.. todo:: Add any product links here. If there are none, then simply delete this todo and leave
34-
the toctree above for use later.
32+
NeoPixel Products <https://www.adafruit.com/category/168>
3533

3634
.. toctree::
3735
:caption: Other Links

examples/pixelmap_simpletest.py

+46-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,46 @@
1-
# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
2-
# SPDX-FileCopyrightText: Copyright (c) 2022 Tim Cocks for Adafruit Industries
3-
#
4-
# SPDX-License-Identifier: Unlicense
1+
# SPDX-FileCopyrightText: 2022 Tim Cocks for Adafruit Industries
2+
# SPDX-License-Identifier: MIT
3+
4+
"""
5+
This example shows usage of the PixelMap helper to easily treat a single strip as a horizontal or
6+
vertical grid for animation purposes.
7+
8+
For NeoPixel FeatherWing. Update pixel_pin and pixel_num to match your wiring if using
9+
a different form of NeoPixels. Note that if you are using a number of pixels other than 32, you
10+
will need to alter the PixelMap values as well for this example to work.
11+
12+
This example does not work on SAMD21 (M0) boards.
13+
"""
14+
import time
15+
import board
16+
import neopixel
17+
from adafruit_pixelmap import PixelMap, horizontal_strip_gridmap
18+
19+
# board.NEOPIXEL is the pin on the NeoTrellis M4.
20+
# Update to match the pin that your neopixels are connected to.
21+
pixel_pin = board.NEOPIXEL
22+
23+
# Update to match the number of NeoPixels you have connected
24+
pixel_num = 32
25+
26+
pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=0.1, auto_write=True)
27+
28+
pixel_wing_vertical = PixelMap.vertical_lines(
29+
pixels, 8, 4, horizontal_strip_gridmap(8, alternating=False)
30+
)
31+
pixel_wing_horizontal = PixelMap.horizontal_lines(
32+
pixels, 8, 4, horizontal_strip_gridmap(8, alternating=False)
33+
)
34+
35+
for i, row in enumerate(pixel_wing_horizontal):
36+
pixels.fill(0x00000)
37+
pixel_wing_horizontal[i] = 0x00FF00
38+
time.sleep(0.3)
39+
40+
for i, col in enumerate(pixel_wing_vertical):
41+
pixels.fill(0x00000)
42+
pixel_wing_vertical[i] = 0xFF00FF
43+
time.sleep(0.3)
44+
45+
while True:
46+
pass

0 commit comments

Comments
 (0)