mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-19 01:06:41 +00:00
Updater changes
This commit is contained in:
parent
a5564a4b41
commit
f13312b266
@ -21,7 +21,7 @@ Licensed under the MIT License <http://opensource.org/licenses/MIT>.
|
|||||||
#else
|
#else
|
||||||
#include "WProgram.h"
|
#include "WProgram.h"
|
||||||
#endif
|
#endif
|
||||||
#include "StringStream.h"
|
//#include "StringStream.h"
|
||||||
typedef void (*printfunction)(uint8_t tag, int level, Print *);
|
typedef void (*printfunction)(uint8_t tag, int level, Print *);
|
||||||
|
|
||||||
//#include <stdint.h>
|
//#include <stdint.h>
|
||||||
|
25
src/hasp.cpp
25
src/hasp.cpp
@ -304,8 +304,9 @@ void haspReconnect()
|
|||||||
lv_obj_set_hidden(obj, true);*/
|
lv_obj_set_hidden(obj, true);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
String progress_str((char *)0);
|
// String progress_str((char *)0);
|
||||||
|
|
||||||
|
// Shows/hides the the global progress bar and updates the value
|
||||||
void haspProgressVal(uint8_t val)
|
void haspProgressVal(uint8_t val)
|
||||||
{
|
{
|
||||||
lv_obj_t * layer = lv_disp_get_layer_sys(NULL);
|
lv_obj_t * layer = lv_disp_get_layer_sys(NULL);
|
||||||
@ -316,8 +317,8 @@ void haspProgressVal(uint8_t val)
|
|||||||
lv_obj_set_hidden(bar, true);
|
lv_obj_set_hidden(bar, true);
|
||||||
lv_obj_set_style_local_bg_opa(layer, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_0);
|
lv_obj_set_style_local_bg_opa(layer, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_0);
|
||||||
lv_obj_set_style_local_value_str(bar, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, "");
|
lv_obj_set_style_local_value_str(bar, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, "");
|
||||||
#if defined(ARCH_ARDUINO_ESP32) || defined(ARCH_ARDUINO_ESP8266)
|
#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
|
||||||
progress_str.clear();
|
// progress_str.clear();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -331,17 +332,23 @@ void haspProgressVal(uint8_t val)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sets the value string of the global progress bar
|
||||||
void haspProgressMsg(const char * msg)
|
void haspProgressMsg(const char * msg)
|
||||||
{
|
{
|
||||||
lv_obj_t * bar = hasp_find_obj_from_id(255, 10);
|
lv_obj_t * bar = hasp_find_obj_from_id(255, 10);
|
||||||
if(bar) {
|
hasp_process_obj_attribute(bar, "value_str", msg, true); // literal string
|
||||||
progress_str.reserve(64);
|
lv_task_handler(); /* let the GUI do its work */
|
||||||
progress_str = msg;
|
|
||||||
lv_obj_set_style_local_value_str(bar, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, progress_str.c_str());
|
/* if(bar) {
|
||||||
lv_task_handler(); /* let the GUI do its work */
|
progress_str.reserve(64);
|
||||||
}
|
progress_str = msg;
|
||||||
|
lv_obj_set_style_local_value_str(bar, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, progress_str.c_str());
|
||||||
|
|
||||||
|
lv_task_handler(); // let the GUI do its work
|
||||||
|
} */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sets the value string of the global progress bar
|
||||||
void haspProgressMsg(const __FlashStringHelper * msg)
|
void haspProgressMsg(const __FlashStringHelper * msg)
|
||||||
{
|
{
|
||||||
haspProgressMsg(String(msg).c_str());
|
haspProgressMsg(String(msg).c_str());
|
||||||
|
@ -301,9 +301,9 @@ void handleTouch(int8_t contacts, GTPoint * points)
|
|||||||
GT911_num_touches = contacts;
|
GT911_num_touches = contacts;
|
||||||
GT911_points = points;
|
GT911_points = points;
|
||||||
|
|
||||||
Log.trace(TAG_GUI,"Contacts: %d", contacts);
|
Log.trace(TAG_GUI, "Contacts: %d", contacts);
|
||||||
for(uint8_t i = 0; i < contacts; i++) {
|
for(uint8_t i = 0; i < contacts; i++) {
|
||||||
Log.trace(TAG_GUI,"C%d: #%d %d,%d s:%d", i, points[i].trackId, points[i].x, points[i].y, points[i].area);
|
Log.trace(TAG_GUI, "C%d: #%d %d,%d s:%d", i, points[i].trackId, points[i].x, points[i].y, points[i].area);
|
||||||
yield();
|
yield();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -378,7 +378,7 @@ void GT911_setup()
|
|||||||
|
|
||||||
touch.setHandler(handleTouch);
|
touch.setHandler(handleTouch);
|
||||||
touchStart();
|
touchStart();
|
||||||
Log.verbose(TAG_GUI,F("Goodix GT911x touch driver started"));
|
Log.verbose(TAG_GUI, F("Goodix GT911x touch driver started"));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -513,16 +513,16 @@ void guiSetup()
|
|||||||
/* Dump TFT Configuration */
|
/* Dump TFT Configuration */
|
||||||
// tftSetup(tft);
|
// tftSetup(tft);
|
||||||
#ifdef USE_DMA_TO_TFT
|
#ifdef USE_DMA_TO_TFT
|
||||||
Log.verbose(TAG_GUI,F("DMA : ENABLED"));
|
Log.verbose(TAG_GUI, F("DMA : ENABLED"));
|
||||||
#else
|
#else
|
||||||
Log.verbose(TAG_GUI,F("DMA : DISABLED"));
|
Log.verbose(TAG_GUI, F("DMA : DISABLED"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Load User Settings */
|
/* Load User Settings */
|
||||||
// guiSetConfig(settings);
|
// guiSetConfig(settings);
|
||||||
/* Setup Backlight Control Pin */
|
/* Setup Backlight Control Pin */
|
||||||
if(guiBacklightPin >= 0) {
|
if(guiBacklightPin >= 0) {
|
||||||
Log.verbose(TAG_LVGL,F("Backlight: Pin %d"), guiBacklightPin);
|
Log.verbose(TAG_LVGL, F("Backlight: Pin %d"), guiBacklightPin);
|
||||||
|
|
||||||
#if defined(ARDUINO_ARCH_ESP32)
|
#if defined(ARDUINO_ARCH_ESP32)
|
||||||
// pinMode(guiBacklightPin, OUTPUT);
|
// pinMode(guiBacklightPin, OUTPUT);
|
||||||
@ -535,16 +535,17 @@ void guiSetup()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.verbose(TAG_LVGL,F("Version : %u.%u.%u %s"), LVGL_VERSION_MAJOR, LVGL_VERSION_MINOR, LVGL_VERSION_PATCH,
|
Log.verbose(TAG_LVGL, F("Version : %u.%u.%u %s"), LVGL_VERSION_MAJOR, LVGL_VERSION_MINOR, LVGL_VERSION_PATCH,
|
||||||
PSTR(LVGL_VERSION_INFO));
|
PSTR(LVGL_VERSION_INFO));
|
||||||
Log.verbose(TAG_LVGL,F("Rotation : %d"), guiRotation);
|
|
||||||
|
Log.verbose(TAG_LVGL, F("Rotation : %d"), guiRotation);
|
||||||
#ifdef LV_MEM_SIZE
|
#ifdef LV_MEM_SIZE
|
||||||
Log.verbose(TAG_LVGL,F("MEM size : %d"), LV_MEM_SIZE);
|
Log.verbose(TAG_LVGL, F("MEM size : %d"), LV_MEM_SIZE);
|
||||||
#endif
|
#endif
|
||||||
Log.verbose(TAG_LVGL,F("VFB size : %d"), (size_t)sizeof(lv_color_t) * guiVDBsize);
|
Log.verbose(TAG_LVGL, F("VFB size : %d"), (size_t)sizeof(lv_color_t) * guiVDBsize);
|
||||||
|
|
||||||
#if LV_USE_LOG != 0
|
#if LV_USE_LOG != 0
|
||||||
Log.verbose(TAG_LVGL,F("Registering lvgl logging handler"));
|
Log.verbose(TAG_LVGL, F("Registering lvgl logging handler"));
|
||||||
lv_log_register_print_cb(debugLvgl); /* register print function for debugging */
|
lv_log_register_print_cb(debugLvgl); /* register print function for debugging */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -746,7 +747,7 @@ bool guiGetConfig(const JsonObject & settings)
|
|||||||
JsonArray array = settings[FPSTR(F_GUI_CALIBRATION)].as<JsonArray>();
|
JsonArray array = settings[FPSTR(F_GUI_CALIBRATION)].as<JsonArray>();
|
||||||
uint8_t i = 0;
|
uint8_t i = 0;
|
||||||
for(JsonVariant v : array) {
|
for(JsonVariant v : array) {
|
||||||
Log.verbose(TAG_GUI,F("GUI CONF: %d: %d <=> %d"), i, calData[i], v.as<uint16_t>());
|
Log.verbose(TAG_GUI, F("GUI CONF: %d: %d <=> %d"), i, calData[i], v.as<uint16_t>());
|
||||||
if(i < 5) {
|
if(i < 5) {
|
||||||
if(calData[i] != v.as<uint16_t>()) changed = true;
|
if(calData[i] != v.as<uint16_t>()) changed = true;
|
||||||
v.set(calData[i]);
|
v.set(calData[i]);
|
||||||
@ -798,7 +799,7 @@ bool guiSetConfig(const JsonObject & settings)
|
|||||||
|
|
||||||
if(!settings[FPSTR(F_GUI_POINTER)].isNull()) {
|
if(!settings[FPSTR(F_GUI_POINTER)].isNull()) {
|
||||||
if(guiShowPointer != settings[FPSTR(F_GUI_POINTER)].as<bool>()) {
|
if(guiShowPointer != settings[FPSTR(F_GUI_POINTER)].as<bool>()) {
|
||||||
Log.trace(TAG_GUI,F("guiShowPointer set"));
|
Log.trace(TAG_GUI, F("guiShowPointer set"));
|
||||||
}
|
}
|
||||||
changed |= guiShowPointer != settings[FPSTR(F_GUI_POINTER)].as<bool>();
|
changed |= guiShowPointer != settings[FPSTR(F_GUI_POINTER)].as<bool>();
|
||||||
|
|
||||||
@ -819,11 +820,11 @@ bool guiSetConfig(const JsonObject & settings)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(calData[0] != 0 || calData[1] != 65535 || calData[2] != 0 || calData[3] != 65535) {
|
if(calData[0] != 0 || calData[1] != 65535 || calData[2] != 0 || calData[3] != 65535) {
|
||||||
Log.trace(TAG_GUI,F("calData set [%u, %u, %u, %u, %u]"), calData[0], calData[1], calData[2], calData[3],
|
Log.trace(TAG_GUI, F("calData set [%u, %u, %u, %u, %u]"), calData[0], calData[1], calData[2], calData[3],
|
||||||
calData[4]);
|
calData[4]);
|
||||||
oobeSetAutoCalibrate(false);
|
oobeSetAutoCalibrate(false);
|
||||||
} else {
|
} else {
|
||||||
Log.notice(TAG_GUI,F("First Touch Calibration enabled"));
|
Log.notice(TAG_GUI, F("First Touch Calibration enabled"));
|
||||||
oobeSetAutoCalibrate(true);
|
oobeSetAutoCalibrate(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -900,7 +901,7 @@ static void gui_get_bitmap_header(uint8_t * buffer, size_t bufsize)
|
|||||||
|
|
||||||
void gui_flush_not_complete()
|
void gui_flush_not_complete()
|
||||||
{
|
{
|
||||||
Log.warning(TAG_GUI,F("GUI: Pixelbuffer not completely sent"));
|
Log.warning(TAG_GUI, F("GUI: Pixelbuffer not completely sent"));
|
||||||
}
|
}
|
||||||
#endif // HASP_USE_SPIFFS > 0 || HASP_USE_HTTP > 0
|
#endif // HASP_USE_SPIFFS > 0 || HASP_USE_HTTP > 0
|
||||||
|
|
||||||
@ -934,7 +935,7 @@ void guiTakeScreenshot(const char * pFileName)
|
|||||||
|
|
||||||
size_t len = pFileOut.write(buffer, 122);
|
size_t len = pFileOut.write(buffer, 122);
|
||||||
if(len == 122) {
|
if(len == 122) {
|
||||||
Log.verbose(TAG_GUI,F("GUI: Bitmap header written"));
|
Log.verbose(TAG_GUI, F("GUI: Bitmap header written"));
|
||||||
|
|
||||||
/* Refresh screen to screenshot callback */
|
/* Refresh screen to screenshot callback */
|
||||||
lv_disp_t * disp = lv_disp_get_default();
|
lv_disp_t * disp = lv_disp_get_default();
|
||||||
@ -945,15 +946,15 @@ void guiTakeScreenshot(const char * pFileName)
|
|||||||
lv_refr_now(NULL); /* Will call our disp_drv.disp_flush function */
|
lv_refr_now(NULL); /* Will call our disp_drv.disp_flush function */
|
||||||
disp->driver.flush_cb = flush_cb; /* restore callback */
|
disp->driver.flush_cb = flush_cb; /* restore callback */
|
||||||
|
|
||||||
Log.verbose(TAG_GUI,F("GUI: Bitmap data flushed to %s"), pFileName);
|
Log.verbose(TAG_GUI, F("GUI: Bitmap data flushed to %s"), pFileName);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Log.error(TAG_GUI,F("GUI: Data written does not match header size"));
|
Log.error(TAG_GUI, F("GUI: Data written does not match header size"));
|
||||||
}
|
}
|
||||||
pFileOut.close();
|
pFileOut.close();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Log.warning(TAG_GUI,F("GUI: %s cannot be opened"), pFileName);
|
Log.warning(TAG_GUI, F("GUI: %s cannot be opened"), pFileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -982,7 +983,7 @@ void guiTakeScreenshot()
|
|||||||
gui_get_bitmap_header(buffer, sizeof(buffer));
|
gui_get_bitmap_header(buffer, sizeof(buffer));
|
||||||
|
|
||||||
if(httpClientWrite(buffer, 122) == 122) {
|
if(httpClientWrite(buffer, 122) == 122) {
|
||||||
Log.verbose(TAG_GUI,F("GUI: Bitmap header sent"));
|
Log.verbose(TAG_GUI, F("GUI: Bitmap header sent"));
|
||||||
|
|
||||||
/* Refresh screen to screenshot callback */
|
/* Refresh screen to screenshot callback */
|
||||||
lv_disp_t * disp = lv_disp_get_default();
|
lv_disp_t * disp = lv_disp_get_default();
|
||||||
@ -993,9 +994,9 @@ void guiTakeScreenshot()
|
|||||||
lv_refr_now(NULL); /* Will call our disp_drv.disp_flush function */
|
lv_refr_now(NULL); /* Will call our disp_drv.disp_flush function */
|
||||||
disp->driver.flush_cb = flush_cb; /* restore callback */
|
disp->driver.flush_cb = flush_cb; /* restore callback */
|
||||||
|
|
||||||
Log.verbose(TAG_GUI,F("GUI: Bitmap data flushed to webclient"));
|
Log.verbose(TAG_GUI, F("GUI: Bitmap data flushed to webclient"));
|
||||||
} else {
|
} else {
|
||||||
Log.error(TAG_GUI,F("GUI: Data sent does not match header size"));
|
Log.error(TAG_GUI, F("GUI: Data sent does not match header size"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
@ -696,7 +696,9 @@ void webHandleFirmwareUpdate()
|
|||||||
webUploadProgress();
|
webUploadProgress();
|
||||||
}
|
}
|
||||||
} else if(upload->status == UPLOAD_FILE_END) {
|
} else if(upload->status == UPLOAD_FILE_END) {
|
||||||
|
haspProgressVal(100);
|
||||||
if(Update.end(true)) { // true to set the size to the current progress
|
if(Update.end(true)) { // true to set the size to the current progress
|
||||||
|
haspProgressMsg(F("Applying Firmware & Reboot"));
|
||||||
webUpdateReboot();
|
webUpdateReboot();
|
||||||
} else {
|
} else {
|
||||||
webUpdatePrintError();
|
webUpdatePrintError();
|
||||||
|
@ -60,9 +60,7 @@ void otaSetup()
|
|||||||
Log.notice(TAG_OTA, F("Start update"));
|
Log.notice(TAG_OTA, F("Start update"));
|
||||||
haspProgressVal(0);
|
haspProgressVal(0);
|
||||||
haspProgressMsg(F("Firmware Update"));
|
haspProgressMsg(F("Firmware Update"));
|
||||||
// dispatchPage("0");
|
|
||||||
otaPrecentageComplete = 0;
|
otaPrecentageComplete = 0;
|
||||||
// haspSetAttr("p[0].b[1].txt", "\"ESP OTA Update\"");
|
|
||||||
});
|
});
|
||||||
ArduinoOTA.onEnd([]() {
|
ArduinoOTA.onEnd([]() {
|
||||||
otaPrecentageComplete = 100;
|
otaPrecentageComplete = 100;
|
||||||
@ -70,33 +68,40 @@ void otaSetup()
|
|||||||
haspProgressVal(100);
|
haspProgressVal(100);
|
||||||
otaProgress();
|
otaProgress();
|
||||||
otaPrecentageComplete = -1;
|
otaPrecentageComplete = -1;
|
||||||
// dispatchPage("0");
|
// setup();
|
||||||
// haspSetAttr("p[0].b[1].txt", "\"ESP OTA Update\\rComplete!\"");
|
dispatchReboot(true);
|
||||||
setup();
|
|
||||||
// dispatchReboot(true);
|
|
||||||
});
|
});
|
||||||
ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
|
ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
|
||||||
if(total != 0) {
|
if(total != 0) {
|
||||||
otaPrecentageComplete = progress * 100 / total;
|
otaPrecentageComplete = progress * 100 / total;
|
||||||
haspProgressVal(otaPrecentageComplete);
|
haspProgressVal(otaPrecentageComplete);
|
||||||
}
|
}
|
||||||
|
|
||||||
// haspSetAttr("p[0].b[1].txt", "\"ESP OTA Update\\rProgress: " + String(progress / (total / 100)) + "%\"");
|
|
||||||
});
|
});
|
||||||
ArduinoOTA.onError([](ota_error_t error) {
|
ArduinoOTA.onError([](ota_error_t error) {
|
||||||
|
char buffer[16];
|
||||||
|
switch(error) {
|
||||||
|
case OTA_AUTH_ERROR:
|
||||||
|
snprintf_P(buffer, sizeof(buffer), PSTR("Auth"));
|
||||||
|
break;
|
||||||
|
case OTA_BEGIN_ERROR:
|
||||||
|
snprintf_P(buffer, sizeof(buffer), PSTR("Begin"));
|
||||||
|
break;
|
||||||
|
case OTA_CONNECT_ERROR:
|
||||||
|
snprintf_P(buffer, sizeof(buffer), PSTR("Connect"));
|
||||||
|
break;
|
||||||
|
case OTA_RECEIVE_ERROR:
|
||||||
|
snprintf_P(buffer, sizeof(buffer), PSTR("Receive"));
|
||||||
|
break;
|
||||||
|
case OTA_END_ERROR:
|
||||||
|
snprintf_P(buffer, sizeof(buffer), PSTR("End"));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
snprintf_P(buffer, sizeof(buffer), PSTR("Something"));
|
||||||
|
}
|
||||||
|
|
||||||
otaPrecentageComplete = -1;
|
otaPrecentageComplete = -1;
|
||||||
Log.error(TAG_OTA, F("ERROR code %u"), error);
|
Log.error(TAG_OTA, F("ERROR - %s failed (%s)"), buffer, error);
|
||||||
if(error == OTA_AUTH_ERROR)
|
haspProgressMsg(F("ESP OTA FAILED"));
|
||||||
Log.error(TAG_OTA, F("ERROR - Auth Failed"));
|
|
||||||
else if(error == OTA_BEGIN_ERROR)
|
|
||||||
Log.error(TAG_OTA, F("ERROR - Begin Failed"));
|
|
||||||
else if(error == OTA_CONNECT_ERROR)
|
|
||||||
Log.error(TAG_OTA, F("ERROR - Connect Failed"));
|
|
||||||
else if(error == OTA_RECEIVE_ERROR)
|
|
||||||
Log.error(TAG_OTA, F("ERROR - Receive Failed"));
|
|
||||||
else if(error == OTA_END_ERROR)
|
|
||||||
Log.error(TAG_OTA, F("ERROR - End Failed"));
|
|
||||||
// haspSetAttr("p[0].b[1].txt", "\"ESP OTA FAILED\"");
|
|
||||||
// delay(5000);
|
// delay(5000);
|
||||||
// haspSendCmd("page " + String(nextionActivePage));
|
// haspSendCmd("page " + String(nextionActivePage));
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user