Skip to content
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

Add animations examples #9

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
71 changes: 69 additions & 2 deletions docs/examples.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,75 @@
Simple test
------------
Examples
===========

.. contents::

Simple Test
-----------

Ensure your device works with this simple test.

.. literalinclude:: ../examples/neopxl8_simpletest.py
:caption: examples/neopxl8_simpletest.py
:linenos:

Animations
-----------

Next, try some Adafruit animations. Here is the example program, which will run the
``Comet()`` animation on up to 8 neopixel strips from one `Feather Scorpio RP2040 <https://www.adafruit.com/product/5650>`_.

.. literalinclude:: ../examples/neopxl8_animations.py
:caption: examples/neopxl8_animations.py
:linenos:

Adafruit LED Animation Functions
--------------------------------

There are a variety of animations you can use (Pulse, Chase, Rainbow, RainbowChase, etc.).

Below are code snippets that you can test in the ``neopxl8_animations.py`` file. **NOTE** I
am only including code snippets of the required import statement and the function call.

The Blink() function
********************

Blink a color on and off.

.. code-block:: python
:emphasize-lines: 2, 5

# import the function
from adafruit_led_animation.animation.blink import Blink

# Call the Blink() function
Blink(strand, 0.1, (0, 255, 120))

**Blink() Parameters:**

:pixel_object: The initialised LED object.
:speed: Animation speed in seconds, e.g. ``0.1``.
:color: Animation color in ``(r, g, b)`` tuple, or ``0x000000`` hex format.
:name=None: *[Optional] string to represent the name of the function.*

The Chase() function
***********************

Chase pixels in one direction in a single color, like a theater marquee sign.

.. code-block:: python
:emphasize-lines: 2, 5

# import the function
from adafruit_led_animation.animation.chase import Chase

# Call the Chase() function
Chase(strand, 0.1, (0, 255, 120), size=1, spacing=2, reverse=True)

**Chase() Parameters:**

:pixel_object (adafruit_neopxl8.NeoPxl8): The initialised LED object.
:speed: Animation speed rate in seconds, e.g. ``0.1``.
:color: Animation color in ``(r, g, b)`` tuple, or ``0x000000`` hex format.
:size=2: *[Optional] Number of pixels to turn on in a row*
:spacing=3: *[Optional] Number of pixels to turn off in a row.*
:reverse=False: *[Optional] Reverse direction of movement.*