Skip to content

Commit 827df42

Browse files
authored
Update to Limor's code
1 parent 40d7409 commit 827df42

1 file changed

Lines changed: 23 additions & 13 deletions

File tree

CLUE_Purse_Slideshow/code.py

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,28 @@
99
from adafruit_slideshow import SlideShow, PlayBackDirection
1010
import adafruit_fancyled.adafruit_fancyled as fancy
1111

12-
slideshow = SlideShow(clue.display, None, folder="/",
13-
auto_advance=False, dwell=0)
12+
# Set the LED ring speed and brightness
13+
LED_SPEED = 0.2 # pick a number from 0 (no motion) to 1.0 (fastest!)
14+
BRIGHTNESS = 0.2 # pick a number from 0 (dark) to 1.0 (bright!)
15+
16+
# colors available are RED, YELLOW, ORANGE, GREEN, TEAL
17+
# CYAN, BLUE, PURPLE, MAGENTA, WHITE, BLACK, GOLD, PINK
18+
# AQUA, JADE, AMBER, VIOLET, SKY - pick any color set!
19+
# 3 to 5 colors looks best...
20+
palette = [clue.PINK, clue.GOLD, clue.JADE]
1421

1522
# For the Bright Wearables DotStar LED Ring
1623
num_leds = 12
17-
palette = [fancy.CRGB(1.0, 0.0, 0.5), # Pink
18-
fancy.CRGB(0.0, 1.0, 0.0), # Green
19-
fancy.CRGB(0.0, 0.0, 1.0)] # Blue
20-
pixels = dotstar.DotStar(board.P13, board.P15, num_leds, brightness=0.5,
21-
auto_write=False)
22-
offset = 0 # Initialize the offset for variation (twinkle)
24+
pixels = dotstar.DotStar(board.P13, board.P15, num_leds, auto_write=False)
25+
offset = 0
26+
27+
# Create the BMP displayer
28+
slideshow = SlideShow(clue.display, None, folder="/",
29+
auto_advance=False)
30+
31+
# turn palette to fancytype
32+
for i, color in enumerate(palette):
33+
palette[i] = fancy.CRGB(*[x / 255 for x in color])
2334

2435
while True:
2536
if clue.button_b:
@@ -28,14 +39,13 @@
2839
if clue.button_a:
2940
slideshow.direction = PlayBackDirection.BACKWARD
3041
slideshow.advance()
42+
43+
# spin the LEDs
3144
for i in range(num_leds):
3245
# Load each pixel's color from the palette using an offset, run it
3346
# through the gamma function, pack RGB value and assign to pixel.
3447
color = fancy.palette_lookup(palette, offset + i / num_leds)
35-
color = fancy.gamma_adjust(color, brightness=0.25)
48+
color = fancy.gamma_adjust(color, brightness=BRIGHTNESS)
3649
pixels[i] = color.pack()
3750
pixels.show()
38-
offset = offset + 1
39-
if offset > 12:
40-
offset = 0
41-
time.sleep(0.1)
51+
offset += LED_SPEED / 10

0 commit comments

Comments
 (0)