parent
0f65cd1f92
commit
de0505cf79
@ -0,0 +1,31 @@
|
||||
#include <FastLED.h>
|
||||
#include <WiFiManager.h>
|
||||
#include <esp_wifi.h>
|
||||
#include <HTTPClient.h>
|
||||
#include <WiFiClientSecure.h>
|
||||
#include "network.h"
|
||||
|
||||
WiFiManager wfm;
|
||||
|
||||
void network_setup(char *password) {
|
||||
String hostid = String(ESP.getEfuseMac(), HEX);
|
||||
String hostname = "Wall Art " + hostid;
|
||||
|
||||
wfm.setConfigPortalBlocking(false);
|
||||
wfm.setHostname(hostname);
|
||||
wfm.autoConnect(hostname.c_str(), password);
|
||||
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
}
|
||||
|
||||
bool connected() {
|
||||
return WiFi.status() == WL_CONNECTED;
|
||||
}
|
||||
|
||||
void pause(uint32_t dwMs) {
|
||||
for (uint32_t t = 0; t < dwMs; t += 10) {
|
||||
wfm.process();
|
||||
digitalWrite(LED_BUILTIN, connected());
|
||||
delay(10);
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <HTTPClient.h>
|
||||
#include <WiFiClientSecure.h>
|
||||
|
||||
|
||||
void network_setup(char *password);
|
||||
bool connected();
|
||||
void pause(uint32_t dwMs);
|
||||
void netget(int count);
|
@ -1,104 +0,0 @@
|
||||
import board
|
||||
from digitalio import DigitalInOut, Direction, Pull
|
||||
import adafruit_dotstar as dotstar
|
||||
import adafruit_fancyled.adafruit_fancyled as fancy
|
||||
import time
|
||||
import neopixel
|
||||
import random
|
||||
import microcontroller
|
||||
|
||||
# One pixel connected internally!
|
||||
dot = dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1, brightness=0.2)
|
||||
dot[0] = 0
|
||||
|
||||
# Built in red LED
|
||||
led = DigitalInOut(board.D13)
|
||||
led.direction = Direction.OUTPUT
|
||||
|
||||
# NeoPixel strip (of 16 LEDs) connected on D4
|
||||
GRIDLEN = 64
|
||||
grid = neopixel.NeoPixel(board.D4, GRIDLEN, brightness=0.2, auto_write=False, pixel_order=neopixel.GRB)
|
||||
|
||||
|
||||
class GlitchPixel:
|
||||
def __init__(self):
|
||||
self.init()
|
||||
self.nsteps = 64
|
||||
self.step = random.randrange(self.nsteps)
|
||||
|
||||
def init(self):
|
||||
self.step = 0
|
||||
self.pos = random.randrange(GRIDLEN)
|
||||
self.color = fancy.CHSV(random.random()).pack()
|
||||
|
||||
def frame(self):
|
||||
bmask = (0xff * self.step // 32) & 0xff
|
||||
if self.step > self.nsteps/2:
|
||||
bmask = 0xff - bmask
|
||||
mask = (bmask << 16) | (bmask << 8) | (bmask << 0)
|
||||
color = self.color & mask
|
||||
grid[self.pos] = color
|
||||
|
||||
self.step += 1
|
||||
if self.step > self.nsteps:
|
||||
self.init()
|
||||
|
||||
def fade():
|
||||
reps = 300 + random.randrange(GRIDLEN)
|
||||
hue = random.randrange(256)
|
||||
colors = [fancy.CHSV(hue, 255, v).pack() for v in range(0, 256, 32)]
|
||||
rcolors = colors[:]
|
||||
rcolors.reverse()
|
||||
colors = colors + rcolors
|
||||
for count in range(reps):
|
||||
pos = count % GRIDLEN
|
||||
for color in colors:
|
||||
grid[pos] = color
|
||||
pos -= 1
|
||||
grid.show()
|
||||
|
||||
def singleCursor():
|
||||
red = fancy.CHSV(0, 210, 127).pack()
|
||||
pos = 20
|
||||
for i in range(80):
|
||||
grid[pos] = red * (i % 2)
|
||||
led.value = not (i % 2)
|
||||
grid.show()
|
||||
time.sleep(0.08)
|
||||
|
||||
def sparkle():
|
||||
white = fancy.CHSV(0, 0, 127).pack()
|
||||
pos = [0,0,0]
|
||||
for i in range(50):
|
||||
for j in range(len(pos)):
|
||||
pos[j] = random.randrange(GRIDLEN)
|
||||
grid[pos[j]] = white
|
||||
grid.show()
|
||||
for p in pos:
|
||||
grid[p] = 0
|
||||
grid.show()
|
||||
|
||||
def glitchPulse():
|
||||
grid.fill(0)
|
||||
pixels = []
|
||||
for i in range(4):
|
||||
p = GlitchPixel()
|
||||
pixels.append(p)
|
||||
|
||||
for f in range(1000):
|
||||
for p in pixels:
|
||||
p.frame()
|
||||
grid.show()
|
||||
time.sleep(0.1)
|
||||
|
||||
def loop():
|
||||
fade()
|
||||
singleCursor()
|
||||
sparkle()
|
||||
glitchPulse()
|
||||
# For some reason, this program freezes occasionally.
|
||||
# I don't want to debug CircuitPython.
|
||||
microcontroller.reset()
|
||||
|
||||
while True:
|
||||
loop()
|
Loading…
Reference in new issue