kopia lustrzana https://github.com/pimoroni/pimoroni-pico
Stellar: Tweak & tidy examples.
rodzic
67152e32e5
commit
94c5d74894
|
@ -54,7 +54,7 @@ Clock example with (optional) NTP synchronization. You can adjust the brightness
|
||||||
|
|
||||||
[eighties_super_computer.py](eighties_super_computer.py)
|
[eighties_super_computer.py](eighties_super_computer.py)
|
||||||
|
|
||||||
Random LEDs blink on and off mimicing the look of a movie super computer doing its work in the eighties. You can adjust the brightness with LUX + and -.
|
Random LEDs blink on and off mimicking the look of a movie super computer doing its work in the eighties. You can adjust the brightness with LUX + and -.
|
||||||
|
|
||||||
### Feature Test
|
### Feature Test
|
||||||
|
|
||||||
|
|
|
@ -11,14 +11,46 @@ from network_manager import NetworkManager
|
||||||
import uasyncio
|
import uasyncio
|
||||||
import urequests
|
import urequests
|
||||||
import time
|
import time
|
||||||
|
import random
|
||||||
from machine import Timer, Pin
|
from machine import Timer, Pin
|
||||||
from stellar import StellarUnicorn
|
from stellar import StellarUnicorn
|
||||||
from picographics import PicoGraphics, DISPLAY_STELLAR_UNICORN as DISPLAY
|
from picographics import PicoGraphics, DISPLAY_STELLAR_UNICORN as DISPLAY, PEN_P8 as PEN
|
||||||
|
|
||||||
URL = 'http://api.thingspeak.com/channels/1417/field/2/last.json'
|
URL = 'http://api.thingspeak.com/channels/1417/field/1/last.txt'
|
||||||
|
|
||||||
UPDATE_INTERVAL = 113 # refresh interval in secs. Be nice to free APIs!
|
UPDATE_INTERVAL = 60 * 60 / 16 # refresh interval in secs. Be nice to free APIs!
|
||||||
# this esoteric number is used so that a column of LEDs equates (approximately) to an hour
|
# Calculated as 60 minutes * 60 seconds divided by number of pixels per row
|
||||||
|
# so that a row of LEDs equates (approximately) to an hour
|
||||||
|
|
||||||
|
CHEERLIGHTS_COLOR_VALUES = [
|
||||||
|
(0x00, 0x00, 0x00), # Black/Unlit
|
||||||
|
(0xFF, 0x00, 0x00),
|
||||||
|
(0x00, 0x80, 0x00),
|
||||||
|
(0x00, 0x00, 0xFF),
|
||||||
|
(0x00, 0xFF, 0xFF),
|
||||||
|
(0xFF, 0xFF, 0xFF),
|
||||||
|
(0xFD, 0xF5, 0xE6),
|
||||||
|
(0x80, 0x00, 0x80),
|
||||||
|
(0xFF, 0x00, 0xFF),
|
||||||
|
(0xFF, 0xFF, 0x00),
|
||||||
|
(0xFF, 0xA5, 0x00),
|
||||||
|
(0xFF, 0xC0, 0xCB),
|
||||||
|
]
|
||||||
|
|
||||||
|
CHEERLIGHTS_COLOR_NAMES = [
|
||||||
|
"black", # Black/Unlit, not part of cheerlights colours
|
||||||
|
"red",
|
||||||
|
"green",
|
||||||
|
"blue",
|
||||||
|
"cyan",
|
||||||
|
"white",
|
||||||
|
"oldlace",
|
||||||
|
"purple",
|
||||||
|
"magenta",
|
||||||
|
"yellow",
|
||||||
|
"orange",
|
||||||
|
"pink"
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
def status_handler(mode, status, ip):
|
def status_handler(mode, status, ip):
|
||||||
|
@ -32,71 +64,62 @@ def status_handler(mode, status, ip):
|
||||||
print('Wifi connection failed!')
|
print('Wifi connection failed!')
|
||||||
|
|
||||||
|
|
||||||
def hex_to_rgb(hex):
|
|
||||||
# converts a hex colour code into RGB
|
|
||||||
h = hex.lstrip('#')
|
|
||||||
r, g, b = (int(h[i:i + 2], 16) for i in (0, 2, 4))
|
|
||||||
return r, g, b
|
|
||||||
|
|
||||||
|
|
||||||
def get_data():
|
def get_data():
|
||||||
|
global index
|
||||||
# open the json file
|
# open the json file
|
||||||
print(f'Requesting URL: {URL}')
|
if UPDATE_INTERVAL >= 60:
|
||||||
r = urequests.get(URL)
|
print(f'Requesting URL: {URL}')
|
||||||
# open the json data
|
r = urequests.get(URL)
|
||||||
j = r.json()
|
name = r.content.decode("utf-8").strip()
|
||||||
print('Data obtained!')
|
r.close()
|
||||||
r.close()
|
print('Data obtained!')
|
||||||
|
|
||||||
|
else:
|
||||||
|
print("Random test colour!")
|
||||||
|
# For sped-up testing we don't want to hit the API at all
|
||||||
|
name = random.choice(CHEERLIGHTS_COLOR_NAMES[1:])
|
||||||
|
|
||||||
# flash the onboard LED after getting data
|
# flash the onboard LED after getting data
|
||||||
pico_led.value(True)
|
pico_led.value(True)
|
||||||
time.sleep(0.2)
|
time.sleep(0.2)
|
||||||
pico_led.value(False)
|
pico_led.value(False)
|
||||||
|
|
||||||
# extract hex colour from the json data
|
|
||||||
hex = j['field2']
|
|
||||||
|
|
||||||
# add the new hex colour to the end of the array
|
# add the new hex colour to the end of the array
|
||||||
colour_array.append(hex)
|
if index == (width * height):
|
||||||
print(f'Colour added to array: {hex}')
|
index = 0
|
||||||
# remove the oldest colour in the array
|
graphics.clear()
|
||||||
colour_array.pop(0)
|
|
||||||
update_leds()
|
|
||||||
|
|
||||||
|
colour_array[index] = CHEERLIGHTS_COLOR_NAMES.index(name)
|
||||||
|
index += 1
|
||||||
|
print(f'Colour added to array: {name}')
|
||||||
|
|
||||||
def update_leds():
|
|
||||||
# light up the LEDs
|
|
||||||
# this step takes a second, it's doing a lot of hex_to_rgb calculations!
|
|
||||||
print("Updating LEDs...")
|
|
||||||
i = 0
|
|
||||||
for x in range(width):
|
|
||||||
for y in range(height):
|
|
||||||
r, g, b = hex_to_rgb(colour_array[i])
|
|
||||||
|
|
||||||
current_colour = graphics.create_pen(r, g, b)
|
|
||||||
graphics.set_pen(current_colour)
|
|
||||||
graphics.pixel(x, y)
|
|
||||||
i = i + 1
|
|
||||||
su.update(graphics)
|
su.update(graphics)
|
||||||
print("LEDs updated!")
|
print("LEDs updated!")
|
||||||
|
|
||||||
|
|
||||||
su = StellarUnicorn()
|
su = StellarUnicorn()
|
||||||
graphics = PicoGraphics(DISPLAY)
|
|
||||||
|
|
||||||
width = StellarUnicorn.WIDTH
|
width = StellarUnicorn.WIDTH
|
||||||
height = StellarUnicorn.HEIGHT
|
height = StellarUnicorn.HEIGHT
|
||||||
|
|
||||||
|
# set up a buffer to store the colours
|
||||||
|
colour_array = bytearray(width * height)
|
||||||
|
|
||||||
|
# We'll use palette mode, so just make the colour list the display buffer
|
||||||
|
graphics = PicoGraphics(DISPLAY, pen_type=PEN, buffer=colour_array)
|
||||||
|
|
||||||
|
# Set up the palette with cheerlights colour values
|
||||||
|
graphics.set_palette(CHEERLIGHTS_COLOR_VALUES)
|
||||||
|
graphics.set_pen(0)
|
||||||
|
graphics.clear()
|
||||||
|
|
||||||
|
# Keep track of the pixel we're lighting
|
||||||
|
index = 0
|
||||||
|
|
||||||
su.set_brightness(0.5)
|
su.set_brightness(0.5)
|
||||||
|
|
||||||
# set up the Pico W's onboard LED
|
# set up the Pico W's onboard LED
|
||||||
pico_led = Pin('LED', Pin.OUT)
|
pico_led = Pin('LED', Pin.OUT)
|
||||||
|
|
||||||
current_colour = graphics.create_pen(0, 0, 0)
|
|
||||||
|
|
||||||
# set up an list to store the colours
|
|
||||||
colour_array = ["#000000"] * 1024
|
|
||||||
|
|
||||||
# set up wifi
|
# set up wifi
|
||||||
try:
|
try:
|
||||||
network_manager = NetworkManager(WIFI_CONFIG.COUNTRY, status_handler=status_handler)
|
network_manager = NetworkManager(WIFI_CONFIG.COUNTRY, status_handler=status_handler)
|
||||||
|
@ -109,19 +132,19 @@ get_data()
|
||||||
|
|
||||||
# start timer (the timer will call the function to update our data every UPDATE_INTERVAL)
|
# start timer (the timer will call the function to update our data every UPDATE_INTERVAL)
|
||||||
timer = Timer(-1)
|
timer = Timer(-1)
|
||||||
timer.init(period=UPDATE_INTERVAL * 1000, mode=Timer.PERIODIC, callback=lambda t: get_data())
|
timer.init(period=int(UPDATE_INTERVAL * 1000), mode=Timer.PERIODIC, callback=lambda t: get_data())
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
# adjust brightness with LUX + and -
|
# adjust brightness with LUX + and -
|
||||||
# LEDs take a couple of secs to update, so adjust in big (10%) steps
|
# LEDs take a couple of secs to update, so adjust in big (10%) steps
|
||||||
if su.is_pressed(StellarUnicorn.SWITCH_BRIGHTNESS_UP):
|
if su.is_pressed(StellarUnicorn.SWITCH_BRIGHTNESS_UP):
|
||||||
su.adjust_brightness(+0.1)
|
su.adjust_brightness(+0.1)
|
||||||
update_leds()
|
su.update(graphics)
|
||||||
print(f"Brightness set to {su.get_brightness()}")
|
print(f"Brightness set to {su.get_brightness()}")
|
||||||
|
|
||||||
if su.is_pressed(StellarUnicorn.SWITCH_BRIGHTNESS_DOWN):
|
if su.is_pressed(StellarUnicorn.SWITCH_BRIGHTNESS_DOWN):
|
||||||
su.adjust_brightness(-0.1)
|
su.adjust_brightness(-0.1)
|
||||||
update_leds()
|
su.update(graphics)
|
||||||
print(f"Brightness set to {su.get_brightness()}")
|
print(f"Brightness set to {su.get_brightness()}")
|
||||||
|
|
||||||
# pause for a moment (important or the USB serial device will fail)
|
# pause for a moment (important or the USB serial device will fail)
|
||||||
|
|
|
@ -4,7 +4,7 @@ from stellar import StellarUnicorn
|
||||||
from picographics import PicoGraphics, DISPLAY_STELLAR_UNICORN as DISPLAY
|
from picographics import PicoGraphics, DISPLAY_STELLAR_UNICORN as DISPLAY
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Random LEDs blink on and off mimicing the look of a movie
|
Random LEDs blink on and off mimicking the look of a movie
|
||||||
super computer doing its work in the eighties.
|
super computer doing its work in the eighties.
|
||||||
|
|
||||||
You can adjust the brightness with LUX + and -.
|
You can adjust the brightness with LUX + and -.
|
||||||
|
|
|
@ -24,7 +24,7 @@ currency_symbol = ""
|
||||||
currency_rate = ""
|
currency_rate = ""
|
||||||
rate_keys = []
|
rate_keys = []
|
||||||
|
|
||||||
# diplay options
|
# display options
|
||||||
line_1_line = -2
|
line_1_line = -2
|
||||||
line_2_line = 9
|
line_2_line = 9
|
||||||
line_3_line = 20
|
line_3_line = 20
|
||||||
|
|
|
@ -13,7 +13,7 @@ damping_factor = 0.97
|
||||||
|
|
||||||
|
|
||||||
def init():
|
def init():
|
||||||
# a palette of five firey colours (white, yellow, orange, red, smoke)
|
# a palette of five fiery colours (white, yellow, orange, red, smoke)
|
||||||
global palette
|
global palette
|
||||||
palette = [
|
palette = [
|
||||||
graphics.create_pen(0, 0, 0),
|
graphics.create_pen(0, 0, 0),
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import time
|
import time
|
||||||
|
import math
|
||||||
import machine
|
import machine
|
||||||
from stellar import StellarUnicorn
|
from stellar import StellarUnicorn
|
||||||
from picographics import PicoGraphics, DISPLAY_STELLAR_UNICORN as DISPLAY
|
from picographics import PicoGraphics, DISPLAY_STELLAR_UNICORN as DISPLAY
|
||||||
|
@ -29,12 +30,21 @@ def pressed():
|
||||||
|
|
||||||
# wait for a button to be pressed and load that effect
|
# wait for a button to be pressed and load that effect
|
||||||
while True:
|
while True:
|
||||||
|
b = int((math.sin(time.ticks_ms() / 200) + 1) / 2.0 * 255)
|
||||||
|
b = max(60, b)
|
||||||
|
|
||||||
graphics.set_font("bitmap6")
|
graphics.set_font("bitmap6")
|
||||||
graphics.set_pen(graphics.create_pen(0, 0, 0))
|
graphics.set_pen(graphics.create_pen(0, 0, 0))
|
||||||
graphics.clear()
|
graphics.clear()
|
||||||
graphics.set_pen(graphics.create_pen(155, 155, 155))
|
|
||||||
graphics.text("PRESS", 3, 6, -1, 1)
|
graphics.set_pen(graphics.create_pen(b, 0, 0))
|
||||||
graphics.text("A B C OR D!", 5, 14, 16, 1, 0)
|
graphics.pixel(0, 3)
|
||||||
|
graphics.set_pen(graphics.create_pen(0, b, 0))
|
||||||
|
graphics.pixel(0, 5)
|
||||||
|
graphics.set_pen(graphics.create_pen(0, 0, b))
|
||||||
|
graphics.pixel(0, 7)
|
||||||
|
graphics.set_pen(graphics.create_pen(b, 0, b))
|
||||||
|
graphics.pixel(0, 9)
|
||||||
|
|
||||||
# brightness up/down
|
# brightness up/down
|
||||||
if stellar.is_pressed(StellarUnicorn.SWITCH_BRIGHTNESS_UP):
|
if stellar.is_pressed(StellarUnicorn.SWITCH_BRIGHTNESS_UP):
|
||||||
|
|
|
@ -6,14 +6,15 @@ import machine
|
||||||
# You will need to create or update the file secrets.py with your network credentials using Thonny
|
# You will need to create or update the file secrets.py with your network credentials using Thonny
|
||||||
# in order for the example to update using the NTP.
|
# in order for the example to update using the NTP.
|
||||||
|
|
||||||
# secrets.py should contain:
|
# WIFI_CONFIG.py should contain:
|
||||||
# WIFI_SSID = ""
|
# SSID = ""
|
||||||
# WIFI_PASSWORD = ""
|
# PSK = ""
|
||||||
|
# COUNTRY = ""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from secrets import WIFI_SSID, WIFI_PASSWORD
|
from WIFI_CONFIG import SSID, PSK
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("Create secrets.py with your WiFi credentials")
|
print("Create WIFI_CONFIG.py with your WiFi credentials")
|
||||||
|
|
||||||
graphics = None
|
graphics = None
|
||||||
|
|
||||||
|
@ -22,14 +23,14 @@ HEIGHT = 16 # StellarUnicorn.HEIGHT
|
||||||
|
|
||||||
rtc = machine.RTC()
|
rtc = machine.RTC()
|
||||||
|
|
||||||
DAYS = ["Mon", "Tue", "Wed", "Thur", "Fri", "Sat", "Sun"]
|
DAYS = ["Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"]
|
||||||
|
|
||||||
# Enable the Wireless
|
# Enable the Wireless
|
||||||
wlan = network.WLAN(network.STA_IF)
|
wlan = network.WLAN(network.STA_IF)
|
||||||
wlan.active(True)
|
wlan.active(True)
|
||||||
|
|
||||||
|
|
||||||
def network_connect(SSID, PSK):
|
def network_connect(ssid, psk):
|
||||||
|
|
||||||
# Number of attempts to make before timeout
|
# Number of attempts to make before timeout
|
||||||
max_wait = 5
|
max_wait = 5
|
||||||
|
@ -37,7 +38,7 @@ def network_connect(SSID, PSK):
|
||||||
# Sets the Wireless LED pulsing and attempts to connect to your local network.
|
# Sets the Wireless LED pulsing and attempts to connect to your local network.
|
||||||
print("connecting...")
|
print("connecting...")
|
||||||
wlan.config(pm=0xa11140) # Turn WiFi power saving off for some slow APs
|
wlan.config(pm=0xa11140) # Turn WiFi power saving off for some slow APs
|
||||||
wlan.connect(SSID, PSK)
|
wlan.connect(ssid, psk)
|
||||||
|
|
||||||
while max_wait > 0:
|
while max_wait > 0:
|
||||||
if wlan.status() < 0 or wlan.status() >= 3:
|
if wlan.status() < 0 or wlan.status() >= 3:
|
||||||
|
@ -55,9 +56,9 @@ def network_connect(SSID, PSK):
|
||||||
def sync_time():
|
def sync_time():
|
||||||
|
|
||||||
try:
|
try:
|
||||||
network_connect(WIFI_SSID, WIFI_PASSWORD)
|
network_connect(SSID, PSK)
|
||||||
except NameError:
|
except NameError:
|
||||||
print("Create secrets.py with your WiFi credentials")
|
print("Create WIFI_CONFIG.py with your WiFi credentials")
|
||||||
|
|
||||||
if wlan.status() < 0 or wlan.status() >= 3:
|
if wlan.status() < 0 or wlan.status() >= 3:
|
||||||
try:
|
try:
|
||||||
|
@ -67,12 +68,10 @@ def sync_time():
|
||||||
|
|
||||||
|
|
||||||
def init():
|
def init():
|
||||||
|
|
||||||
sync_time()
|
sync_time()
|
||||||
|
|
||||||
|
|
||||||
def draw():
|
def draw():
|
||||||
|
|
||||||
# Pens
|
# Pens
|
||||||
RED = graphics.create_pen(120, 0, 0)
|
RED = graphics.create_pen(120, 0, 0)
|
||||||
WHITE = graphics.create_pen(255, 255, 255)
|
WHITE = graphics.create_pen(255, 255, 255)
|
||||||
|
@ -85,16 +84,16 @@ def draw():
|
||||||
|
|
||||||
# Measures the length of the text to help us with centring later.
|
# Measures the length of the text to help us with centring later.
|
||||||
day_length = graphics.measure_text(DAYS[current_t[3]], 1)
|
day_length = graphics.measure_text(DAYS[current_t[3]], 1)
|
||||||
date_length = graphics.measure_text(str(current_t[2]), 3)
|
date_length = graphics.measure_text(str(current_t[2]), 1)
|
||||||
|
|
||||||
graphics.set_font("bitmap6")
|
graphics.set_font("bitmap6")
|
||||||
graphics.set_pen(RED)
|
graphics.set_pen(RED)
|
||||||
graphics.rectangle(0, 0, WIDTH, 7)
|
graphics.rectangle(0, 0, WIDTH, 7)
|
||||||
graphics.set_pen(WHITE)
|
graphics.set_pen(WHITE)
|
||||||
graphics.text(DAYS[current_t[3]], (WIDTH // 2) - (day_length // 2) - 1, 0, 16, 1)
|
graphics.text(DAYS[current_t[3]], (WIDTH // 2) - (day_length // 2), 0, 16, 1)
|
||||||
|
|
||||||
graphics.set_pen(RED)
|
graphics.set_pen(RED)
|
||||||
graphics.set_font("bitmap8")
|
graphics.set_font("bitmap6")
|
||||||
graphics.text(str(current_t[2]), (WIDTH // 2) - (date_length // 2) + 1, 9, 16, 3)
|
graphics.text(str(current_t[2]), (WIDTH // 2) - (date_length // 2) + 1, 8, 16, 1)
|
||||||
|
|
||||||
graphics.set_pen(graphics.create_pen(0, 0, 0))
|
graphics.set_pen(graphics.create_pen(0, 0, 0))
|
||||||
|
|
|
@ -14,7 +14,7 @@ Experiment with the damping, number of spawns and intensity to change the effect
|
||||||
# machine.freq(250_000_000)
|
# machine.freq(250_000_000)
|
||||||
|
|
||||||
DAMPING_FACTOR = 0.95
|
DAMPING_FACTOR = 0.95
|
||||||
NUMBER_OF_LIGHTS = 10
|
NUMBER_OF_LIGHTS = 4
|
||||||
INTENSITY = 20
|
INTENSITY = 20
|
||||||
|
|
||||||
volume = 0.5
|
volume = 0.5
|
||||||
|
|
|
@ -18,7 +18,7 @@ su.set_brightness(0.5)
|
||||||
graphics = PicoGraphics(DISPLAY_STELLAR_UNICORN, pen_type=PEN_P8)
|
graphics = PicoGraphics(DISPLAY_STELLAR_UNICORN, pen_type=PEN_P8)
|
||||||
|
|
||||||
# Number of random fire spawns
|
# Number of random fire spawns
|
||||||
FIRE_SPAWNS = 5
|
FIRE_SPAWNS = 3
|
||||||
|
|
||||||
# Fire damping
|
# Fire damping
|
||||||
DAMPING_FACTOR = 0.98
|
DAMPING_FACTOR = 0.98
|
||||||
|
|
|
@ -13,6 +13,8 @@ A lava lamp effect, created by blurred, moving particles.
|
||||||
# MAXIMUM OVERKILL
|
# MAXIMUM OVERKILL
|
||||||
# machine.freq(250_000_000)
|
# machine.freq(250_000_000)
|
||||||
|
|
||||||
|
NUM_BLOBS = 3
|
||||||
|
|
||||||
su = StellarUnicorn()
|
su = StellarUnicorn()
|
||||||
graphics = PicoGraphics(DISPLAY_STELLAR_UNICORN, pen_type=PEN_P8)
|
graphics = PicoGraphics(DISPLAY_STELLAR_UNICORN, pen_type=PEN_P8)
|
||||||
su.set_brightness(0.5)
|
su.set_brightness(0.5)
|
||||||
|
@ -45,7 +47,7 @@ class Blob():
|
||||||
self.dy = -self.dy
|
self.dy = -self.dy
|
||||||
|
|
||||||
|
|
||||||
blobs = [Blob() for _ in range(10)]
|
blobs = [Blob() for _ in range(NUM_BLOBS)]
|
||||||
|
|
||||||
|
|
||||||
# Fill palette with a steep falloff from bright red to dark blue
|
# Fill palette with a steep falloff from bright red to dark blue
|
||||||
|
@ -60,7 +62,7 @@ def update():
|
||||||
blob.move()
|
blob.move()
|
||||||
lava[int(blob.y)][int(blob.x)] = blob.r
|
lava[int(blob.y)][int(blob.x)] = blob.r
|
||||||
|
|
||||||
# Propogate the blobs outwards
|
# Propagate the blobs outwards
|
||||||
a = numpy.roll(lava, 1, axis=0)
|
a = numpy.roll(lava, 1, axis=0)
|
||||||
b = numpy.roll(lava, -1, axis=0)
|
b = numpy.roll(lava, -1, axis=0)
|
||||||
d = numpy.roll(lava, 1, axis=1)
|
d = numpy.roll(lava, 1, axis=1)
|
||||||
|
|
|
@ -15,9 +15,9 @@ Press "A" to manually re-seed.
|
||||||
# MAXIMUM OVERKILL
|
# MAXIMUM OVERKILL
|
||||||
# machine.freq(250_000_000)
|
# machine.freq(250_000_000)
|
||||||
|
|
||||||
INITIAL_LIFE = 500 # Number of live cells to seed
|
INITIAL_LIFE = 128 # Number of live cells to seed
|
||||||
GENERATION_TIME_MS = 50 # MS between generations
|
GENERATION_TIME_MS = 50 # MS between generations
|
||||||
MINIMUM_LIFE = 10 # Auto reseed when only this many alive cells remain
|
MINIMUM_LIFE = 15 # Auto reseed when only this many alive cells remain
|
||||||
SMOOTHED = True # Enable for a more organic if somewhat unsettling feel
|
SMOOTHED = True # Enable for a more organic if somewhat unsettling feel
|
||||||
|
|
||||||
DECAY = 0.90 # Rate at which smoothing effect decays, higher number = more persistent, 1.0 = no decay
|
DECAY = 0.90 # Rate at which smoothing effect decays, higher number = more persistent, 1.0 = no decay
|
||||||
|
|
|
@ -12,6 +12,8 @@ HELLO NEO.
|
||||||
# MAXIMUM OVERKILL
|
# MAXIMUM OVERKILL
|
||||||
# machine.freq(250_000_000)
|
# machine.freq(250_000_000)
|
||||||
|
|
||||||
|
NUM_SPARKLES = 1
|
||||||
|
|
||||||
su = StellarUnicorn()
|
su = StellarUnicorn()
|
||||||
su.set_brightness(1.0)
|
su.set_brightness(1.0)
|
||||||
graphics = PicoGraphics(DISPLAY_STELLAR_UNICORN, pen_type=PEN_P8)
|
graphics = PicoGraphics(DISPLAY_STELLAR_UNICORN, pen_type=PEN_P8)
|
||||||
|
@ -29,7 +31,7 @@ for g in range(128):
|
||||||
def update():
|
def update():
|
||||||
trippy[:] *= 0.65
|
trippy[:] *= 0.65
|
||||||
|
|
||||||
for _ in range(2):
|
for _ in range(NUM_SPARKLES):
|
||||||
x = random.randint(0, width - 1)
|
x = random.randint(0, width - 1)
|
||||||
y = random.randint(0, height // 2)
|
y = random.randint(0, height // 2)
|
||||||
trippy[y][x] = random.randint(128, 255) / 255.0
|
trippy[y][x] = random.randint(128, 255) / 255.0
|
||||||
|
|
|
@ -6,7 +6,7 @@ from picographics import PicoGraphics, DISPLAY_STELLAR_UNICORN, PEN_P8
|
||||||
from ulab import numpy
|
from ulab import numpy
|
||||||
|
|
||||||
"""
|
"""
|
||||||
THIS IS FINE!
|
THI IS FIN!
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# MAXIMUM OVERKILL
|
# MAXIMUM OVERKILL
|
||||||
|
@ -17,7 +17,7 @@ su.set_brightness(0.5)
|
||||||
graphics = PicoGraphics(DISPLAY_STELLAR_UNICORN, pen_type=PEN_P8)
|
graphics = PicoGraphics(DISPLAY_STELLAR_UNICORN, pen_type=PEN_P8)
|
||||||
|
|
||||||
# Number of random fire spawns
|
# Number of random fire spawns
|
||||||
FIRE_SPAWNS = 5
|
FIRE_SPAWNS = 4
|
||||||
|
|
||||||
# Fire damping
|
# Fire damping
|
||||||
DAMPING_FACTOR = 0.98
|
DAMPING_FACTOR = 0.98
|
||||||
|
@ -81,9 +81,9 @@ def draw():
|
||||||
|
|
||||||
# Draw text over the top
|
# Draw text over the top
|
||||||
graphics.set_pen(0)
|
graphics.set_pen(0)
|
||||||
graphics.text("This", 6, 1, 1, 1)
|
graphics.text("This", 1, 0, 1, 1)
|
||||||
graphics.text("is", 11, 9, 1, 1)
|
graphics.text("is", 1, 3, 1, 1)
|
||||||
graphics.text("fine", 6, 17, 1, 1)
|
graphics.text("fine", 1, 9, 1, 1)
|
||||||
su.update(graphics)
|
su.update(graphics)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ graphics = PicoGraphics(DISPLAY_STELLAR_UNICORN, pen_type=PEN_P8)
|
||||||
|
|
||||||
|
|
||||||
DAMPING_FACTOR = 0.8
|
DAMPING_FACTOR = 0.8
|
||||||
NUMBER_OF_DROPS = 5
|
NUMBER_OF_DROPS = 2
|
||||||
INTENSITY = 10
|
INTENSITY = 10
|
||||||
OFFSET = 0.0 # Try 0.5
|
OFFSET = 0.0 # Try 0.5
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ HEIGHT = StellarUnicorn.HEIGHT
|
||||||
|
|
||||||
rtc = machine.RTC()
|
rtc = machine.RTC()
|
||||||
|
|
||||||
DAYS = ["Mon", "Tue", "Wed", "Thur", "Fri", "Sat", "Sun"]
|
DAYS = ["Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"]
|
||||||
|
|
||||||
# Enable the Wireless
|
# Enable the Wireless
|
||||||
wlan = network.WLAN(network.STA_IF)
|
wlan = network.WLAN(network.STA_IF)
|
||||||
|
@ -99,7 +99,7 @@ def draw():
|
||||||
graphics.set_pen(RED)
|
graphics.set_pen(RED)
|
||||||
graphics.rectangle(0, 0, WIDTH, 7)
|
graphics.rectangle(0, 0, WIDTH, 7)
|
||||||
graphics.set_pen(WHITE)
|
graphics.set_pen(WHITE)
|
||||||
graphics.text(DAYS[current_t[3]], (WIDTH // 2) - (day_length // 2) - 1, 0, 16, 1)
|
graphics.text(DAYS[current_t[3]], (WIDTH // 2) - (day_length // 2), 0, 16, 1)
|
||||||
|
|
||||||
graphics.set_pen(RED)
|
graphics.set_pen(RED)
|
||||||
graphics.set_font("bitmap6")
|
graphics.set_font("bitmap6")
|
||||||
|
|
Ładowanie…
Reference in New Issue