1
- # Simple fancyled example for Circuit Playground Express
1
+ # Simple FancyLED example for Circuit Playground Express
2
2
3
3
from adafruit_circuitplayground .express import cpx
4
- import fancyled
4
+ import adafruit_fancyled as fancy
5
5
6
6
# A dynamic gradient palette is a compact representation of a color palette
7
7
# that lists only the key points (specific positions and colors), which are
17
17
# Here's where we convert the dynamic gradient palette to a full normal
18
18
# palette. First we need a list to hold the resulting palette...it can be
19
19
# filled with nonsense but the list length needs to match the desired
20
- # palette length (in FastLED, after which fancyled is modeled, color
20
+ # palette length (in FastLED, after which FancyLED is modeled, color
21
21
# palettes always have 16, 32 or 256 entries...we can actually use whatever
22
22
# length we want in CircuitPython, but for the sake of consistency, let's
23
23
# make it a 16-element palette...
24
24
palette = [0 ] * 16
25
- fancyled .loadDynamicGradientPalette (blackbody , palette )
25
+ fancy .loadDynamicGradientPalette (blackbody , palette )
26
26
27
27
# The dynamic gradient step is optional...some projects will just specify
28
28
# a whole color palette directly on their own, not expand it from bytes.
29
29
30
30
# This function fills the Circuit Playground Express NeoPixels from a
31
31
# color palette plus an offset to allow us to 'spin' the colors. In
32
- # fancyled (a la FastLED), palette indices are multiples of 16 (e.g.
32
+ # FancyLED (a la FastLED), palette indices are multiples of 16 (e.g.
33
33
# first palette entry is index 0, second is index 16, third is 32, etc)
34
34
# and indices between these values will interpolate color between the
35
35
# two nearest palette entries.
@@ -38,10 +38,10 @@ def FillLEDsFromPaletteColors(palette, offset):
38
38
# This looks up the color in the palette, scaling from
39
39
# 'palette space' (16 colors * 16 interp position = 256)
40
40
# to 'pixel space' (10 NeoPixels):
41
- c = fancyled .ColorFromPalette (palette ,
41
+ c = fancy .ColorFromPalette (palette ,
42
42
int (i * len (palette ) * 16 / 10 + offset ), 255 , True )
43
43
# Gamma correction gives more sensible-looking colors
44
- cpx .pixels [i ] = fancyled .applyGamma_video (c )
44
+ cpx .pixels [i ] = fancy .applyGamma_video (c )
45
45
46
46
# This is an offset (0-255) into the color palette to get it to 'spin'
47
47
adjust = 0
0 commit comments