Fix URL and a few other display tweaks

This commit is contained in:
Neale Pickett 2023-01-06 12:50:46 -07:00
parent f9b51216ba
commit 9e2d2b39f0
5 changed files with 88 additions and 23 deletions

View File

@ -16,6 +16,34 @@ form different ideas about what it's displaying.
That's cool.
Network Server
--------------
If you provide a wallart server in
`network-server.h`,
the program will periodically fetch an image/animation from it,
and display that image/animation.
Because the fetch takes some time,
one of the animation patterns actually shows progress of the fetch.
It's the one with the four lights of the same color.
After it's either succeeded or failed,
it stays on that color for a while,
so you can tell how everything is going.
Here's what the colors indicate:
Color it stays on | Status
--- | ---
Blue | Unable to connect to access point
Aqua | Some sort of problem initiating the HTTPS request (DNS?)
Green | HTTPS server request failed (404 or similar)
Yellow | Image download failed
Orange | Everything worked!
A happy setup will cycle through each color once,
and then display orange for a while.
Philosophy
----------

View File

@ -5,6 +5,6 @@
*
* https://git.woozle.org/neale/wallart-server
*/
//#define ART_HOSTNAME "wallart.your.site"
#define ART_HOSTNAME "www.woozle.org"
#define ART_PORT 443
#define ART_PATH "/wallart/wallart.bin"

View File

@ -3,15 +3,12 @@
#include <WiFiClientSecure.h>
#include "picker.h"
#include "network.h"
#include "network-server.h"
#define NEOPIXEL_PIN 32
#define GRIDLEN 64
#define WFM_PASSWORD "artsy fartsy"
#define ART_HOSTNAME "sweetums.woozle.org"
#define ART_PORT 443
#define ART_PATH "/public/wallart.bin"
#define MILLISECOND 1
#define SECOND (1000 * MILLISECOND)
@ -21,7 +18,9 @@ CRGB grid[GRIDLEN];
void setup() {
FastLED.addLeds<WS2812, NEOPIXEL_PIN, GRB>(grid, GRIDLEN);
FastLED.setBrightness(32);
FastLED.setBrightness(64);
// Maybe it's the plexiglass but for my build I really need to dial back the red
FastLED.setCorrection(0xc0ffff);
network_setup(WFM_PASSWORD);
}
@ -30,7 +29,8 @@ void fade(int cycles = 2) {
int hue = random(256);
for (int i = 0; i < reps; i++) {
for (int pos = 0; pos < 8; pos++) {
grid[(i+pos) % GRIDLEN] = CHSV(hue, 255, pos * 32);
uint8_t p = cm5xlat(8, (i+pos) % GRIDLEN);
grid[p] = CHSV(hue, 255, pos * 32);
}
FastLED.show();
pause(80);
@ -123,14 +123,28 @@ void conwayish(int cycles=5000) {
}
}
void cm5(int cycles=200) {
uint8_t cm5xlat(uint8_t width, uint8_t pos) {
if (width == 0) {
return pos;
}
uint8_t x = pos % width;
uint8_t y = pos / width;
uint8_t odd = y % 2;
return (y*width) + ((width-x-1)*odd) + (x*(1-odd));
}
void cm5(uint8_t width=0, int cycles=200) {
for (int frame = 0; frame < cycles; frame++) {
int val = 127 * random(2);
for (int pos = 0; pos < GRIDLEN; pos++) {
for (uint8_t pos = 0; pos < GRIDLEN; pos++) {
uint8_t xpos = cm5xlat(width, pos);
if (pos < GRIDLEN-1) {
grid[pos] = grid[pos + 1];
uint8_t x2pos = cm5xlat(width, pos+1);
grid[xpos] = grid[x2pos];
} else {
grid[pos] = CHSV(0, 255, val);
grid[xpos] = CHSV(0, 255, val);
}
}
FastLED.show();
@ -169,26 +183,28 @@ uint8_t netgetStatus(uint8_t hue) {
void netget(int count=60) {
uint8_t hue = netgetStatus(HUE_BLUE);
#if defined(ART_HOSTNAME) && defined(ART_PORT) && defined(ART_PATH)
if (connected()) {
WiFiClientSecure scli;
hue = netgetStatus(hue - 32);
hue = netgetStatus(HUE_AQUA);
scli.setInsecure();
HttpClient https(scli, ART_HOSTNAME, ART_PORT);
do {
if (https.get(ART_PATH) != 0) break;
hue = netgetStatus(hue - 32);
hue = netgetStatus(HUE_GREEN);
if (https.skipResponseHeaders() != HTTP_SUCCESS) break;
hue = netgetStatus(hue - 32);
hue = netgetStatus(HUE_YELLOW);
int artlen = https.read((uint8_t *)NetArt, sizeof(NetArt));
hue = netgetStatus(hue - 32);
hue = netgetStatus(HUE_ORANGE);
NetArtFrames = (artlen / 3) / GRIDLEN;
} while(false);
https.stop();
}
#endif
for (int i = 0; i < count; i++) {
netgetStatus(hue);
@ -208,8 +224,17 @@ void spinner(int count=32) {
void loop() {
Picker p;
uint8_t getprob = 4;
if (p.Pick(1)) {
if ((NetArtFrames == 0) || !connected()) {
getprob = 16;
}
if (p.Pick(getprob)) {
netget();
} else if (p.Pick(4)) {
netart();
} else if (p.Pick(1)) {
fade();
singleCursor(20);
} else if (p.Pick(1)) {
@ -220,11 +245,11 @@ void loop() {
conwayish();
} else if (p.Pick(8)) {
glitchPulse();
} else if (p.Pick(8)) {
cm5();
} else if (p.Pick(8)) {
netart();
} else if (p.Pick(4) || !connected()) {
netget();
} else if (p.Pick(2)) {
cm5(0);
} else if (p.Pick(2)) {
cm5(8);
} else if (p.Pick(2)) {
cm5(16);
}
}

12
xlat.py Normal file
View File

@ -0,0 +1,12 @@
def xlat(width, pos):
if width == 0:
return pos
x = pos % width
y = pos // width
odd = y % 2
return (y*width) + ((width-x-1)*odd) + (x*(1-odd))
for i in range(32):
print(i, xlat(8, i))