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