Fix missing-final-newline and missing-final-newline
This commit is contained in:
parent
a7d8e9939a
commit
e5414291ed
13 changed files with 337 additions and 337 deletions
|
|
@ -175,4 +175,4 @@ while True:
|
|||
if MODE == 1:
|
||||
animations.animate()
|
||||
if MODE == 4:
|
||||
animations.freeze()
|
||||
animations.freeze()
|
||||
|
|
|
|||
162
IoT_NeoPixel_Sign/code.py
Executable file → Normal file
162
IoT_NeoPixel_Sign/code.py
Executable file → Normal file
|
|
@ -1,81 +1,81 @@
|
|||
import ssl
|
||||
import board
|
||||
import neopixel
|
||||
import adafruit_requests
|
||||
import socketpool
|
||||
import wifi
|
||||
from adafruit_io.adafruit_io import IO_HTTP
|
||||
from adafruit_pixel_framebuf import PixelFramebuffer
|
||||
# adafruit_circuitpython_adafruitio usage with native wifi networking
|
||||
|
||||
# Neopixel matrix configuration
|
||||
PIXEL_PIN = board.IO6
|
||||
PIXEL_WIDTH = 12
|
||||
PIXEL_HEIGHT = 12
|
||||
|
||||
# secrets.py has SSID/password and adafruit.io
|
||||
try:
|
||||
from secrets import secrets
|
||||
except ImportError:
|
||||
print("WiFi secrets are kept in secrets.py, please add them there!")
|
||||
raise
|
||||
AIO_USERNAME = secrets["aio_username"]
|
||||
AIO_KEY = secrets["aio_key"]
|
||||
|
||||
# LED matrix creation
|
||||
PIXELS = neopixel.NeoPixel(
|
||||
PIXEL_PIN, PIXEL_WIDTH * PIXEL_HEIGHT, brightness=0.5, auto_write=False,
|
||||
)
|
||||
|
||||
PIXEL_FRAMEBUF = PixelFramebuffer(
|
||||
PIXELS,
|
||||
PIXEL_WIDTH,
|
||||
PIXEL_HEIGHT,
|
||||
alternating=True,
|
||||
rotation=1,
|
||||
reverse_x=True
|
||||
)
|
||||
|
||||
# Adafruit.io feeds setup
|
||||
QUOTE_FEED = "sign-quotes.signtext"
|
||||
COLOR_FEED = "sign-quotes.signcolor"
|
||||
CURRENT_TEXT = "Merry Christmas!"
|
||||
CURRENT_COLOR = 0xFFFFFF
|
||||
|
||||
# Helper function to get updated data from Adafruit.io
|
||||
def update_data():
|
||||
global CURRENT_TEXT, CURRENT_COLOR
|
||||
print("Updating data from Adafruit IO")
|
||||
try:
|
||||
quote_feed = IO.get_feed(QUOTE_FEED)
|
||||
quotes_data = IO.receive_data(quote_feed["key"])
|
||||
CURRENT_TEXT = quotes_data["value"]
|
||||
color_feed = IO.get_feed(COLOR_FEED)
|
||||
color_data = IO.receive_data(color_feed["key"])
|
||||
CURRENT_COLOR = int(color_data["value"][1:], 16)
|
||||
# pylint: disable=broad-except
|
||||
except Exception as error:
|
||||
print(error)
|
||||
|
||||
|
||||
# Connect to WiFi
|
||||
print("Connecting to %s" % secrets["ssid"])
|
||||
wifi.radio.connect(secrets["ssid"], secrets["password"])
|
||||
print("Connected to %s!" % secrets["ssid"])
|
||||
|
||||
# Setup Adafruit IO connection
|
||||
POOL = socketpool.SocketPool(wifi.radio)
|
||||
REQUESTS = adafruit_requests.Session(POOL, ssl.create_default_context())
|
||||
# Initialize an Adafruit IO HTTP API object
|
||||
IO = IO_HTTP(AIO_USERNAME, AIO_KEY, REQUESTS)
|
||||
|
||||
|
||||
while True:
|
||||
update_data()
|
||||
print("Displaying", CURRENT_TEXT, "in", hex(CURRENT_COLOR))
|
||||
|
||||
for i in range(12 * len(CURRENT_TEXT) + PIXEL_WIDTH):
|
||||
PIXEL_FRAMEBUF.fill(0x000000)
|
||||
PIXEL_FRAMEBUF.pixel(0, 0, 0x000000)
|
||||
PIXEL_FRAMEBUF.text(CURRENT_TEXT, PIXEL_WIDTH - i, 3, CURRENT_COLOR)
|
||||
PIXEL_FRAMEBUF.display()
|
||||
import ssl
|
||||
import board
|
||||
import neopixel
|
||||
import adafruit_requests
|
||||
import socketpool
|
||||
import wifi
|
||||
from adafruit_io.adafruit_io import IO_HTTP
|
||||
from adafruit_pixel_framebuf import PixelFramebuffer
|
||||
# adafruit_circuitpython_adafruitio usage with native wifi networking
|
||||
|
||||
# Neopixel matrix configuration
|
||||
PIXEL_PIN = board.IO6
|
||||
PIXEL_WIDTH = 12
|
||||
PIXEL_HEIGHT = 12
|
||||
|
||||
# secrets.py has SSID/password and adafruit.io
|
||||
try:
|
||||
from secrets import secrets
|
||||
except ImportError:
|
||||
print("WiFi secrets are kept in secrets.py, please add them there!")
|
||||
raise
|
||||
AIO_USERNAME = secrets["aio_username"]
|
||||
AIO_KEY = secrets["aio_key"]
|
||||
|
||||
# LED matrix creation
|
||||
PIXELS = neopixel.NeoPixel(
|
||||
PIXEL_PIN, PIXEL_WIDTH * PIXEL_HEIGHT, brightness=0.5, auto_write=False,
|
||||
)
|
||||
|
||||
PIXEL_FRAMEBUF = PixelFramebuffer(
|
||||
PIXELS,
|
||||
PIXEL_WIDTH,
|
||||
PIXEL_HEIGHT,
|
||||
alternating=True,
|
||||
rotation=1,
|
||||
reverse_x=True
|
||||
)
|
||||
|
||||
# Adafruit.io feeds setup
|
||||
QUOTE_FEED = "sign-quotes.signtext"
|
||||
COLOR_FEED = "sign-quotes.signcolor"
|
||||
CURRENT_TEXT = "Merry Christmas!"
|
||||
CURRENT_COLOR = 0xFFFFFF
|
||||
|
||||
# Helper function to get updated data from Adafruit.io
|
||||
def update_data():
|
||||
global CURRENT_TEXT, CURRENT_COLOR
|
||||
print("Updating data from Adafruit IO")
|
||||
try:
|
||||
quote_feed = IO.get_feed(QUOTE_FEED)
|
||||
quotes_data = IO.receive_data(quote_feed["key"])
|
||||
CURRENT_TEXT = quotes_data["value"]
|
||||
color_feed = IO.get_feed(COLOR_FEED)
|
||||
color_data = IO.receive_data(color_feed["key"])
|
||||
CURRENT_COLOR = int(color_data["value"][1:], 16)
|
||||
# pylint: disable=broad-except
|
||||
except Exception as error:
|
||||
print(error)
|
||||
|
||||
|
||||
# Connect to WiFi
|
||||
print("Connecting to %s" % secrets["ssid"])
|
||||
wifi.radio.connect(secrets["ssid"], secrets["password"])
|
||||
print("Connected to %s!" % secrets["ssid"])
|
||||
|
||||
# Setup Adafruit IO connection
|
||||
POOL = socketpool.SocketPool(wifi.radio)
|
||||
REQUESTS = adafruit_requests.Session(POOL, ssl.create_default_context())
|
||||
# Initialize an Adafruit IO HTTP API object
|
||||
IO = IO_HTTP(AIO_USERNAME, AIO_KEY, REQUESTS)
|
||||
|
||||
|
||||
while True:
|
||||
update_data()
|
||||
print("Displaying", CURRENT_TEXT, "in", hex(CURRENT_COLOR))
|
||||
|
||||
for i in range(12 * len(CURRENT_TEXT) + PIXEL_WIDTH):
|
||||
PIXEL_FRAMEBUF.fill(0x000000)
|
||||
PIXEL_FRAMEBUF.pixel(0, 0, 0x000000)
|
||||
PIXEL_FRAMEBUF.text(CURRENT_TEXT, PIXEL_WIDTH - i, 3, CURRENT_COLOR)
|
||||
PIXEL_FRAMEBUF.display()
|
||||
|
|
|
|||
|
|
@ -1,77 +1,77 @@
|
|||
"""
|
||||
NextBus class -- handles NextBus server queries and infers
|
||||
arrival times based on last-queried predictions and elapsed time.
|
||||
"""
|
||||
|
||||
# pylint: disable=bare-except, too-many-instance-attributes, too-many-arguments
|
||||
|
||||
import re
|
||||
import time
|
||||
|
||||
class NextBus():
|
||||
""" Class to handle NextBus prediction times for one route & stop.
|
||||
"""
|
||||
|
||||
def __init__(self, network, agency, route, stop, data=None,
|
||||
max_predictions=3, minimum_time=300):
|
||||
""" Constructor expects a Requests-capable Network object,
|
||||
strings for transit agency, route, and stop ID, plus optional
|
||||
per-stop data as defined by an application (e.g. text
|
||||
description, but could be an object or tuple of data, or None,
|
||||
or whatever's needed by the app), limits for the maximum number
|
||||
of future arrivals to predict (limited to server response,
|
||||
typically 5) and minimum time below which arrivals are not shown
|
||||
(to discourage unsafe bus-chasing).
|
||||
"""
|
||||
self.network = network
|
||||
self.agency = agency
|
||||
self.route = route
|
||||
self.stop = stop
|
||||
self.data = data
|
||||
self.max_predictions = max_predictions
|
||||
self.minimum_time = minimum_time
|
||||
self.predictions = []
|
||||
self.last_query_time = -1000
|
||||
|
||||
def fetch(self):
|
||||
""" Contact NextBus server and request predictions for one
|
||||
agency/route/stop.
|
||||
"""
|
||||
try:
|
||||
url = ('http://webservices.nextbus.com/service/publicXMLFeed?' +
|
||||
'command=predictions&a=' + self.agency +
|
||||
'&r=' + self.route + '&s=' + self.stop)
|
||||
response = self.network.requests.get(url)
|
||||
if response.status_code == 200:
|
||||
string = response.text
|
||||
self.last_query_time = time.monotonic()
|
||||
self.predictions = []
|
||||
while len(self.predictions) < self.max_predictions:
|
||||
# CircuitPython version of re library doesn't have findall.
|
||||
# Search for first instance of seconds="N" string and then
|
||||
# increment the string position based on match length.
|
||||
match = re.search('seconds=\"[0-9]*', string)
|
||||
if match:
|
||||
seconds = int(match.group(0)[9:]) # Remove 'seconds="'
|
||||
if seconds >= self.minimum_time:
|
||||
self.predictions.append(seconds)
|
||||
string = string[match.end():]
|
||||
else:
|
||||
break
|
||||
self.predictions.sort()
|
||||
except:
|
||||
# If server query fails, we can keep extrapolating from the
|
||||
# last set of predictions and try query again on next pass.
|
||||
pass
|
||||
|
||||
def predict(self):
|
||||
""" Extrapolate predictions based on last values queried from
|
||||
NextBus server and time elapsed since last query. Predictions
|
||||
are returned as a list of integer seconds values.
|
||||
"""
|
||||
times = []
|
||||
for predict in self.predictions:
|
||||
seconds = predict - (time.monotonic() - self.last_query_time)
|
||||
if seconds >= self.minimum_time:
|
||||
times.append(seconds)
|
||||
return times
|
||||
"""
|
||||
NextBus class -- handles NextBus server queries and infers
|
||||
arrival times based on last-queried predictions and elapsed time.
|
||||
"""
|
||||
|
||||
# pylint: disable=bare-except, too-many-instance-attributes, too-many-arguments
|
||||
|
||||
import re
|
||||
import time
|
||||
|
||||
class NextBus():
|
||||
""" Class to handle NextBus prediction times for one route & stop.
|
||||
"""
|
||||
|
||||
def __init__(self, network, agency, route, stop, data=None,
|
||||
max_predictions=3, minimum_time=300):
|
||||
""" Constructor expects a Requests-capable Network object,
|
||||
strings for transit agency, route, and stop ID, plus optional
|
||||
per-stop data as defined by an application (e.g. text
|
||||
description, but could be an object or tuple of data, or None,
|
||||
or whatever's needed by the app), limits for the maximum number
|
||||
of future arrivals to predict (limited to server response,
|
||||
typically 5) and minimum time below which arrivals are not shown
|
||||
(to discourage unsafe bus-chasing).
|
||||
"""
|
||||
self.network = network
|
||||
self.agency = agency
|
||||
self.route = route
|
||||
self.stop = stop
|
||||
self.data = data
|
||||
self.max_predictions = max_predictions
|
||||
self.minimum_time = minimum_time
|
||||
self.predictions = []
|
||||
self.last_query_time = -1000
|
||||
|
||||
def fetch(self):
|
||||
""" Contact NextBus server and request predictions for one
|
||||
agency/route/stop.
|
||||
"""
|
||||
try:
|
||||
url = ('http://webservices.nextbus.com/service/publicXMLFeed?' +
|
||||
'command=predictions&a=' + self.agency +
|
||||
'&r=' + self.route + '&s=' + self.stop)
|
||||
response = self.network.requests.get(url)
|
||||
if response.status_code == 200:
|
||||
string = response.text
|
||||
self.last_query_time = time.monotonic()
|
||||
self.predictions = []
|
||||
while len(self.predictions) < self.max_predictions:
|
||||
# CircuitPython version of re library doesn't have findall.
|
||||
# Search for first instance of seconds="N" string and then
|
||||
# increment the string position based on match length.
|
||||
match = re.search('seconds=\"[0-9]*', string)
|
||||
if match:
|
||||
seconds = int(match.group(0)[9:]) # Remove 'seconds="'
|
||||
if seconds >= self.minimum_time:
|
||||
self.predictions.append(seconds)
|
||||
string = string[match.end():]
|
||||
else:
|
||||
break
|
||||
self.predictions.sort()
|
||||
except:
|
||||
# If server query fails, we can keep extrapolating from the
|
||||
# last set of predictions and try query again on next pass.
|
||||
pass
|
||||
|
||||
def predict(self):
|
||||
""" Extrapolate predictions based on last values queried from
|
||||
NextBus server and time elapsed since last query. Predictions
|
||||
are returned as a list of integer seconds values.
|
||||
"""
|
||||
times = []
|
||||
for predict in self.predictions:
|
||||
seconds = predict - (time.monotonic() - self.last_query_time)
|
||||
if seconds >= self.minimum_time:
|
||||
times.append(seconds)
|
||||
return times
|
||||
|
|
|
|||
|
|
@ -1,99 +1,99 @@
|
|||
# SpaceX Launch Display, by Anne Barela November 2020
|
||||
# MIT License - for Adafruit Industries LLC
|
||||
# See https://github.com/r-spacex/SpaceX-API for API info
|
||||
|
||||
import time
|
||||
import terminalio
|
||||
from adafruit_magtag.magtag import MagTag
|
||||
|
||||
months = ["January", "February", "March", "April", "May", "June", "July",
|
||||
"August", "September", "October", "November", "December"]
|
||||
USE_24HR_TIME = True
|
||||
# in seconds, we can refresh about 100 times on a battery
|
||||
TIME_BETWEEN_REFRESHES = 24 * 60 * 60 # once a day delay
|
||||
|
||||
# Set up data location and fields
|
||||
DATA_SOURCE = "https://api.spacexdata.com/v4/launches/next"
|
||||
DETAIL_LOCATION = ['details']
|
||||
NAME_LOCATION = ['name']
|
||||
DATE_LOCATION = ['date_local']
|
||||
|
||||
# These functions take the JSON data keys and does checks to determine
|
||||
# how to display the data. They're used in the add_text blocks below
|
||||
|
||||
def mission_transform(val):
|
||||
if val == None:
|
||||
val = "Unavailable"
|
||||
return "Mission: " + val
|
||||
|
||||
def time_transform(val2):
|
||||
if val2 == None:
|
||||
return "When: Unavailable"
|
||||
month = int(val2[5:7])
|
||||
day = int(val2[8:10])
|
||||
hour = int(val2[11:13])
|
||||
min = int(val2[14:16])
|
||||
|
||||
if USE_24HR_TIME:
|
||||
timestring = "%d:%02d" % (hour, min)
|
||||
elif hour > 12:
|
||||
timestring = "%d:%02d pm" % (hour-12, min)
|
||||
else:
|
||||
timestring = "%d:%02d am" % (hour, min)
|
||||
|
||||
return "%s %d, at %s" % (months[month-1], day, timestring)
|
||||
|
||||
def details_transform(val3):
|
||||
if val3 == None or not len(val3):
|
||||
return "Details: To Be Determined"
|
||||
return "Details: " + val3[0:166] + "..."
|
||||
|
||||
# Set up the MagTag with the JSON data parameters
|
||||
magtag = MagTag(
|
||||
url=DATA_SOURCE,
|
||||
json_path=(NAME_LOCATION, DATE_LOCATION, DETAIL_LOCATION)
|
||||
)
|
||||
|
||||
magtag.add_text(
|
||||
text_font="/fonts/Lato-Bold-ltd-25.bdf",
|
||||
text_position=(10, 15),
|
||||
is_data=False
|
||||
)
|
||||
# Display heading text below with formatting above
|
||||
magtag.set_text("Next SpaceX Launch")
|
||||
|
||||
# Formatting for the mission text
|
||||
magtag.add_text(
|
||||
text_font="/fonts/Arial-Bold-12.pcf",
|
||||
text_position=(10, 38),
|
||||
text_transform=mission_transform
|
||||
)
|
||||
|
||||
# Formatting for the launch time text
|
||||
magtag.add_text(
|
||||
text_font="/fonts/Arial-12.bdf",
|
||||
text_position=(10, 60),
|
||||
text_transform=time_transform
|
||||
)
|
||||
|
||||
# Formatting for the details text
|
||||
magtag.add_text(
|
||||
text_font=terminalio.FONT,
|
||||
text_position=(10, 94),
|
||||
line_spacing=0.8,
|
||||
text_wrap=47, # wrap text at this count
|
||||
text_transform=details_transform
|
||||
)
|
||||
|
||||
try:
|
||||
# Have the MagTag connect to the internet
|
||||
magtag.network.connect()
|
||||
# This statement gets the JSON data and displays it automagically
|
||||
value = magtag.fetch()
|
||||
print("Response is", value)
|
||||
except (ValueError, RuntimeError) as e:
|
||||
print("Some error occured, retrying! -", e)
|
||||
|
||||
# wait 2 seconds for display to complete
|
||||
time.sleep(2)
|
||||
magtag.exit_and_deep_sleep(TIME_BETWEEN_REFRESHES)
|
||||
# SpaceX Launch Display, by Anne Barela November 2020
|
||||
# MIT License - for Adafruit Industries LLC
|
||||
# See https://github.com/r-spacex/SpaceX-API for API info
|
||||
|
||||
import time
|
||||
import terminalio
|
||||
from adafruit_magtag.magtag import MagTag
|
||||
|
||||
months = ["January", "February", "March", "April", "May", "June", "July",
|
||||
"August", "September", "October", "November", "December"]
|
||||
USE_24HR_TIME = True
|
||||
# in seconds, we can refresh about 100 times on a battery
|
||||
TIME_BETWEEN_REFRESHES = 24 * 60 * 60 # once a day delay
|
||||
|
||||
# Set up data location and fields
|
||||
DATA_SOURCE = "https://api.spacexdata.com/v4/launches/next"
|
||||
DETAIL_LOCATION = ['details']
|
||||
NAME_LOCATION = ['name']
|
||||
DATE_LOCATION = ['date_local']
|
||||
|
||||
# These functions take the JSON data keys and does checks to determine
|
||||
# how to display the data. They're used in the add_text blocks below
|
||||
|
||||
def mission_transform(val):
|
||||
if val == None:
|
||||
val = "Unavailable"
|
||||
return "Mission: " + val
|
||||
|
||||
def time_transform(val2):
|
||||
if val2 == None:
|
||||
return "When: Unavailable"
|
||||
month = int(val2[5:7])
|
||||
day = int(val2[8:10])
|
||||
hour = int(val2[11:13])
|
||||
min = int(val2[14:16])
|
||||
|
||||
if USE_24HR_TIME:
|
||||
timestring = "%d:%02d" % (hour, min)
|
||||
elif hour > 12:
|
||||
timestring = "%d:%02d pm" % (hour-12, min)
|
||||
else:
|
||||
timestring = "%d:%02d am" % (hour, min)
|
||||
|
||||
return "%s %d, at %s" % (months[month-1], day, timestring)
|
||||
|
||||
def details_transform(val3):
|
||||
if val3 == None or not len(val3):
|
||||
return "Details: To Be Determined"
|
||||
return "Details: " + val3[0:166] + "..."
|
||||
|
||||
# Set up the MagTag with the JSON data parameters
|
||||
magtag = MagTag(
|
||||
url=DATA_SOURCE,
|
||||
json_path=(NAME_LOCATION, DATE_LOCATION, DETAIL_LOCATION)
|
||||
)
|
||||
|
||||
magtag.add_text(
|
||||
text_font="/fonts/Lato-Bold-ltd-25.bdf",
|
||||
text_position=(10, 15),
|
||||
is_data=False
|
||||
)
|
||||
# Display heading text below with formatting above
|
||||
magtag.set_text("Next SpaceX Launch")
|
||||
|
||||
# Formatting for the mission text
|
||||
magtag.add_text(
|
||||
text_font="/fonts/Arial-Bold-12.pcf",
|
||||
text_position=(10, 38),
|
||||
text_transform=mission_transform
|
||||
)
|
||||
|
||||
# Formatting for the launch time text
|
||||
magtag.add_text(
|
||||
text_font="/fonts/Arial-12.bdf",
|
||||
text_position=(10, 60),
|
||||
text_transform=time_transform
|
||||
)
|
||||
|
||||
# Formatting for the details text
|
||||
magtag.add_text(
|
||||
text_font=terminalio.FONT,
|
||||
text_position=(10, 94),
|
||||
line_spacing=0.8,
|
||||
text_wrap=47, # wrap text at this count
|
||||
text_transform=details_transform
|
||||
)
|
||||
|
||||
try:
|
||||
# Have the MagTag connect to the internet
|
||||
magtag.network.connect()
|
||||
# This statement gets the JSON data and displays it automagically
|
||||
value = magtag.fetch()
|
||||
print("Response is", value)
|
||||
except (ValueError, RuntimeError) as e:
|
||||
print("Some error occured, retrying! -", e)
|
||||
|
||||
# wait 2 seconds for display to complete
|
||||
time.sleep(2)
|
||||
magtag.exit_and_deep_sleep(TIME_BETWEEN_REFRESHES)
|
||||
|
|
|
|||
2
Mask_Efficacy/process_run.py
Executable file → Normal file
2
Mask_Efficacy/process_run.py
Executable file → Normal file
|
|
@ -51,4 +51,4 @@ ax.set_ylabel("COUNT")
|
|||
ax.plot([x[0] for x in frame_data])
|
||||
fig.savefig('run_{:03d}_plot.png'.format(RUN))
|
||||
|
||||
print("DONE.")
|
||||
print("DONE.")
|
||||
|
|
|
|||
2
MetroX_CircuitPython/mib_colorful_light.py
Executable file → Normal file
2
MetroX_CircuitPython/mib_colorful_light.py
Executable file → Normal file
|
|
@ -47,4 +47,4 @@ def random_color():
|
|||
|
||||
while True:
|
||||
random_color()
|
||||
time.sleep(2)
|
||||
time.sleep(2)
|
||||
|
|
|
|||
|
|
@ -20,4 +20,4 @@ while True:
|
|||
else:
|
||||
print("BTN is up")
|
||||
|
||||
prev_state = cur_state
|
||||
prev_state = cur_state
|
||||
|
|
|
|||
|
|
@ -57,4 +57,4 @@ while True:
|
|||
# Is it time to turn OFF?
|
||||
if now >= BLINK_MAP[color]["PREV_TIME"] + BLINK_MAP[color]["ON"]:
|
||||
cp.pixels[BLINK_MAP[color]["INDEX"]] = (0, 0, 0)
|
||||
BLINK_MAP[color]["PREV_TIME"] = now
|
||||
BLINK_MAP[color]["PREV_TIME"] = now
|
||||
|
|
|
|||
|
|
@ -129,4 +129,4 @@ while True:
|
|||
elif show_next == 4:
|
||||
do_pulse("/heart.bmp", duration=4, pulse=.45)
|
||||
elif show_next == 5:
|
||||
do_crawl_down("/dark.bmp")
|
||||
do_crawl_down("/dark.bmp")
|
||||
|
|
|
|||
|
|
@ -52,4 +52,4 @@ while True:
|
|||
gfx.elections_cycle()
|
||||
except RuntimeError as e:
|
||||
print("Some error ocurred, retrying! -", e)
|
||||
continue
|
||||
continue
|
||||
|
|
|
|||
|
|
@ -94,4 +94,4 @@ while True:
|
|||
time.sleep(0.5)
|
||||
kbd.press(Keycode.V)
|
||||
kbd.release_all()
|
||||
time.sleep(.2)
|
||||
time.sleep(.2)
|
||||
|
|
|
|||
|
|
@ -254,4 +254,4 @@ while True:
|
|||
peak = peak - 0.01
|
||||
if peak > 0:
|
||||
pixels[int(peak)] = PEAK_COLOR
|
||||
pixels.show()
|
||||
pixels.show()
|
||||
|
|
|
|||
|
|
@ -1,71 +1,71 @@
|
|||
"""
|
||||
FancyLED Necklace Insert Code
|
||||
Written by Phil Burgess and Erin St Blaine for Adafruit Industries
|
||||
Full tutorial: https://learn.adafruit.com/neopixel-led-necklace-insert-with-usb-charging
|
||||
|
||||
"""
|
||||
|
||||
import board
|
||||
import neopixel
|
||||
import adafruit_fancyled.adafruit_fancyled as fancy
|
||||
|
||||
NUM_LEDS = 15
|
||||
|
||||
# Define your palettes. Add as many colors as you like.
|
||||
# You can use CRGB, CHSV or Hex format, or any combination therein
|
||||
# Select which palette you're using below the palette definitions
|
||||
|
||||
palette_fire = [fancy.CRGB(0, 0, 0), #Black
|
||||
fancy.CHSV(1.0), #Red
|
||||
fancy.CRGB(1.0, 1.0, 0.0), #Yellow
|
||||
0xFFFFFF,] #White
|
||||
|
||||
|
||||
palette_water = [fancy.CRGB(0, 214, 214), # blues and cyans
|
||||
fancy.CRGB(0, 92, 160),
|
||||
fancy.CRGB(0, 123, 255),
|
||||
fancy.CRGB(0, 100, 200),
|
||||
fancy.CRGB(0, 120, 210),
|
||||
fancy.CRGB(0, 123, 255),
|
||||
fancy.CRGB(0, 68, 214),
|
||||
fancy.CRGB(0, 68, 214),
|
||||
fancy.CRGB(0, 28, 214),
|
||||
fancy.CRGB(0, 68, 200),
|
||||
fancy.CRGB(0, 68, 214),
|
||||
fancy.CRGB(0, 200, 50),
|
||||
fancy.CRGB(0, 200, 80),
|
||||
fancy.CRGB(0, 200, 20),
|
||||
fancy.CRGB(0, 100, 50),
|
||||
fancy.CRGB(0, 150, 50),]
|
||||
|
||||
palette_forest = [0xa6db97,
|
||||
0xc6de50,
|
||||
0x2a7a02,
|
||||
0x5fb862,
|
||||
0x314a32,
|
||||
0xd5e8d6,]
|
||||
|
||||
palette_cloud = [fancy.CHSV(0.8, 1.0, 1.0),
|
||||
fancy.CHSV(0.6, 0.8, 0.7),
|
||||
fancy.CHSV(0.7, 1.0, 0.8),]
|
||||
|
||||
#choose your active palette
|
||||
palette = palette_water
|
||||
|
||||
# Declare a NeoPixel object on pin A1 with NUM_LEDS pixels, no auto-write.
|
||||
# Set brightness to max because we'll be using FancyLED's brightness control.
|
||||
pixels = neopixel.NeoPixel(board.A1, 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.005 # Bigger number = faster spin
|
||||
"""
|
||||
FancyLED Necklace Insert Code
|
||||
Written by Phil Burgess and Erin St Blaine for Adafruit Industries
|
||||
Full tutorial: https://learn.adafruit.com/neopixel-led-necklace-insert-with-usb-charging
|
||||
|
||||
"""
|
||||
|
||||
import board
|
||||
import neopixel
|
||||
import adafruit_fancyled.adafruit_fancyled as fancy
|
||||
|
||||
NUM_LEDS = 15
|
||||
|
||||
# Define your palettes. Add as many colors as you like.
|
||||
# You can use CRGB, CHSV or Hex format, or any combination therein
|
||||
# Select which palette you're using below the palette definitions
|
||||
|
||||
palette_fire = [fancy.CRGB(0, 0, 0), #Black
|
||||
fancy.CHSV(1.0), #Red
|
||||
fancy.CRGB(1.0, 1.0, 0.0), #Yellow
|
||||
0xFFFFFF,] #White
|
||||
|
||||
|
||||
palette_water = [fancy.CRGB(0, 214, 214), # blues and cyans
|
||||
fancy.CRGB(0, 92, 160),
|
||||
fancy.CRGB(0, 123, 255),
|
||||
fancy.CRGB(0, 100, 200),
|
||||
fancy.CRGB(0, 120, 210),
|
||||
fancy.CRGB(0, 123, 255),
|
||||
fancy.CRGB(0, 68, 214),
|
||||
fancy.CRGB(0, 68, 214),
|
||||
fancy.CRGB(0, 28, 214),
|
||||
fancy.CRGB(0, 68, 200),
|
||||
fancy.CRGB(0, 68, 214),
|
||||
fancy.CRGB(0, 200, 50),
|
||||
fancy.CRGB(0, 200, 80),
|
||||
fancy.CRGB(0, 200, 20),
|
||||
fancy.CRGB(0, 100, 50),
|
||||
fancy.CRGB(0, 150, 50),]
|
||||
|
||||
palette_forest = [0xa6db97,
|
||||
0xc6de50,
|
||||
0x2a7a02,
|
||||
0x5fb862,
|
||||
0x314a32,
|
||||
0xd5e8d6,]
|
||||
|
||||
palette_cloud = [fancy.CHSV(0.8, 1.0, 1.0),
|
||||
fancy.CHSV(0.6, 0.8, 0.7),
|
||||
fancy.CHSV(0.7, 1.0, 0.8),]
|
||||
|
||||
#choose your active palette
|
||||
palette = palette_water
|
||||
|
||||
# Declare a NeoPixel object on pin A1 with NUM_LEDS pixels, no auto-write.
|
||||
# Set brightness to max because we'll be using FancyLED's brightness control.
|
||||
pixels = neopixel.NeoPixel(board.A1, 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.005 # Bigger number = faster spin
|
||||
|
|
|
|||
Loading…
Reference in a new issue