From caeb06eea745abf1db9afe72bab1887b495df893 Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Mon, 4 Sep 2023 16:30:21 -0600 Subject: [PATCH] Reset pin, quicker transitions --- README.md | 36 ++++++++++++++++++++++++++++++++++++ network.cpp | 6 ++++-- network.h | 1 + wallart.ino | 52 ++++++++++++++++++++++++++++++++++++++++++++-------- 4 files changed, 85 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 9d67e20..44c7781 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,31 @@ Most people, after watching it for a bit, form different ideas about what it's displaying. That's cool. +Reset +------ + +Plug the device in, +connect GND to pin A0, +and briefly press the reboot button. +It will flash orange and blue a few times +to let you know it has reset. + + +WiFi +----- + +If the red light on the board is lit, +that means it doesn't know how to connect to the WiFi. + +Get your phone or computer to connect to an access point +called "Wall Art xxxxxxxxx". +The password is "artsy fartsy", unless you changed it in the source code. +Once connected, +you should get a browser window that lets you connect. +If not, try going to http://neverssl.com/. + +You can clear the wifi information with a reset. + Network Server -------------- @@ -65,6 +90,17 @@ I suggest you set it to standard time and pretend it's in sync with the sun. * There are four pixels around the bottom that move every 5 seconds +Update +------ + +You can upload a new version of the firmware. +Reset the device, +and select the "Update" button instead of configuring WiFi. +Then you can upload the new .bin firmware file. + +You will have to reconfigure networking after this. + + Philosophy ---------- diff --git a/network.cpp b/network.cpp index e53a270..d738aff 100644 --- a/network.cpp +++ b/network.cpp @@ -7,6 +7,10 @@ WiFiManager wfm; +void network_reset() { + wfm.resetSettings(); +} + void network_setup(char *password) { String hostid = String(ESP.getEfuseMac(), HEX); String hostname = "Wall Art " + hostid; @@ -14,8 +18,6 @@ void network_setup(char *password) { wfm.setConfigPortalBlocking(false); wfm.setHostname(hostname); wfm.autoConnect(hostname.c_str(), password); - - pinMode(LED_BUILTIN, OUTPUT); } bool connected() { diff --git a/network.h b/network.h index db935c7..cb378fc 100644 --- a/network.h +++ b/network.h @@ -1,5 +1,6 @@ #pragma once +void network_reset(); void network_setup(char *password); bool connected(); void pause(uint32_t dwMs); diff --git a/wallart.ino b/wallart.ino index ae5e658..80ec608 100644 --- a/wallart.ino +++ b/wallart.ino @@ -1,9 +1,9 @@ -#include + #include #include #include #include #include -#include +#include #include "durations.h" #include "timezones.h" #include "picker.h" @@ -34,15 +34,34 @@ #define HTTPS_TIMEOUT (2 * SECOND) +#define RESET_PIN 26 + CRGB grid[GRIDLEN]; WiFiUDP ntpUDP; NTPClient timeClient(ntpUDP); +void do_reset() { + for (int i = 0; i < 8; i++) { + for (int j = 0; j < 8; j += 1) { + grid[j] = ((i+j)%2) ? (CRGB::Orange) : (CRGB::Blue); + } + FastLED.show(); + digitalWrite(LED_BUILTIN, i%2); + delay(300 * MILLISECOND); + } + network_reset(); +} + void setup() { + pinMode(RESET_PIN, INPUT_PULLUP); + pinMode(LED_BUILTIN, OUTPUT); FastLED.addLeds(grid, GRIDLEN); - // Maybe it's the plexiglass but for my build I really need to dial back the red - FastLED.setCorrection(0xc0ffff); + // Maybe it's the plexiglass, but for my build, I need to dial back the red + FastLED.setCorrection(0xd0ffff); + if (!digitalRead(RESET_PIN)) { + do_reset(); + } network_setup(WFM_PASSWORD); } @@ -230,9 +249,21 @@ void netget(int count=60) { if (https.skipResponseHeaders() != HTTP_SUCCESS) break; hue = netgetStatus(HUE_YELLOW); - int artlen = https.read((uint8_t *)NetArt, sizeof(NetArt)); - hue = netgetStatus(HUE_ORANGE); - NetArtFrames = (artlen / 3) / GRIDLEN; + size_t readBytes = 0; + for (int i = 0; i < 12; i++) { + size_t artBytesLeft = sizeof(NetArt) - readBytes; + + if (https.endOfBodyReached() || (artBytesLeft == 0)) { + hue = netgetStatus(HUE_ORANGE); + NetArtFrames = (readBytes / 3) / GRIDLEN; + break; + } + int l = https.read((uint8_t *)NetArt + readBytes, artBytesLeft); + if (-1 == l) { + break; + } + readBytes += l; + } } while(false); https.stop(); } @@ -307,7 +338,12 @@ void loop() { bool conn = connected(); bool day = true; - updateTime(); + switch (timeStatus()) { + case timeNotSet: + case timeNeedsSync: + updateTime(); + break; + } if (timeStatus() == timeSet) { int hh = hour(); day = ((hh >= DAY_BEGIN) && (hh < DAY_END));