implement OTA via Web Server
This commit is contained in:
parent
594c665350
commit
aa4a07f4b9
3 changed files with 26 additions and 2 deletions
|
|
@ -12,5 +12,7 @@
|
|||
platform = espressif8266
|
||||
board = d1_mini_lite
|
||||
framework = arduino
|
||||
lib_deps =
|
||||
fastled/FastLED
|
||||
lib_deps =
|
||||
fastled/FastLED
|
||||
ayushsharma82/AsyncElegantOTA@^2.2.7
|
||||
ottowinter/ESPAsyncWebServer-esphome@^3.0.0
|
||||
|
|
|
|||
|
|
@ -16,6 +16,10 @@
|
|||
#define ANIMATION_DURATION 120 //seconds
|
||||
#define BRIGHTNESS 255
|
||||
|
||||
#define MESH_AP_NAME "LED_TREE"
|
||||
#define MESH_AP_PASSWORD "7uaG2CFmPj"
|
||||
#define MESH_AP_TIMEOUT 30
|
||||
|
||||
/*
|
||||
* █████ ███ ██ ██ ███ ███ █████ ████████ ██ ██████ ███ ██ ███████
|
||||
* ██ ██ ████ ██ ██ ████ ████ ██ ██ ██ ██ ██ ██ ████ ██ ██
|
||||
|
|
|
|||
18
src/main.cpp
18
src/main.cpp
|
|
@ -1,16 +1,24 @@
|
|||
#include <Arduino.h>
|
||||
#include <config.h>
|
||||
#include <FastLED.h>
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <ESPAsyncTCP.h>
|
||||
#include <ESPAsyncWebServer.h>
|
||||
#include <AsyncElegantOTA.h>
|
||||
|
||||
#define ANIMATION_DURATION_MS (ANIMATION_DURATION * 1000)
|
||||
#define MESH_AP_TIMEOUT_MS (MESH_AP_TIMEOUT * 1000)
|
||||
#define NUMLEDS (LEDS_STAGE_1 + LEDS_STAGE_2 + LEDS_STAGE_3 + LEDS_STAGE_4 + LEDS_TOP)
|
||||
|
||||
CRGB leds[NUMLEDS];
|
||||
AsyncWebServer server(80);
|
||||
|
||||
unsigned long colorScrollTemperature = 0;
|
||||
unsigned long lastChange = 0;
|
||||
unsigned long snakeColor = 0;
|
||||
byte animation = 0;
|
||||
bool meshApActive = true;
|
||||
bool meshClientConnected = false;
|
||||
|
||||
void colorScroll();
|
||||
void stars();
|
||||
|
|
@ -20,6 +28,10 @@ void snow();
|
|||
|
||||
void setup()
|
||||
{
|
||||
WiFi.softAP(MESH_AP_NAME, MESH_AP_PASSWORD);
|
||||
AsyncElegantOTA.begin(&server);
|
||||
server.begin();
|
||||
|
||||
FastLED.addLeds<WS2812B, LEDPIN_STAGE_1, BRG>(leds, LEDS_STAGE_1);
|
||||
FastLED.addLeds<WS2812B, LEDPIN_STAGE_2, BRG>(leds, LEDS_STAGE_1, LEDS_STAGE_2);
|
||||
FastLED.addLeds<WS2812B, LEDPIN_STAGE_3, BRG>(leds, LEDS_STAGE_1 + LEDS_STAGE_2, LEDS_STAGE_3);
|
||||
|
|
@ -53,6 +65,12 @@ void loop()
|
|||
animation++;
|
||||
lastChange = millis();
|
||||
}
|
||||
|
||||
if(meshApActive && (millis() > MESH_AP_TIMEOUT_MS ) && (millis() < MESH_AP_TIMEOUT_MS + 60000 ) && (wifi_softap_get_station_num() == 0))
|
||||
{
|
||||
meshApActive = false;
|
||||
WiFi.softAPdisconnect (true);
|
||||
}
|
||||
}
|
||||
|
||||
void colorScroll()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue