add a bit of onboard led flashage

pull/536/head
helgibbons 2022-10-18 15:17:10 +01:00
rodzic ce76ff5ea3
commit 8f2837d930
2 zmienionych plików z 19 dodań i 2 usunięć

Wyświetl plik

@ -5,6 +5,7 @@ import urequests
import time
import plasma
from plasma import plasma_stick
from machine import Pin
'''
This Plasma Stick example sets your LED strip to the current #cheerlights colour.
@ -70,6 +71,9 @@ def hex_to_rgb(hex):
return r, g, b
# set up the Pico W's onboard LED
pico_led = Pin('LED', Pin.OUT)
# set up the WS2812 / NeoPixel™ LEDs
led_strip = plasma.WS2812(NUM_LEDS, 0, 0, plasma_stick.DAT)
@ -94,6 +98,11 @@ while True:
print('Data obtained!')
r.close()
# flash the onboard LED after getting data
pico_led.value(True)
time.sleep(0.2)
pico_led.value(False)
# extract hex colour from the data
hex = j['field2']

Wyświetl plik

@ -7,7 +7,7 @@ import plasma
from plasma import plasma_stick
# Random functions! randrange is for picking integers from a range, and uniform is for floats.
from random import randrange, uniform
from machine import Timer
from machine import Timer, Pin
import gc
"""
@ -15,7 +15,7 @@ Weather in a bottle!
This Plasma Stick example connects to Open Meteo to access the current weather conditions.
It then does some cool weather appropriate stuff with LEDs.
Find out more about the Open Meteo API at https://open-meteo.com
Based on original code by AxWax <3 https://github.com/axwax/Open-Meteo-Inky-Pack
Based on original code by AxWax: https://github.com/axwax/Open-Meteo-Inky-Pack
"""
# Set how many LEDs you have
@ -103,6 +103,11 @@ Conditions = {WEATHERCODES[weathercode]}
Last Open-Meteo update: {datetime_arr[0]}, {datetime_arr[1]}
""")
# flash the onboard LED after getting data
pico_led.value(True)
time.sleep(0.2)
pico_led.value(False)
# the rest of our functions are for animations!
def display_current():
@ -217,6 +222,9 @@ current_leds = [[0] * 3 for i in range(NUM_LEDS)]
# Create an list of [r, g, b] values that will hold target LED colours, to move towards
target_leds = [[0] * 3 for i in range(NUM_LEDS)]
# set up the Pico W's onboard LED
pico_led = Pin('LED', Pin.OUT)
# set up the WS2812 / NeoPixel™ LEDs
led_strip = plasma.WS2812(NUM_LEDS, 0, 0, plasma_stick.DAT)