From 8f2837d93056a43e1b49de9def3c673fa38a13ca Mon Sep 17 00:00:00 2001 From: helgibbons <50950368+helgibbons@users.noreply.github.com> Date: Tue, 18 Oct 2022 15:17:10 +0100 Subject: [PATCH] add a bit of onboard led flashage --- micropython/examples/plasma_stick/cheerlights.py | 9 +++++++++ micropython/examples/plasma_stick/weather.py | 12 ++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/micropython/examples/plasma_stick/cheerlights.py b/micropython/examples/plasma_stick/cheerlights.py index eb1d6b2a..70fcb47d 100644 --- a/micropython/examples/plasma_stick/cheerlights.py +++ b/micropython/examples/plasma_stick/cheerlights.py @@ -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'] diff --git a/micropython/examples/plasma_stick/weather.py b/micropython/examples/plasma_stick/weather.py index 190cd1e3..934dbc2e 100644 --- a/micropython/examples/plasma_stick/weather.py +++ b/micropython/examples/plasma_stick/weather.py @@ -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)