Don't exit reparse if is setup

This commit is contained in:
Edward Firmo
2023-11-30 11:38:39 +01:00
parent bc677e6c21
commit 99616d4e79

View File

@@ -9,8 +9,7 @@ substitutions:
################## Defaults ################## ################## Defaults ##################
# Just in case user forgets to set something # # Just in case user forgets to set something #
nextion_update_url: "https://github.com/Blackymas/NSPanel_HA_Blueprint/raw/main/nspanel_eu.tft" nextion_update_url: "http://github.com/Blackymas/NSPanel_HA_Blueprint/raw/main/custom_configuration/nspanel_blank.tft"
# nextion_update_blank_url: "https://github.com/Blackymas/NSPanel_HA_Blueprint/raw/main/custom_configuration/nspanel_blank.tft"
############################################## ##############################################
##### DON'T CHANGE THIS ##### ##### DON'T CHANGE THIS #####
@@ -104,9 +103,11 @@ script:
upload_tries++; upload_tries++;
ESP_LOGD(TAG, "Try #%i", upload_tries); ESP_LOGD(TAG, "Try #%i", upload_tries);
nextion_status->execute(); nextion_status->execute();
ESP_LOGD(TAG, "Setting Nextion protocol reparse mode to passive"); if (!disp1->is_setup()) {
exit_reparse->execute(); ESP_LOGD(TAG, "Setting Nextion protocol reparse mode to passive");
delay_seconds_(2); exit_reparse->execute();
delay_seconds_(5);
}
ESP_LOGV(TAG, "Calling upload from Nextion component"); ESP_LOGV(TAG, "Calling upload from Nextion component");
//if (disp1->upload_tft()) id(restart_nspanel).press(); //if (disp1->upload_tft()) id(restart_nspanel).press();
ESP_LOGD(TAG, "Turn off Nextion"); ESP_LOGD(TAG, "Turn off Nextion");
@@ -146,6 +147,18 @@ script:
int content_length_ = 0; int content_length_ = 0;
int tft_size_ = 0; int tft_size_ = 0;
auto delay_seconds_ = [](int seconds) {
ESP_LOGD(TAG, "Wait %i seconds", seconds);
for (int i = 0; i < (seconds*4); i++) {
#ifdef ARDUINO
delay(250);
#elif defined(USE_ESP_IDF)
vTaskDelay(pdMS_TO_TICKS(250));
#endif
App.feed_wdt();
}
};
auto send_nextion_command = [](const std::string &command) -> bool auto send_nextion_command = [](const std::string &command) -> bool
{ {
static const char *const TAG = "script.upload_tft.send_nextion_command"; static const char *const TAG = "script.upload_tft.send_nextion_command";
@@ -358,9 +371,11 @@ script:
return upload_end_(false); return upload_end_(false);
} }
ESP_LOGD(TAG, "Setting Nextion protocol reparse mode to passive"); if (!disp1->is_setup()) {
exit_reparse->execute(); ESP_LOGD(TAG, "Setting Nextion protocol reparse mode to passive");
//id(disp1).set_protocol_reparse_mode(false); exit_reparse->execute();
delay_seconds_(5);
}
is_updating_ = true; is_updating_ = true;
@@ -621,9 +636,11 @@ script:
return upload_end_(false); return upload_end_(false);
} }
ESP_LOGD(TAG, "Setting Nextion protocol reparse mode to passive"); if (!disp1->is_setup()) {
exit_reparse->execute(); ESP_LOGD(TAG, "Setting Nextion protocol reparse mode to passive");
//id(disp1).set_protocol_reparse_mode(false); exit_reparse->execute();
delay_seconds_(5);
}
is_updating_ = true; is_updating_ = true;
@@ -744,18 +761,9 @@ script:
if (upload_tft_(url, id(tf_uart).get_baud_rate())) id(restart_nspanel).press(); if (upload_tft_(url, id(tf_uart).get_baud_rate())) id(restart_nspanel).press();
ESP_LOGD(TAG, "Turn off Nextion"); ESP_LOGD(TAG, "Turn off Nextion");
id(screen_power).turn_off(); id(screen_power).turn_off();
#ifdef ARDUINO delay_seconds_(2);
delay(1500);
#elif defined(ESP_PLATFORM)
vTaskDelay(pdMS_TO_TICKS(1500));
#endif
ESP_LOGD(TAG, "Turn on Nextion"); ESP_LOGD(TAG, "Turn on Nextion");
id(screen_power).turn_on(); delay_seconds_(5);
#ifdef ARDUINO
delay(1500);
#elif defined(ESP_PLATFORM)
vTaskDelay(pdMS_TO_TICKS(1500));
#endif
} }
unsigned int new_baud_rate; unsigned int new_baud_rate;
if (id(tf_uart).get_baud_rate() == 115200) { if (id(tf_uart).get_baud_rate() == 115200) {
@@ -770,19 +778,11 @@ script:
ESP_LOGE(TAG, "TFT upload failed."); ESP_LOGE(TAG, "TFT upload failed.");
ESP_LOGD(TAG, "Turn off Nextion"); ESP_LOGD(TAG, "Turn off Nextion");
id(screen_power).turn_off(); id(screen_power).turn_off();
#ifdef ARDUINO delay_seconds_(2);
delay(1500);
#elif defined(ESP_PLATFORM)
vTaskDelay(pdMS_TO_TICKS(1500));
#endif
ESP_LOGD(TAG, "Turn on Nextion"); ESP_LOGD(TAG, "Turn on Nextion");
id(screen_power).turn_on(); id(screen_power).turn_on();
ESP_LOGD(TAG, "Restarting esphome"); ESP_LOGD(TAG, "Restarting esphome");
#ifdef ARDUINO delay_seconds_(2);
delay(1500);
#elif defined(ESP_PLATFORM)
vTaskDelay(pdMS_TO_TICKS(1500));
#endif
id(restart_nspanel).press(); id(restart_nspanel).press();
ESP_LOGD(TAG, "Finished!"); ESP_LOGD(TAG, "Finished!");