def heat_animation(delay=0.02): global heat_offset for i in range(num_leds): # Load each pixel's color from the palette. FastLED uses 16-step # in-between blending...so for a 16-color palette, there's 256 # steps total. With 10 pixels, multiply the pixel index by 25.5 # (and add our offset) to get FastLED-style palette position. color = helper.ColorFromPalette(heat_palette, int(heat_offset + i * 25.5), blend=True) # color = helper.ColorFromPalette(ocean_palette, int(heat_offset + i * 6.375), blend=True) # Apply gamma using the FastLED helper syntax color = helper.applyGamma_video(color) # 'Pack' color and assign to NeoPixel #i pixels[i] = color.pack() pixels.show() time.sleep(delay) heat_offset += 8 # Bigger number = faster spin
0, 0, # Red 255, 0, 0, 0 ]) # Black # fmt: on # Convert the gradient palette into a normal palette w/16 elements: palette = helper.loadDynamicGradientPalette(heatmap_gp, 16) offset = 0 # Positional offset into color palette to get it to 'spin' while True: for i in range(10): # Load each pixel's color from the palette. FastLED uses 16-step # in-between blending...so for a 16-color palette, there's 256 # steps total. With 10 pixels, multiply the pixel index by 25.5 # (and add our offset) to get FastLED-style palette position. color = helper.ColorFromPalette(palette, int(offset + i * 25.5), blend=True) # Apply gamma using the FastLED helper syntax color = helper.applyGamma_video(color) # 'Pack' color and assign to NeoPixel #i cpx.pixels[i] = color.pack() cpx.pixels.show() offset += 8 # Bigger number = faster spin