From 2b5542a5254de0fa5dcbf4e6118e31f1e2adc85a Mon Sep 17 00:00:00 2001 From: Kattni Rembor Date: Thu, 23 Sep 2021 14:26:08 -0400 Subject: [PATCH] Update example to use rainbowio --- README.rst | 19 +++---------------- examples/pixie_simpletest.py | 17 ++--------------- 2 files changed, 5 insertions(+), 31 deletions(-) diff --git a/README.rst b/README.rst index 188d458..ad73724 100644 --- a/README.rst +++ b/README.rst @@ -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 @@ -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 diff --git a/examples/pixie_simpletest.py b/examples/pixie_simpletest.py index 38da01d..7f080cc 100644 --- a/examples/pixie_simpletest.py +++ b/examples/pixie_simpletest.py @@ -4,6 +4,7 @@ import time import board import busio +from rainbowio import colorwheel import adafruit_pixie # For use with CircuitPython: @@ -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)