def routine_2(): """Adafruit Example 2.""" # Declare a NeoPixel object on pin D6 with num_leds pixels, no auto-write. # Set brightness to max because we'll be using FancyLED's brightness control. with neopixel.NeoPixel( BOARD, NUM_LEDS, brightness=1.0, auto_write=False ) as pixels: offset = 0 # Positional offset into color palette to get it to 'spin' start = time.monotonic() while True: now = time.monotonic() if abs(now - start) > RUN_SECONDS and USE_TIMER: break for i in range(NUM_LEDS): # Load each pixel's color from the palette using an offset, run it # through the gamma function, pack RGB value and assign to pixel. color = fancy.palette_lookup(PALETE, offset + i / NUM_LEDS) color = fancy.gamma_adjust(color, brightness=0.25) pixels[i] = color.pack() pixels.show() offset += 0.01 # Bigger number = faster spin
def set_palette(palette): for i in range(NUM_LEDS): # Load each pixel's color from the palette using an offset, run it # through the gamma function, pack RGB value and assign to pixel. color = fancy.palette_lookup(palette, (offset + i) / NUM_LEDS) color = fancy.gamma_adjust(color, brightness=1.0) ring[i] = color.pack() ring.show() for i in range(NUM_LEDS): # Load each pixel's color from the palette using an offset, run it # through the gamma function, pack RGB value and assign to pixel. color = fancy.palette_lookup(palette, (offset + i) / NUM_LEDS) color = fancy.gamma_adjust(color, brightness=1.0) cpx[i] = color.pack() cpx.show()
def ColorFromPalette(pal, pos, brightness=255, blend=False): """Approximates the FastLED ColorFromPalette() function ACCEPTS: color palette (list of CRGB, CSHV and/or packed ints), palette index (x16) + blend factor of next index (0-15) -- e.g. pass 32 to retrieve palette index 2, or 40 for an interpolated value between palette index 2 and 3, optional brightness (0-255), optional blend flag (True/False) RETURNS: CRGB color, no gamma correction """ # Alter 'pos' from FastLED-like behavior to fancyled range if blend: # Continuous interpolation 0.0 to 1.0 pos = (pos / 16.0) / len(pal) else: # No blending -- quantize to nearest palette bin pos = floor(pos / 16.0) / len(pal) color = fancy.palette_lookup(pal, pos) if brightness < 1.0: brightness /= 255.0 if isinstance(color, fancy.CHSV): color = fancy.CRGB(color) elif isinstance(color, int): color = fancy.unpack(color) color.red *= brightness color.green *= brightness color.blue *= brightness return color
def render(self, t): if (self.value == self.rendered_value and (self.palette_shift_speed == None or self.value == 0) and not self.dirty and self.highlight == None): return if self.last_value_t == None or self.speed is None: time_delta = self.max_val else: time_diff = t - self.last_value_t time_delta = int(time_diff / self.speed) if self.value > self.last_value: self.rendered_value = min(self.value, self.last_value + time_delta) else: self.rendered_value = max(self.value, self.last_value - time_delta) highlight_mix = abs(0.5 - ((t - self.highlight_t) % self.highlight_speed) / (self.highlight_speed) * 1.5) if self.highlight_speed != None else 0 if self.palette_shift_speed == None: palette_animation_offset = 0 else: palette_t = t if self.last_value_t == None else t - self.last_value_t palette_animation_offset = (palette_t % self.palette_shift_speed ) / self.palette_shift_speed i = 1 if self.color_from_end: palette_align = self.max_val - self.rendered_value else: palette_align = 0 for (x, y) in self.positions: if i <= self.min_value: c = None elif i <= self.rendered_value: c_idx = (i - 1 + palette_align ) * self.palette_step + palette_animation_offset c = fancy.palette_lookup(self.colors, c_idx) else: c = self.background_color if self.highlight != None and (x, y) in self.highlight: if c == None: c = fancy.CHSV(0, 0, 0.0) c = fancy.mix(self.highlight_color, c, highlight_mix) if c != None: c_packed = pack( fancy.gamma_adjust(c, brightness=self.brightness)) self.pixels[x, y] = c_packed i = i + 1 self.dirty = False
def blend(palette1, palette2, weight2, offset): """ Given two FancyLED color palettes and a weighting (0.0 to 1.0) of the second palette, plus a positional offset (where 0.0 is the start of each palette), fill the NeoPixel strip with an interpolated blend of the two palettes. """ weight2 = min(1.0, max(0.0, weight2)) # Constrain input to 0.0-1.0 weight1 = 1.0 - weight2 # palette1 weight (inverse of #2) for i in range(NUM_LEDS): position = offset + i / NUM_LEDS color1 = fancy.palette_lookup(palette1, position) color2 = fancy.palette_lookup(palette2, position) # Blend the two colors based on weight1&2, run through gamma func: color = fancy.CRGB(color1[0] * weight1 + color2[0] * weight2, color1[1] * weight1 + color2[1] * weight2, color1[2] * weight1 + color2[2] * weight2) color = fancy.gamma_adjust(color, brightness=BRIGHTNESS) PIXELS[i] = color.pack() PIXELS.show()
def brightPulse(): print("I'm about to brightPulse") global offset for i in range(10): color = fancy.palette_lookup(RainbowStripeColors, offset + i / 9) cp.pixels[i] = color.pack() time.sleep(0.15) cp.pixels.show() offset += 0.033 # Bigger number = faster spin print(offset)
def rotatePalette(): global offset while True: for i in range(pixelCount): color = fancy.palette_lookup(palette, offset + i / pixelCount) color = fancy.gamma_adjust(color, brightness=0.25) #color = fancy.gamma_adjust(color, brightness=levels) pixels[i] = color.pack() pixels.show() offset += 0.005 # Bigger number = faster spin
def rainbow_flush(delay=.02): global offset for i in range(num_leds): # Load each pixel's color from the palette using an offset, run it # through the gamma function, pack RGB value and assign to pixel. color = fancy.palette_lookup(palette, offset + i / num_leds) color = fancy.gamma_adjust(color, brightness=0.25) pixels[i] = color.pack() pixels.show() time.sleep(delay) offset += 0.02 # Bigger number = faster spin
def fire_2018(strip, offset): # heat colors palette = [ 0x330000, 0x660000, 0x990000, 0xCC0000, 0xFF0000, 0xFF3300, 0xFF6600, 0xFF9900, 0xFFCC00, 0xFFFF00, 0xFFFF33, 0xFFFF66, 0xFFFF99, 0xFFFFCC ] for i in range(num_leds): # FancyLED can handle the gamma adjustment, brightness and RGB settings color = fancy.palette_lookup(palette, offset + i / num_leds) color = fancy.gamma_adjust(color, brightness=brightness) strip[i] = color.pack()
def simple_rainbow(delay = .03): global offset num_steps = 4 for i in range(num_steps): color = fancy.palette_lookup(palette, offset + i / num_steps) color = fancy.gamma_adjust(color, brightness=0.25) col = color.pack() nleds = num_leds//num_steps start = i*nleds for j in range(start,start+nleds,1): pixels[j] = col pixels.show() offset += .02 time.sleep(delay)
def nine(): audio_file = open("9.wav", "rb") wave = audioio.WaveFile(audio_file) offset = 0 # Positional offset into color palette to get it to 'spin' audio.play(wave) while audio.playing: for i in range(num_leds): # Load each pixel's color from the palette using an offset, run it # through the gamma function, pack RGB value and assign to pixel. color = fancy.palette_lookup(palette, offset + i / num_leds) color = fancy.gamma_adjust(color, brightness=0.25) pixels[i] = color.pack() pixels.show() offset += 0.2 # Bigger number = faster spin audio_file.close() return
def rainbow_update(): """Rainbow.""" global offset for i in range(pixel_count): # Load each pixel's color from the palette using an offset, run it # through the gamma function, pack RGB value and assign to pixel. color = fancyled.palette_lookup(palette, offset + i / pixel_count) color = fancyled.gamma_adjust(color, brightness=0.25) # print("{index:>2} : {div:>2} | {mod:>2}".format( # index=i, # div=i // 4, # mod=i % 4 # )) # pixels[i // 4][i % 4] = map_01_to_16bit(color) pixels[i] = color pixels.show() offset += 0.001 # Bigger number = faster spin
def buttonAnimation(offset, fadeup, palette): # for x in range(0, 200): if ledmode != 0: # if not larson for i in range(num_leds): color = fancy.palette_lookup(palette, offset + i / num_leds) color = fancy.gamma_adjust(color, brightness=brightness) strip[i] = color.pack() strip.show() if fadeup: offset += steps if offset >= 1: fadeup = False else: offset -= steps if offset <= 0: fadeup = True return offset
def __init__(self, strip): # refer to # https://learn.adafruit.com/fancyled-library-for-circuitpython/led-colors # across the rainbow self.strip = strip self.lookup = [] self.size = self.strip.n / 2 grad = [(0.0, 0xFF0000), (0.33, 0x00FF00), (0.67, 0x0000FF), (1.0, 0xFF0000)] palette = fancy.expand_gradient(grad, 20) for index in range(self.size): coloff = index / self.size rgb = fancy.palette_lookup(palette, coloff) color = rgb.pack() self.lookup.append(color) # delete to free memory grad and palette we don't them any longer del grad del palette
def flashColor(): toggle = True count = 0 globalCount = 0 threshold = 15 global offset while True: count += 1 if (count > threshold): count = 0 globalCount += 1 threshold = (math.sin(globalCount * 0.1) * 0.5 + 0.5) * 30 + 5 if (toggle): pixels.fill((0, 0, 0)) else: fillColor = fancy.palette_lookup(palette, offset) pixels.fill(fillColor.pack()) toggle = not toggle pixels.show() offset += 0.0005 # Bigger number = faster spin
def update(self): if (self.isPlaying == False): return for effect in self.activeRivers: total = effect.total() start = effect.start() dir = effect.direction() palette = self.colorPalettes[effect.color] for i in range(total): color = fancy.palette_lookup( palette, effect.offset() + (i / self.spread) * dir) color = fancy.gamma_adjust(color, brightness=0.8) self.ledStrip[start + i] = color.pack() effect.setOffset(effect.offset() + 0.1) self.ledStrip.show()
def led_drops(strip): # FancyLED allows for mixing colors with palettes palette = [fancy.CRGB(200, 255, 200), # lighter (more white) green fancy.CRGB(0, 255, 0)] # full green for i in range(num_leds): # FancyLED can handle the gamma adjustment, brightness and RGB settings color = fancy.palette_lookup(palette, i / num_leds) color = fancy.gamma_adjust(color, brightness=brightness) strip[i] = color.pack() # turn off the LEDs as we go for raindrop effect if i >= concurrent: strip[i - concurrent] = (0,0,0) if i >= num_leds - 1: for j in range(concurrent,-1,-1): strip[i-j] = (0,0,0) time.sleep(on_time) time.sleep(on_time)
def start_colors(self, environ): print("start colors") json = json_module.loads(environ["wsgi.input"].getvalue()) if json and json.get("colors"): colors = json.get("colors") if json.get("blend"): self.palette = [] for color in colors: print(color) self.palette.append(fancy.CRGB(color.get("r"),color.get("g"), color.get("b"))) self.period = json.get("period") if json.get("period") else 0 self.duty_cycle = json.get("duty_cycle") if json.get("duty_cycle") else 1 if json.get("animate"): self.is_displaying = display_type.COLORS_GRAD_ANIMATE return ("200 OK", [], []) partition_size = num_pixels // len(colors) remainder = num_pixels % len(colors) if json.get("blend"): for i in range(num_pixels): pos = (i / ((num_pixels * len(colors)) / (len(colors) - 1) ) ) color = fancy.palette_lookup(self.palette, pos) print('pos', pos) print('color', color) color = fancy.gamma_adjust(color, brightness=0.5) self.colors_pixels[i] = color.pack() else: for idx, color in enumerate(colors): color = fancy.CRGB(color.get("r"),color.get("g"), color.get("b")) # color = fancy.gamma_adjust(color, brightness=0.5) current_idx = idx * partition_size use_remainder = remainder if idx == len(colors) - 1 else 0 self.colors_pixels[current_idx: current_idx + partition_size + use_remainder] = [color.pack()] * (partition_size + use_remainder) self.is_displaying = display_type.COLORS return ("200 OK", [], [])
""" Simple FancyLED example for Circuit Playground Express """ from adafruit_circuitplayground.express import cpx import adafruit_fancyled.adafruit_fancyled as fancy cpx.pixels.auto_write = False # Refresh pixels only when we say cpx.pixels.brightness = 1.0 # We'll use FancyLED's brightness controls # Declare a 4-element color palette, this one happens to be a # 'blackbody' palette -- good for heat maps and firey effects. palette = [fancy.CRGB(1.0, 1.0, 1.0), # White fancy.CRGB(1.0, 1.0, 0.0), # Yellow fancy.CRGB(1.0, 0.0, 0.0), # Red fancy.CRGB(0.0, 0.0, 0.0)] # Black offset = 0 # Positional offset into color palette to get it to 'spin' levels = (0.25, 0.3, 0.15) # Color balance / brightness for gamma function while True: for i in range(10): # Load each pixel's color from the palette using an offset, run it # through the gamma function, pack RGB value and assign to pixel. color = fancy.palette_lookup(palette, offset + i / 10) color = fancy.gamma_adjust(color, brightness=levels) cpx.pixels[i] = color.pack() cpx.pixels.show() offset += 0.033 # Bigger number = faster spin
print("Setting pixels to RGB", colorway) pixels.fill(colorway.pack()) pixels.show() set_rgb_led(pixels[0]) # set RGB LED as same as first pixel else: # its a list of colors to cycle through print("Setting pixels to a pallete of", colorway) swirl = 0 # we'll swirl through the colors in the color way while switch.value: # button pressed? quit! for i in range(NEOPIXEL_NUM): # the index into the palette is from 0 to 1.0 and uses the pixels # number and the swirl number to take us through the whole thing! pallete_index = ((swirl + i) % NEOPIXEL_NUM) / NEOPIXEL_NUM # Then look up the color in the pallete color_lookup = fancy.palette_lookup(colorway, pallete_index) # display it! pixels[i] = color_lookup.pack() # check button often if not switch.value: break # if its pressed, quit now pixels.show() # show the pixels! set_rgb_led(pixels[0]) # set RGB LED as same as first pixel swirl += 1 # never stop swirlin! print('Done with pallete display') while switch.value: pass # hang out and wait for the button to be pressed while not switch.value: pass # hang out and wait for the button to be released! print("Button pressed")
return average while True: if cpx.switch: if analogIn_1: analogValue = analogIn_1.value average = scaleAndTranslate(analogIn_1.value, 0, 65535, 0, 3) scaleValue = scaleAndTranslate(analogValue, 0, 65535, 0, 3) cpx.pixels.brightness = weightedSmooth(scaleValue, 0.8) for i in range(10): color = fancy.palette_lookup(palette_purple, offset + i / 9) cpx.pixels[i] = color.pack() cpx.pixels.show() offset += 0.033 # Bigger number = faster spin time.sleep(0.01) if analogIn_2: analogValue = analogIn_2.value average = scaleAndTranslate(analogIn_2.value, 0, 65535, 0, 10) scaleValue = scaleAndTranslate(analogValue, 0, 65535, 0, 10) for i in range(10): color = fancy.palette_lookup(palette_purple, offset + i / 9) cpx.pixels[i] = color.pack() cpx.pixels.show()
for idx, station in enumerate(STATION_LIST): station_url = '{:04}{:02}{:02}/{}/'.format(now.tm_year, now.tm_mon, now.tm_mday, station) file_url = '{:04}-{:02}-{:02}-{:02}00-{}-AUTO-swob.xml'.format( now.tm_year, now.tm_mon, now.tm_mday, now.tm_hour, station) file_url = BASE_URL + station_url + file_url print("Fetching obs from", file_url) r = requests.get(file_url) data_count = 0 for elm in xmltok.tokenize(io.StringIO(r.text)): data_count -= 1 if (elm[0] == 'ATTR') and (elm[2] == VAR_STRING): data_count = 2 if data_count == 0: latest_var[idx] = float(elm[2]) r.close() print(latest_var) for i, v in enumerate(latest_var): print(i) if v is not None: pix_val = (v - min(latest_var)) / (max(latest_var) + 1 - min(latest_var)) pix_col = fancy.palette_lookup(palette, pix_val) pix_col = fancy.gamma_adjust(pix_col, brightness=levels) pixels[i] = pix_col.pack() print(v) # TODO: Update every hour print("Done!")
# Our accelerometer i2c = busio.I2C(board.ACCELEROMETER_SCL, board.ACCELEROMETER_SDA) accelerometer = adafruit_adxl34x.ADXL345(i2c) # Play the welcome wav (if its there) with audioio.AudioOut(board.A1, right_channel=board.A0) as audio: try: f = open("welcome.wav", "rb") wave = audiocore.WaveFile(f) audio.play(wave) swirl = 0 # we'll swirl through the colors in the gradient while audio.playing: for i in range(32): palette_index = ((swirl+i) % 32) / 32 color = fancy.palette_lookup(INTRO_SWIRL, palette_index) # display it! trellis.pixels[(i//8, i%8)] = color.pack() swirl += 1 time.sleep(0.005) f.close() # Clear all pixels trellis.pixels.fill(0) # just hold a moment time.sleep(0.5) except OSError: # no biggie, they probably deleted it pass # Parse the first file to figure out what format its in
""" from adafruit_circuitplayground.express import cpx import adafruit_fancyled.adafruit_fancyled as fancy cpx.pixels.auto_write = False # Refresh pixels only when we say cpx.pixels.brightness = 1.0 # We'll use FancyLED's brightness controls # Declare a 4-element color palette, this one happens to be a # 'blackbody' palette -- good for heat maps and firey effects. palette = [ fancy.CRGB(1.0, 1.0, 1.0), # White fancy.CRGB(1.0, 1.0, 0.0), # Yellow fancy.CRGB(1.0, 0.0, 0.0), # Red fancy.CRGB(0.0, 0.0, 0.0) ] # Black offset = 0 # Positional offset into color palette to get it to 'spin' levels = (0.25, 0.3, 0.15) # Color balance / brightness for gamma function while True: for i in range(10): # Load each pixel's color from the palette using an offset, run it # through the gamma function, pack RGB value and assign to pixel. color = fancy.palette_lookup(palette, offset + i / 10) color = fancy.gamma_adjust(color, brightness=levels) cpx.pixels[i] = color.pack() cpx.pixels.show() offset += 0.033 # Bigger number = faster spin
def process_display(self): if self.is_displaying == display_type.COLORS and self.colors_pixels: pixels[:] = self.colors_pixels pixels.show() self._blink() if self.is_displaying == display_type.COLORS_GRAD_ANIMATE and self.palette: # pos = self.animation_step / (len(self.palette) / (len(self.palette) - 1)) # self.animation_step += 0.1 / min(3, len(self.palette)) # color = fancy.palette_lookup(self.palette, pos) # color = fancy.gamma_adjust(color, brightness=0.5) # pixels.fill(color.pack()) # pixels.show() # self._blink() sleep = 0.05 self.animation_step += sleep / ( len(self.palette) * self.period ) print(sleep / ( len(self.palette) * self.period )) # print(self.animation_step) color = fancy.palette_lookup(self.palette, self.animation_step) # print(color) # color = fancy.gamma_adjust(color, brightness=0.5) pixels.fill(color.pack()) pixels.show() # time.sleep(sleep*0.5) if self.is_displaying == display_type.BMP and self.current_display: print("start displaying") rowSize = (self.display_width * 3) print("current_display_size: ", len(self.current_display)) # rowCounter = 0 # rgb = [] # for val in self.current_display: # if (len(rgb) == 3): # print("rgb", rgb) # pixels[rowCounter] = tuple(rgb) # rgb = [] # rgb.append(val) # rowCounter += 1 # else: # rgb.append(val) # if (rowCounter == self.display_width): # print("row finished") # pixels.show() # time.sleep(0.1) # rowCounter = 0 # print("done!") for row in range(self.display_height): # print("row", row) pixel_index = 0 for col in range(self.display_width): # print("col", col) idx = (rowSize * row) + (col * 3) # print("idx", idx) # print("rgb ", tuple(self.current_display[idx:idx+3])) pixels[pixel_index] = tuple(self.current_display[idx:idx+3]) pixel_index += 1 # print(pixels) pixels.show() time.sleep(0.01) if (not self.loop_image): self.is_displaying = display_type.OFF pixels.fill((0,0,0)) pixels.show()
t0 = time.monotonic() while time.monotonic() - t0 < 1: button.update() if button.just_pressed(): clicks += 1 update_console(clicks, 1) # Allow another second to press the button again t0 = time.monotonic() time.sleep(0.01) timer_limit = clicks * timer_step timer_start = time.monotonic() # Update omnitool o_hue += o_step * (2 * random.random() - 1) omnitool[0] = fancy.palette_lookup(palette, o_hue).pack() omnitool.brightness = o_brit + o_varb * (2 * random.random() - 1) omnitool.show() # Update console if mode == "ambient": console[0] = fancy.CHSV(c_hue - c_delta).pack() console[1] = fancy.CHSV(c_hue).pack() console[2] = fancy.CHSV(c_hue + c_delta).pack() c_hue += c_step if c_hue > 1: c_hue -= 1 console.show() elif mode == "timer": t = time.monotonic() elapsed = t - timer_start
import neopixel import adafruit_fancyled.adafruit_fancyled as fancy num_leds = 20 # Declare a 6-element RGB rainbow palette palette = [fancy.CRGB(1.0, 0.0, 0.0), # Red fancy.CRGB(0.5, 0.5, 0.0), # Yellow fancy.CRGB(0.0, 1.0, 0.0), # Green fancy.CRGB(0.0, 0.5, 0.5), # Cyan fancy.CRGB(0.0, 0.0, 1.0), # Blue fancy.CRGB(0.5, 0.0, 0.5)] # Magenta # Declare a NeoPixel object on pin D6 with num_leds pixels, no auto-write. # Set brightness to max because we'll be using FancyLED's brightness control. pixels = neopixel.NeoPixel(board.D6, num_leds, brightness=1.0, auto_write=False) offset = 0 # Positional offset into color palette to get it to 'spin' while True: for i in range(num_leds): # Load each pixel's color from the palette using an offset, run it # through the gamma function, pack RGB value and assign to pixel. color = fancy.palette_lookup(palette, offset + i / num_leds) color = fancy.gamma_adjust(color, brightness=0.25) pixels[i] = color.pack() pixels.show() offset += 0.02 # Bigger number = faster spin
wave = audiocore.WaveFile(wave_file) snowing = True has_sound = True weather_refresh = time.monotonic() except RuntimeError as e: print("Some error occured, retrying! -", e) time.sleep(5) continue if not audio.playing and has_sound: if not thundering: audio.play(wave) if palette: for i in range(len(pixels)): color = fancy.palette_lookup(palette, pal_offset + i / len(pixels)) color = fancy.gamma_adjust(color, brightness=levels) pixels[i] = color.pack() pixels.show() pal_offset += 0.01 # Bigger number = faster spin if raining: # don't have a droplet every time for i in range(random.randint(1, 5)): # up to 3 times... pixels[random.randint(0, len(pixels) - 1)] = 0x0000FF # make a random pixel Blue pixels.show() if snowing: # don't have a droplet every time
while uart_client.connected: # Connected switch.update() if switch.fell: # Check for button press try: uart_client.write(button_packet.to_bytes()) # Transmit press except OSError: pass # Check for LED status receipt if uart_client.in_waiting: packet = Packet.from_stream(uart_client) if isinstance(packet, ColorPacket): if fancy.CRGB(*packet.color).pack() == GREEN: # Color match # Green indicates on state palette = fancy.expand_gradient(gradients['On'], 30) else: # Otherwise red indicates off palette = fancy.expand_gradient(gradients['Off'], 30) # NeoPixel color fading routing color = fancy.palette_lookup(palette, color_index / 29) color = fancy.gamma_adjust(color, brightness=gamma_levels) c = color.pack() pixels[0] = c pixels.show() if color_index == 0 or color_index == 28: fade_direction *= -1 # Change direction color_index += fade_direction sleep(0.02)
(0.20, 0x333333), (0.40, 0x666666), (0.60, 0x999999), (0.80, 0xCCCCCC), (1.0, 0xEEEEEE), ] # Creating the grayscale Palette using the FancyLed Library palette = fancy.expand_gradient(grad, 50) colors = list() # We create an equal space palette. This is done for convenience and clarity as we use # a value from 0 to 100 in our ProgressBar for i in range(99): color = fancy.palette_lookup(palette, i / 100) colors.append(color.pack()) # Background creation color_bitmap = displayio.Bitmap(display.width, display.height, 1) color_palette = displayio.Palette(1) color_palette[0] = 0x2266AA # Teal-ish-kinda bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0) splash.append(bg_sprite) horizontal_bar = HorizontalProgressBar( (10, 80), (180, 40), fill_color=0x990099,
elif ledmode == 4: palette = allRed elif ledmode == 5: palette = lava elif ledmode == 6: palette = sunset elif ledmode == 7: palette = allGold elif ledmode == 8: palette = forest elif ledmode == 9: palette = ocean elif ledmode == 10: palette = allPurple elif ledmode == 11: palette = galaxy for i in range(num_leds): color = fancy.palette_lookup(palette, offset + i / num_leds) color = fancy.gamma_adjust(color, brightness) strip[i] = color.pack() strip.show() if fadeup: offset += steps if offset >= 1: fadeup = False else: offset -= steps if offset <= 0: fadeup = True
def show_spinning_track(pixels, palette): for i in range(len(pixels)): color = fancy.palette_lookup(palette, offset + i / (len(pixels) - 1)) pixels[i] = color.pack() pixels.show()