updated screen + added OTA

This commit is contained in:
2021-07-27 08:26:12 +02:00
parent 11b146c2d1
commit dd511c8e18
14 changed files with 261 additions and 57 deletions

46
esp_ota.cpp Normal file
View File

@@ -0,0 +1,46 @@
#include "esp_ota.h"
void initEspOta(void)
{
Serial.println("ESPOTA: init");
ArduinoOTA
.onStart([]() {
String type;
if (ArduinoOTA.getCommand() == U_FLASH)
type = "sketch";
else // U_SPIFFS
type = "filesystem";
// NOTE: if updating SPIFFS this would be the place to unmount SPIFFS using SPIFFS.end()
Serial.println("ESPOTA: Start updating " + type);
ProgressbarVisible(true);
ledcWrite(TFT_BL_PWMCHANNEL, 64);
})
.onEnd([]() {
Serial.println("\nESPOTA: End");
})
.onProgress([](unsigned int progress, unsigned int total) {
Serial.printf("ESPOTA: Progress: %u%%\r", (progress / (total / 100)));
setOTAProgress((progress / (total / 100)));
})
.onError([](ota_error_t error) {
Serial.printf("ESPOTA: Error[%u]: ", error);
if (error == OTA_AUTH_ERROR) Serial.println("ESPOTA: Auth Failed");
else if (error == OTA_BEGIN_ERROR) Serial.println("ESPOTA: Begin Failed");
else if (error == OTA_CONNECT_ERROR) Serial.println("ESPOTA: Connect Failed");
else if (error == OTA_RECEIVE_ERROR) Serial.println("ESPOTA: Receive Failed");
else if (error == OTA_END_ERROR) Serial.println("ESPOTA: End Failed");
});
ArduinoOTA.begin();
Serial.print("ESPOTA: IP address: ");
Serial.println(WiFi.localIP());
Serial.println("ESPOTA: init OK");
}
void handleEspOta(void)
{
ArduinoOTA.handle();
}