Add mac address display at boot

This commit is contained in:
Neale Pickett 2023-12-06 13:33:33 -07:00
parent fda0ef95e0
commit dc0e6d8bf4
2 changed files with 53 additions and 14 deletions

View File

@ -24,8 +24,14 @@ That's cool.
Setup Setup
----- -----
If the red light on the board is lit, When you first plug it in,
that means it doesn't know how to connect to the WiFi. you will see a yellow pattern with blue or red bars around it.
The pattern is your mac address.
If the bars are red and a pixel is flashing,
that means you need to set up WiFi.
You can also look at the back for a red LED.
If it's lit, you need to set up WiFi.
Get your phone or computer to connect to an access point Get your phone or computer to connect to an access point
called "WallArt". called "WallArt".

View File

@ -31,20 +31,11 @@
#define ART_PATH "/wallart/wallart.bin" #define ART_PATH "/wallart/wallart.bin"
#define HTTPS_TIMEOUT (2 * SECOND) #define HTTPS_TIMEOUT (2 * SECOND)
#define IMAGE_PULL_MIN_INTERVAL (5 * MINUTE)
CRGB grid[GRIDLEN]; CRGB grid[GRIDLEN];
void setup() {
pinMode(RESET_PIN, INPUT_PULLUP);
pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(19200);
FastLED.addLeds<WS2812, NEOPIXEL_PIN, GRB>(grid, GRIDLEN);
// Maybe it's the plexiglass, but for my build, I need to dial back the red
FastLED.setCorrection(0xd0ffff);
network_setup(WFM_PASSWORD);
}
void fade(int cycles = 2) { void fade(int cycles = 2) {
int reps = (cycles*GRIDLEN) + random(GRIDLEN); int reps = (cycles*GRIDLEN) + random(GRIDLEN);
int hue = random(256); int hue = random(256);
@ -173,6 +164,26 @@ void cm5(uint8_t width=0, int cycles=200) {
} }
} }
void displayMacAddress(int cycles=40) {
uint64_t addr = ESP.getEfuseMac();
for (; cycles > 0; cycles -= 1) {
bool conn = connected();
fill_solid(grid, GRIDLEN, CHSV(conn?HUE_AQUA:HUE_RED, 128, 64));
for (int i = 0; i < 48; i++) {
int pos = i + 8;
grid[pos] = CHSV(HUE_YELLOW, 255, ((addr>>(47-i)) & 1)?255:64);
}
grid[0] = CRGB::Black;
if (!conn && (cycles % 2)) {
grid[1] = CRGB::Black;
}
FastLED.show();
pause(250*MILLISECOND);
}
}
// Art from the network // Art from the network
int NetArtFrames = 0; int NetArtFrames = 0;
CRGB NetArt[8][GRIDLEN]; CRGB NetArt[8][GRIDLEN];
@ -203,17 +214,25 @@ uint8_t netgetStatus(uint8_t hue) {
void netget(int count=60) { void netget(int count=60) {
uint8_t hue = netgetStatus(HUE_BLUE); uint8_t hue = netgetStatus(HUE_BLUE);
static unsigned long nextPull = 0; // when to pull next
#if defined(ART_HOSTNAME) && defined(ART_PORT) && defined(ART_PATH) #if defined(ART_HOSTNAME) && defined(ART_PORT) && defined(ART_PATH)
if (connected()) { if (millis() < nextPull) {
// Let's not bombard the server
hue = HUE_ORANGE;
} else if (connected()) {
WiFiClientSecure scli; WiFiClientSecure scli;
nextPull = millis() + IMAGE_PULL_MIN_INTERVAL;
hue = netgetStatus(HUE_AQUA); hue = netgetStatus(HUE_AQUA);
scli.setInsecure(); scli.setInsecure();
HttpClient https(scli, ART_HOSTNAME, ART_PORT); HttpClient https(scli, ART_HOSTNAME, ART_PORT);
do { do {
if (https.get(ART_PATH) != 0) break; String path = String(ART_PATH) + "?mac=" + String(ESP.getEfuseMac(), HEX);
Serial.println(path);
if (https.get(path) != 0) break;
hue = netgetStatus(HUE_GREEN); hue = netgetStatus(HUE_GREEN);
if (https.skipResponseHeaders() != HTTP_SUCCESS) break; if (https.skipResponseHeaders() != HTTP_SUCCESS) break;
@ -301,6 +320,20 @@ void displayTime(unsigned long duration = 20 * SECOND) {
} }
} }
void setup() {
pinMode(RESET_PIN, INPUT_PULLUP);
pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(19200);
FastLED.addLeds<WS2812, NEOPIXEL_PIN, GRB>(grid, GRIDLEN);
// Maybe it's the plexiglass, but for my build, I need to dial back the red
FastLED.setCorrection(0xd0ffff);
network_setup(WFM_PASSWORD);
// Show our mac address, for debugging?
displayMacAddress();
sparkle();
}
void loop() { void loop() {
Picker p; Picker p;
uint8_t getprob = 4; uint8_t getprob = 4;