Skip to content

Update example to use rainbowio #19

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 1 commit into from
Sep 23, 2021
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
19 changes: 3 additions & 16 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@ To install in a virtual environment in your current project:
Usage Example
=============

.. code-block::python
.. code-block:: python

import time
import board
from rainbowio import colorwheel
import adafruit_pixie
import busio

Expand All @@ -65,24 +66,10 @@ Usage Example
pixies = adafruit_pixie.Pixie(uart, num_pixies, brightness=0.2, auto_write=False)


def wheel(pos):
# Input a value 0 to 255 to get a color value.
# The colours are a transition r - g - b - back to r.
if pos < 0 or pos > 255:
return 0, 0, 0
if pos < 85:
return int(255 - pos * 3), int(pos * 3), 0
if pos < 170:
pos -= 85
return 0, int(255 - pos * 3), int(pos * 3)
pos -= 170
return int(pos * 3), 0, int(255 - (pos * 3))


while True:
for i in range(255):
for pixie in range(num_pixies):
pixies[pixie] = wheel(i)
pixies[pixie] = colorwheel(i)
pixies.show()

Contributing
Expand Down
17 changes: 2 additions & 15 deletions examples/pixie_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import time
import board
import busio
from rainbowio import colorwheel
import adafruit_pixie

# For use with CircuitPython:
Expand All @@ -17,24 +18,10 @@
pixies = adafruit_pixie.Pixie(uart, num_pixies, brightness=0.2, auto_write=False)


def wheel(pos):
# Input a value 0 to 255 to get a color value.
# The colours are a transition r - g - b - back to r.
if pos < 0 or pos > 255:
return 0, 0, 0
if pos < 85:
return int(255 - pos * 3), int(pos * 3), 0
if pos < 170:
pos -= 85
return 0, int(255 - pos * 3), int(pos * 3)
pos -= 170
return int(pos * 3), 0, int(255 - (pos * 3))


while True:
for i in range(255):
for pixie in range(num_pixies):
pixies[pixie] = wheel(i)
pixies[pixie] = colorwheel(i)
pixies.show()
time.sleep(2)
pixies[0] = (0, 255, 0)
Expand Down