Skip to content

Instantly share code, notes, and snippets.

EVERY_N_MILLISECONDS(PAUSE) {
uint8_t color;
if((pos % 2) && (pos <= (msglen * 2))) {
char letter = msg[pos/2];
char mapped = mapChar(letter);
// Serial.printf("pos: %d, char: %c, num: %d\n", pos, letter, mapped);
if(mapped > 0) {
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
#include <DNSServer.h>
#include <FS.h>
#include <FastLED.h>
#include <PGMWrap.h>
#include <EEPROM.h>
#define FLAGSET 0x55
#define FLAGCLEAR 0xAA
#define FLAGADDRESS 00
#define FLAGTIMEOUT 3000
uint32_t flag = FLAGCLEAR;
void setup() {
void setup() {
// put your setup code here, to run once:
Serial.begin(115200); Serial.println();
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, HIGH);
//Activate the EEPROM before attempting to use it
EEPROM.begin(sizeof(flag));
//Check to see if the flag is still set from the previous boot
bool checkFlag() {
flag = EEPROM.read(FLAGADDRESS);
return flag == FLAGSET;
}
void writeFlag(uint32_t value) {
flag = value;
EEPROM.write(FLAGADDRESS, flag);
EEPROM.commit();
}
#include <EEPROM.h>
#define FLAGSET 0x55
#define FLAGCLEAR 0xAA
#define FLAGADDRESS 00
#define FLAGTIMEOUT 3000
uint32_t flag = FLAGCLEAR;
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <FS.h>
#include "EEPROMAnything.h"
#define RESETPIN D1
ESP8266WebServer webServer(80);
struct config_t{
// If the passwords match we can update the config with the new settings
// Check to see if there is a new value (also doubles to check the length of the new value is long enough)
if(webServer.arg("newpassword").length() > 7)
webServer.arg("newpassword").toCharArray(config.password, sizeof(config.password));
if(webServer.arg("newssid").length() > 7)
webServer.arg("newssid").toCharArray(config.ssid, sizeof(config.ssid));
// Store the new settings to EEPROM
EEPROM_writeAnything(0, config);
void handleAdmin() {
// Create a string containing all the arguments, send them out to the serial port
Serial.printf("handleAdmin\n");
// Construct a list of all the arguments for debug
String message = "#Args:" + String(webServer.args()) + "\n";
for (int i = 0; i < webServer.args(); i++)
message.concat(webServer.argName(i) + ": "+ webServer.arg(i) + "\n");
webServer.on("/", [](){
webServer.send(200, "text/plain", "visit /admin for wifi configuration");
});
webServer.serveStatic("/admin", SPIFFS, "/admin.html");
webServer.on("/admin", handleAdmin);
webServer.begin();