-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
873 additions
and
587 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
============ | ||
Example Code | ||
============ | ||
Example code has been supplied to illustrate the methods available. | ||
|
||
.. Note:: | ||
Remember to change the Strip definition to suit the LEDs connected. Each of the four terminals may use a | ||
different LED type and shape. | ||
|
||
Run the code using:: | ||
|
||
sudo python3 example.py | ||
|
||
Rainbow | ||
------- | ||
|
||
Displays a moving rainbow on your LEDs. | ||
|
||
.. literalinclude:: ../../examples/rainbow.py | ||
:language: python | ||
|
||
Shifting LEDs | ||
------------- | ||
The LED colours can be shifted by a number of LEDs and direction: | ||
|
||
Shifting LED Strings | ||
^^^^^^^^^^^^^^^^^^^^ | ||
.. literalinclude:: ../../examples/string_shift.py | ||
:language: python | ||
|
||
Shifting LED Matrices | ||
^^^^^^^^^^^^^^^^^^^^^ | ||
.. literalinclude:: ../../examples/matrix_shift.py | ||
:language: python | ||
|
||
Mirroring in an Axis | ||
-------------------- | ||
Mirroring LED Strings | ||
^^^^^^^^^^^^^^^^^^^^^ | ||
.. literalinclude:: ../../examples/string_mirror.py | ||
:language: python | ||
|
||
Mirroring LED Matrices | ||
^^^^^^^^^^^^^^^^^^^^^^ | ||
.. literalinclude:: ../../examples/matrix_mirror.py | ||
:language: python | ||
|
||
Displaying an Image | ||
------------------- | ||
Displaying Images of LED Matrices | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
.. literalinclude:: ../../examples/matrix_image.py | ||
:language: python | ||
|
||
.. :Note:: | ||
The image must be formatted in RGB format. See | ||
`Pillow image file formats <https://pillow.readthedocs.io/en/stable/handbook/image-file-formats.html>`_ | ||
You may manipulate the | ||
|
||
:Note: You can of course display an image on an LED string by supplying a 1 by x image. |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,71 @@ | ||
================ | ||
PixelPi Examples | ||
================ | ||
===================== | ||
Identifying LED Types | ||
===================== | ||
|
||
When you attach your LEDs you may not know the exact LED type they, and if it is a matrix, you may not know the order of | ||
the LEDs. Sample code has been given to help you identify both LED type and matrix shape. | ||
|
||
Connecting the LEDs to the PixelPi board | ||
---------------------------------------- | ||
WS281x LEDs have three wires which are usually red, green and white. The red wire should be connected to + on a | ||
terminal, the white to - and the green to the centre. | ||
|
||
Strings and matrices that use the same LED type may be connected together to form longer strings or larger matrices | ||
but you should note that LED brightness will diminish the further away from the start they are. | ||
|
||
:Note: Only ever connect a 5v power supply to the PixelPi board. Higher voltage will destroy the board, the Raspberry | ||
Pi, the LEDs or all three. | ||
|
||
|
||
Strings and Matrices | ||
-------------------- | ||
An LED strip, or string, is a set of LEDs on a long, flexible PCB. They come in many different lengths and LED spacing. | ||
|
||
.. image:: images/string.jpg | ||
:width: 800 | ||
:alt: An LED String | ||
|
||
LED matrices are a 2D array of LEDs: | ||
|
||
.. image:: images/matrix.jpg | ||
:width: 800 | ||
:alt: An LED Matrix | ||
|
||
Finding LED Types | ||
----------------- | ||
Once connected to the board, use the following code (in /PixelPiLibrary/examples/string_test.py or | ||
/PixelPiLibrary/examples/matrix_test.py if you are using a matrix): | ||
|
||
.. literalinclude:: ../../examples/string_test.py | ||
:language: python | ||
:emphasize-lines: 34 | ||
:linenos: | ||
|
||
Edit line 34 to set: | ||
|
||
- Which terminal your LEDs are connected to. | ||
- The number of LEDs in the string (or matrix size, in (width, height) format)) | ||
- The LED type. | ||
- If you are using a matrix, the ``shape`` must also be set to either ``matrix`` or ``zmatrix``. | ||
|
||
To run the code, use the following:: | ||
|
||
sudo python3 string_test.py | ||
|
||
or:: | ||
|
||
sudo python3 matrix_test.py | ||
|
||
:Note: ``sudo`` is currently required. | ||
|
||
If the LEDs do not display colours in the order RED, GREEN, BLUE followed by a white moving LED you should change the | ||
LED type to one of the following: | ||
|
||
WS2812, SK6812, SK6812W, SK6812_RGBW, SK6812_RBGW, SK6812_GRBW, SK6812_GBRW, SK6812_BRGW, SK6812_BGRW, WS2811_RGB, | ||
WS2811_RBG, WS2811_GRB, WS2811_GBR, WS2811_BRG, WS2811_BGR | ||
|
||
For example, your LEDs may display BLUE, GREEN then all go white. This will not damage them, but indicates you are using | ||
the incorrect type. Change the type until the colors are displayed in the right order. | ||
|
||
For a matrix, the white LED should move in the same direction for each row. If it does not, swap the ``shape`` between | ||
``zmatrix`` and ``matrix``. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,13 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import colorsys | ||
import time | ||
from pixelpi import PixelPi | ||
from pixelpi import Strip | ||
|
||
""" | ||
Available strip types (note, setting the white element of LEDs is currently not supported): | ||
strip1 = Strip(1, 300, brightness=40) | ||
strip2 = Strip(2, 300, brightness=40) | ||
strip3 = Strip(3, 300, brightness=40) | ||
strip4 = Strip(4, 300, brightness=40) | ||
|
||
* `WS2812` | ||
* `SK6812` | ||
* `SK6812W` | ||
* `SK6812_RGBW` | ||
* `SK6812_RBGW` | ||
* `SK6812_GRBW` | ||
* `SK6812_GBRW` | ||
* `SK6812_BRGW` | ||
* `SK6812_BGRW` | ||
* `WS2811_RGB` | ||
* `WS2811_RBG` | ||
* `WS2811_GRB` | ||
* `WS2811_GBR` | ||
* `WS2811_BRG` | ||
* `WS2811_BGR` | ||
""" | ||
|
||
strip = PixelPi(1, 300, striptype='WS2811_GRB', brightness=40) | ||
strip = PixelPi(2, 300, striptype='WS2811_GRB', brightness=40) | ||
strip = PixelPi(3, 300, striptype='WS2811_GRB', brightness=40) | ||
strip = PixelPi(4, 300, striptype='WS2811_GRB', brightness=40) | ||
|
||
strip.clearStrip() | ||
strip.showStrip() | ||
for strip in [strip1, strip2, strip3, strip4]: | ||
strip.clearLEDs() | ||
strip.showLEDs() | ||
del strip |
Oops, something went wrong.