Skip to content

Commit 6f16229

Browse files
authored
Merge pull request #1032 from adafruit/TheKitty-patch-118
CLUE Purse guide code
2 parents 4a2591a + 8f02033 commit 6f16229

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

CLUE_Purse_Slideshow/code.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Bright Wearables Purse Slideshow with FancyLED
2+
# Anne Barela for Adafruit Industries, February 2020
3+
# MIT License
4+
5+
import board
6+
import adafruit_dotstar as dotstar
7+
from adafruit_clue import clue
8+
from adafruit_slideshow import SlideShow, PlayBackDirection
9+
import adafruit_fancyled.adafruit_fancyled as fancy
10+
11+
# Set the LED ring speed and brightness
12+
LED_SPEED = 0.2 # pick a number from 0 (no motion) to 1.0 (fastest!)
13+
BRIGHTNESS = 0.2 # pick a number from 0 (dark) to 1.0 (bright!)
14+
15+
# colors available are RED, YELLOW, ORANGE, GREEN, TEAL
16+
# CYAN, BLUE, PURPLE, MAGENTA, WHITE, BLACK, GOLD, PINK
17+
# AQUA, JADE, AMBER, VIOLET, SKY - pick any color set!
18+
# 3 to 5 colors looks best...
19+
palette = [clue.PINK, clue.GOLD, clue.JADE]
20+
21+
# For the Bright Wearables DotStar LED Ring
22+
num_leds = 12
23+
pixels = dotstar.DotStar(board.P13, board.P15, num_leds, auto_write=False)
24+
offset = 0
25+
26+
# Create the BMP displayer
27+
slideshow = SlideShow(clue.display, None, folder="/",
28+
auto_advance=False)
29+
30+
# turn palette to fancytype
31+
for i, color in enumerate(palette):
32+
palette[i] = fancy.CRGB(*[x / 255 for x in color])
33+
34+
while True:
35+
if clue.button_b:
36+
slideshow.direction = PlayBackDirection.FORWARD
37+
slideshow.advance()
38+
if clue.button_a:
39+
slideshow.direction = PlayBackDirection.BACKWARD
40+
slideshow.advance()
41+
42+
# spin the LEDs
43+
for i in range(num_leds):
44+
# Load each pixel's color from the palette using an offset, run it
45+
# through the gamma function, pack RGB value and assign to pixel.
46+
color = fancy.palette_lookup(palette, offset + i / num_leds)
47+
color = fancy.gamma_adjust(color, brightness=BRIGHTNESS)
48+
pixels[i] = color.pack()
49+
pixels.show()
50+
offset += LED_SPEED / 10

0 commit comments

Comments
 (0)