kopia lustrzana https://github.com/dl9rdz/rdz_ttgo_sonde
OTA display output fix for TFT
rodzic
33c5ccc905
commit
c01a72cf91
|
@ -1029,6 +1029,7 @@ const char *handleEditPost(AsyncWebServerRequest *request) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// will be removed. its now in data/upd.html (for GET; POST to update.html still handled here)
|
||||||
const char *createUpdateForm(boolean run) {
|
const char *createUpdateForm(boolean run) {
|
||||||
char *ptr = message;
|
char *ptr = message;
|
||||||
strcpy(ptr, "<html><head><link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\"></head><body><form action=\"update.html\" method=\"post\">");
|
strcpy(ptr, "<html><head><link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\"></head><body><form action=\"update.html\" method=\"post\">");
|
||||||
|
@ -2865,17 +2866,25 @@ void execOTA() {
|
||||||
int contentLength = 0;
|
int contentLength = 0;
|
||||||
bool isValidContentType = false;
|
bool isValidContentType = false;
|
||||||
sonde.clearDisplay();
|
sonde.clearDisplay();
|
||||||
|
uint8_t dispxs, dispys;
|
||||||
|
if( ISOLED(sonde.config) ) {
|
||||||
disp.rdis->setFont(FONT_SMALL);
|
disp.rdis->setFont(FONT_SMALL);
|
||||||
disp.rdis->drawString(0, 0, "C:");
|
dispxs = dispys = 1;
|
||||||
String dispHost = updateHost.substring(0, 14);
|
} else {
|
||||||
disp.rdis->drawString(2, 0, dispHost.c_str());
|
disp.rdis->setFont(5);
|
||||||
|
dispxs = 18;
|
||||||
|
dispys = 20;
|
||||||
|
}
|
||||||
|
|
||||||
|
String dispHost = updateHost.substring(0, 16);
|
||||||
|
disp.rdis->drawString(0, 0, dispHost.c_str());
|
||||||
|
|
||||||
Serial.println("Connecting to: " + updateHost);
|
Serial.println("Connecting to: " + updateHost);
|
||||||
// Connect to Update host
|
// Connect to Update host
|
||||||
if (client.connect(updateHost.c_str(), updatePort)) {
|
if (client.connect(updateHost.c_str(), updatePort)) {
|
||||||
// Connection succeeded, fecthing the bin
|
// Connection succeeded, fecthing the bin
|
||||||
Serial.println("Fetching bin: " + String(*updateBin));
|
Serial.println("Fetching bin: " + String(*updateBin));
|
||||||
disp.rdis->drawString(0, 1, "Fetching update");
|
disp.rdis->drawString(0, 1 * dispys, "Fetching update");
|
||||||
|
|
||||||
// Get the contents of the bin file
|
// Get the contents of the bin file
|
||||||
client.print(String("GET ") + *updateBin + " HTTP/1.1\r\n" +
|
client.print(String("GET ") + *updateBin + " HTTP/1.1\r\n" +
|
||||||
|
@ -2968,22 +2977,22 @@ void execOTA() {
|
||||||
|
|
||||||
// Check what is the contentLength and if content type is `application/octet-stream`
|
// Check what is the contentLength and if content type is `application/octet-stream`
|
||||||
Serial.println("contentLength : " + String(contentLength) + ", isValidContentType : " + String(isValidContentType));
|
Serial.println("contentLength : " + String(contentLength) + ", isValidContentType : " + String(isValidContentType));
|
||||||
disp.rdis->drawString(0, 2, "Len: ");
|
disp.rdis->drawString(0, 2 * dispys, "Len: ");
|
||||||
String cls = String(contentLength);
|
String cls = String(contentLength);
|
||||||
disp.rdis->drawString(5, 2, cls.c_str());
|
disp.rdis->drawString(5 * dispxs, 2 * dispys, cls.c_str());
|
||||||
|
|
||||||
// check contentLength and content type
|
// check contentLength and content type
|
||||||
if (contentLength && isValidContentType) {
|
if (contentLength && isValidContentType) {
|
||||||
// Check if there is enough to OTA Update
|
// Check if there is enough to OTA Update
|
||||||
bool canBegin = Update.begin(contentLength);
|
bool canBegin = Update.begin(contentLength);
|
||||||
disp.rdis->drawString(0, 4, "Starting update");
|
disp.rdis->drawString(0, 4 * dispys, "Starting update");
|
||||||
|
|
||||||
// If yes, begin
|
// If yes, begin
|
||||||
if (canBegin) {
|
if (canBegin) {
|
||||||
Serial.println("Begin OTA. This may take 2 - 5 mins to complete. Things might be quite for a while.. Patience!");
|
Serial.println("Begin OTA. This may take 2 - 5 mins to complete. Things might be quite for a while.. Patience!");
|
||||||
// No activity would appear on the Serial monitor
|
// No activity would appear on the Serial monitor
|
||||||
// So be patient. This may take 2 - 5mins to complete
|
// So be patient. This may take 2 - 5mins to complete
|
||||||
disp.rdis->drawString(0, 5, "Please wait!");
|
disp.rdis->drawString(0, 5 * dispys, "Please wait!");
|
||||||
size_t written = Update.writeStream(client);
|
size_t written = Update.writeStream(client);
|
||||||
|
|
||||||
if (written == contentLength) {
|
if (written == contentLength) {
|
||||||
|
@ -2998,7 +3007,7 @@ void execOTA() {
|
||||||
Serial.println("OTA done!");
|
Serial.println("OTA done!");
|
||||||
if (Update.isFinished()) {
|
if (Update.isFinished()) {
|
||||||
Serial.println("Update successfully completed. Rebooting.");
|
Serial.println("Update successfully completed. Rebooting.");
|
||||||
disp.rdis->drawString(0, 7, "Rebooting....");
|
disp.rdis->drawString(0, 7 * dispys, "Rebooting....");
|
||||||
delay(1000);
|
delay(1000);
|
||||||
ESP.restart();
|
ESP.restart();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -336,6 +336,7 @@ const struct gfxoffset_t gfxoffsets[]={
|
||||||
{ 13, 18 }, // 17+13-12 "j"
|
{ 13, 18 }, // 17+13-12 "j"
|
||||||
{ 17, 23 }, // 23+17-17
|
{ 17, 23 }, // 23+17-17
|
||||||
{ 4, 6}, // 6+4-4
|
{ 4, 6}, // 6+4-4
|
||||||
|
{ 25, 34 }, // 34 25 -25
|
||||||
};
|
};
|
||||||
static int ngfx = sizeof(gfl)/sizeof(GFXfont *);
|
static int ngfx = sizeof(gfl)/sizeof(GFXfont *);
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,8 @@ extern const char *sondeTypeLongStr[NSondeTypes];
|
||||||
extern const char sondeTypeChar[NSondeTypes];
|
extern const char sondeTypeChar[NSondeTypes];
|
||||||
extern const char *manufacturer_string[NSondeTypes];
|
extern const char *manufacturer_string[NSondeTypes];
|
||||||
|
|
||||||
|
#define ISOLED(cfg) ((cfg).disptype==0 || (cfg).disptype==2)
|
||||||
|
|
||||||
#define TYPE_IS_DFM(t) ( (t)==STYPE_DFM )
|
#define TYPE_IS_DFM(t) ( (t)==STYPE_DFM )
|
||||||
#define TYPE_IS_METEO(t) ( (t)==STYPE_M10 || (t)==STYPE_M20 )
|
#define TYPE_IS_METEO(t) ( (t)==STYPE_M10 || (t)==STYPE_M20 )
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ extern WiFiClient client;
|
||||||
char outbuf[128];
|
char outbuf[128];
|
||||||
uint8_t ephstate = EPH_NOTUSED;
|
uint8_t ephstate = EPH_NOTUSED;
|
||||||
//enum EPHSTATE { EPH_NOTUSED, EPH_PENDING, EPH_TIMEERR, EPH_ERROR, EPH_EPHERROR, EPH_GOOD };
|
//enum EPHSTATE { EPH_NOTUSED, EPH_PENDING, EPH_TIMEERR, EPH_ERROR, EPH_EPHERROR, EPH_GOOD };
|
||||||
char *ephtxt[] = { "Disabled", "Pending", "Time error", "Fetch error", "Read error", "Good" };
|
const char *ephtxt[] = { "Disabled", "Pending", "Time error", "Fetch error", "Read error", "Good" };
|
||||||
|
|
||||||
uint8_t getreply() {
|
uint8_t getreply() {
|
||||||
String s = client.readStringUntil('\n');
|
String s = client.readStringUntil('\n');
|
||||||
|
|
|
@ -7,5 +7,5 @@ void geteph();
|
||||||
enum EPHSTATE { EPH_NOTUSED, EPH_PENDING, EPH_TIMEERR, EPH_ERROR, EPH_EPHERROR, EPH_GOOD };
|
enum EPHSTATE { EPH_NOTUSED, EPH_PENDING, EPH_TIMEERR, EPH_ERROR, EPH_EPHERROR, EPH_GOOD };
|
||||||
|
|
||||||
extern uint8_t ephstate;
|
extern uint8_t ephstate;
|
||||||
extern char *ephtxt[];
|
extern const char *ephtxt[];
|
||||||
#endif
|
#endif
|
||||||
|
|
Ładowanie…
Reference in New Issue