Reset pin, quicker transitions

This commit is contained in:
Neale Pickett 2023-09-04 16:30:21 -06:00
parent 9ced99c376
commit caeb06eea7
4 changed files with 85 additions and 10 deletions

View File

@ -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
----------

View File

@ -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() {

View File

@ -1,5 +1,6 @@
#pragma once
void network_reset();
void network_setup(char *password);
bool connected();
void pause(uint32_t dwMs);

View File

@ -1,9 +1,9 @@
#include <FastLED.h>
#include <FastLED.h>
#include <ArduinoHttpClient.h>
#include <WiFiClientSecure.h>
#include <WiFiUdp.h>
#include <NTPClient.h>
#include <Time.h>
#include <TimeLib.h>
#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<WS2812, NEOPIXEL_PIN, GRB>(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));
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 = (artlen / 3) / GRIDLEN;
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;
switch (timeStatus()) {
case timeNotSet:
case timeNeedsSync:
updateTime();
break;
}
if (timeStatus() == timeSet) {
int hh = hour();
day = ((hh >= DAY_BEGIN) && (hh < DAY_END));