|
9 | 9 | from adafruit_slideshow import SlideShow, PlayBackDirection |
10 | 10 | import adafruit_fancyled.adafruit_fancyled as fancy |
11 | 11 |
|
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] |
14 | 21 |
|
15 | 22 | # For the Bright Wearables DotStar LED Ring |
16 | 23 | 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]) |
23 | 34 |
|
24 | 35 | while True: |
25 | 36 | if clue.button_b: |
|
28 | 39 | if clue.button_a: |
29 | 40 | slideshow.direction = PlayBackDirection.BACKWARD |
30 | 41 | slideshow.advance() |
| 42 | + |
| 43 | + # spin the LEDs |
31 | 44 | for i in range(num_leds): |
32 | 45 | # Load each pixel's color from the palette using an offset, run it |
33 | 46 | # through the gamma function, pack RGB value and assign to pixel. |
34 | 47 | 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) |
36 | 49 | pixels[i] = color.pack() |
37 | 50 | 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