Skip to content

Commit 2b5542a

Browse files
committed
Update example to use rainbowio
1 parent 4af7a77 commit 2b5542a

File tree

2 files changed

+5
-31
lines changed

2 files changed

+5
-31
lines changed

README.rst

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,11 @@ To install in a virtual environment in your current project:
5252
Usage Example
5353
=============
5454

55-
.. code-block::python
55+
.. code-block:: python
5656
5757
import time
5858
import board
59+
from rainbowio import colorwheel
5960
import adafruit_pixie
6061
import busio
6162
@@ -65,24 +66,10 @@ Usage Example
6566
pixies = adafruit_pixie.Pixie(uart, num_pixies, brightness=0.2, auto_write=False)
6667
6768
68-
def wheel(pos):
69-
# Input a value 0 to 255 to get a color value.
70-
# The colours are a transition r - g - b - back to r.
71-
if pos < 0 or pos > 255:
72-
return 0, 0, 0
73-
if pos < 85:
74-
return int(255 - pos * 3), int(pos * 3), 0
75-
if pos < 170:
76-
pos -= 85
77-
return 0, int(255 - pos * 3), int(pos * 3)
78-
pos -= 170
79-
return int(pos * 3), 0, int(255 - (pos * 3))
80-
81-
8269
while True:
8370
for i in range(255):
8471
for pixie in range(num_pixies):
85-
pixies[pixie] = wheel(i)
72+
pixies[pixie] = colorwheel(i)
8673
pixies.show()
8774
8875
Contributing

examples/pixie_simpletest.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import time
55
import board
66
import busio
7+
from rainbowio import colorwheel
78
import adafruit_pixie
89

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

1920

20-
def wheel(pos):
21-
# Input a value 0 to 255 to get a color value.
22-
# The colours are a transition r - g - b - back to r.
23-
if pos < 0 or pos > 255:
24-
return 0, 0, 0
25-
if pos < 85:
26-
return int(255 - pos * 3), int(pos * 3), 0
27-
if pos < 170:
28-
pos -= 85
29-
return 0, int(255 - pos * 3), int(pos * 3)
30-
pos -= 170
31-
return int(pos * 3), 0, int(255 - (pos * 3))
32-
33-
3421
while True:
3522
for i in range(255):
3623
for pixie in range(num_pixies):
37-
pixies[pixie] = wheel(i)
24+
pixies[pixie] = colorwheel(i)
3825
pixies.show()
3926
time.sleep(2)
4027
pixies[0] = (0, 255, 0)

0 commit comments

Comments
 (0)