-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy path_ota.h
42 lines (37 loc) · 1.06 KB
/
_ota.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#ifndef _OTA_H
#define _OTA_H
//This is the OTA SubSystem..
#include <ESP8266mDNS.h>
#ifndef _WIFIUDP_H
#include <WiFiUdp.h>
#endif
#include <ArduinoOTA.h>
void otaInit()
{
ArduinoOTA.onStart([]() {
matrix->fillScreen(0);
Serial.println("Start");
});
ArduinoOTA.onEnd([]() {
Serial.println("\nEnd");
ESP.reset();
});
ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
matrix->setNPixelColor((progress / (total / 64)), matrix->Color(255, 0, 0));
matrix->show();
Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
});
ArduinoOTA.onError([](ota_error_t error) {
Serial.printf("Error[%u]: ", error);
if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed");
else if (error == OTA_BEGIN_ERROR) Serial.println("Begin Failed");
else if (error == OTA_CONNECT_ERROR) Serial.println("Connect Failed");
else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed");
else if (error == OTA_END_ERROR) Serial.println("End Failed");
});
}
void OTAEvent()
{
ArduinoOTA.handle();
}
#endif