Skip to content

Update examples to use rainbowio #16

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
17 changes: 2 additions & 15 deletions examples/rgbled_pca9685.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_pca9685
import adafruit_rgbled

Expand All @@ -24,24 +25,10 @@
# led = adafruit_rgbled.RGBLED(RED_LED, GREEN_LED, BLUE_LED, invert_pwm=True)


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))


def rainbow_cycle(wait):
for i in range(255):
i = (i + 1) % 256
led.color = wheel(i)
led.color = colorwheel(i)
time.sleep(wait)


Expand Down
17 changes: 2 additions & 15 deletions examples/rgbled_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import time
import board
from rainbowio import colorwheel
import adafruit_rgbled

# Pin the Red LED is connected to
Expand All @@ -21,24 +22,10 @@
# led = adafruit_rgbled.RGBLED(RED_LED, GREEN_LED, BLUE_LED, invert_pwm=True)


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))


def rainbow_cycle(wait):
for i in range(255):
i = (i + 1) % 256
led.color = wheel(i)
led.color = colorwheel(i)
time.sleep(wait)


Expand Down