Address strip WS2812B: различия между версиями

Нет описания правки
Строка 471: Строка 471:


[[Файл:Снимок экрана 2023-12-07 095833.jpg]]
[[Файл:Снимок экрана 2023-12-07 095833.jpg]]
==Загрузка прошивки по WiFi==
С учетом того что esp32 не всегда будет находиться рядом с компом, прошивать эту железка будет неудобно через кабель. Можно прикрутить возможность прошиваться через WiFi.
Установим модули
* AsyncElegantOTA
* ESPAsyncWebServer-esphome
Кодим функционал:
<syntaxhighlight lang="c++">
#include <Arduino.h>
#include <ESPAsyncWebServer.h>
#include <AsyncTCP.h>
#include <ESPAsyncWebServer.h>
#include <AsyncElegantOTA.h>
unsigned long ota_progress_millis = 0;
AsyncWebServer server(80);
void setupOTA(void) {
  server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) {
    request->send(200, "text/plain", "Hi! This is a sample response.");
  });
  AsyncElegantOTA.begin(&server);    // Start AsyncElegantOTA
  server.begin();
  Serial.println("HTTP server started");
}
void setup() {
  setupOTA();
}
</syntaxhighlight>


==Финальный код скетча==
==Финальный код скетча==
Строка 479: Строка 512:
#include <WiFiClient.h>
#include <WiFiClient.h>
#include <WiFi.h>
#include <WiFi.h>
#include <ESPAsyncWebServer.h>
#include <AsyncTCP.h>
#include <ESPAsyncWebServer.h>
#include <AsyncElegantOTA.h>
   
   
#define LED_PIN    27
#define LED_PIN    27
Строка 490: Строка 527:
uint8_t BRIGHTNESS = 50;
uint8_t BRIGHTNESS = 50;
bool hueLoop = true;
bool hueLoop = true;
unsigned long ota_progress_millis = 0;
AsyncWebServer server(80);
void setupOTA(void) {
  server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) {
    request->send(200, "text/plain", "Hi! This is a sample response.");
  });
  AsyncElegantOTA.begin(&server);    // Start AsyncElegantOTA
  server.begin();
  Serial.println("HTTP server started");
}


// This example shows several ways to set up and use 'palettes' of colors
// This example shows several ways to set up and use 'palettes' of colors
Строка 772: Строка 824:
// the first sixteen entries from the virtual palette (of 256), you'd get
// the first sixteen entries from the virtual palette (of 256), you'd get
// Green, followed by a smooth gradient from green-to-blue, and then Blue.
// Green, followed by a smooth gradient from green-to-blue, and then Blue.
</syntaxhighlight>
</syntaxhighlight>
123

правки