Don't exit reparse if is setup
This commit is contained in:
@@ -9,8 +9,7 @@ substitutions:
|
||||
|
||||
################## Defaults ##################
|
||||
# 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_blank_url: "https://github.com/Blackymas/NSPanel_HA_Blueprint/raw/main/custom_configuration/nspanel_blank.tft"
|
||||
nextion_update_url: "http://github.com/Blackymas/NSPanel_HA_Blueprint/raw/main/custom_configuration/nspanel_blank.tft"
|
||||
##############################################
|
||||
|
||||
##### DON'T CHANGE THIS #####
|
||||
@@ -104,9 +103,11 @@ script:
|
||||
upload_tries++;
|
||||
ESP_LOGD(TAG, "Try #%i", upload_tries);
|
||||
nextion_status->execute();
|
||||
ESP_LOGD(TAG, "Setting Nextion protocol reparse mode to passive");
|
||||
exit_reparse->execute();
|
||||
delay_seconds_(2);
|
||||
if (!disp1->is_setup()) {
|
||||
ESP_LOGD(TAG, "Setting Nextion protocol reparse mode to passive");
|
||||
exit_reparse->execute();
|
||||
delay_seconds_(5);
|
||||
}
|
||||
ESP_LOGV(TAG, "Calling upload from Nextion component");
|
||||
//if (disp1->upload_tft()) id(restart_nspanel).press();
|
||||
ESP_LOGD(TAG, "Turn off Nextion");
|
||||
@@ -146,6 +147,18 @@ script:
|
||||
int content_length_ = 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
|
||||
{
|
||||
static const char *const TAG = "script.upload_tft.send_nextion_command";
|
||||
@@ -358,9 +371,11 @@ script:
|
||||
return upload_end_(false);
|
||||
}
|
||||
|
||||
ESP_LOGD(TAG, "Setting Nextion protocol reparse mode to passive");
|
||||
exit_reparse->execute();
|
||||
//id(disp1).set_protocol_reparse_mode(false);
|
||||
if (!disp1->is_setup()) {
|
||||
ESP_LOGD(TAG, "Setting Nextion protocol reparse mode to passive");
|
||||
exit_reparse->execute();
|
||||
delay_seconds_(5);
|
||||
}
|
||||
|
||||
is_updating_ = true;
|
||||
|
||||
@@ -621,9 +636,11 @@ script:
|
||||
return upload_end_(false);
|
||||
}
|
||||
|
||||
ESP_LOGD(TAG, "Setting Nextion protocol reparse mode to passive");
|
||||
exit_reparse->execute();
|
||||
//id(disp1).set_protocol_reparse_mode(false);
|
||||
if (!disp1->is_setup()) {
|
||||
ESP_LOGD(TAG, "Setting Nextion protocol reparse mode to passive");
|
||||
exit_reparse->execute();
|
||||
delay_seconds_(5);
|
||||
}
|
||||
|
||||
is_updating_ = true;
|
||||
|
||||
@@ -744,18 +761,9 @@ script:
|
||||
if (upload_tft_(url, id(tf_uart).get_baud_rate())) id(restart_nspanel).press();
|
||||
ESP_LOGD(TAG, "Turn off Nextion");
|
||||
id(screen_power).turn_off();
|
||||
#ifdef ARDUINO
|
||||
delay(1500);
|
||||
#elif defined(ESP_PLATFORM)
|
||||
vTaskDelay(pdMS_TO_TICKS(1500));
|
||||
#endif
|
||||
delay_seconds_(2);
|
||||
ESP_LOGD(TAG, "Turn on Nextion");
|
||||
id(screen_power).turn_on();
|
||||
#ifdef ARDUINO
|
||||
delay(1500);
|
||||
#elif defined(ESP_PLATFORM)
|
||||
vTaskDelay(pdMS_TO_TICKS(1500));
|
||||
#endif
|
||||
delay_seconds_(5);
|
||||
}
|
||||
unsigned int new_baud_rate;
|
||||
if (id(tf_uart).get_baud_rate() == 115200) {
|
||||
@@ -770,19 +778,11 @@ script:
|
||||
ESP_LOGE(TAG, "TFT upload failed.");
|
||||
ESP_LOGD(TAG, "Turn off Nextion");
|
||||
id(screen_power).turn_off();
|
||||
#ifdef ARDUINO
|
||||
delay(1500);
|
||||
#elif defined(ESP_PLATFORM)
|
||||
vTaskDelay(pdMS_TO_TICKS(1500));
|
||||
#endif
|
||||
delay_seconds_(2);
|
||||
ESP_LOGD(TAG, "Turn on Nextion");
|
||||
id(screen_power).turn_on();
|
||||
ESP_LOGD(TAG, "Restarting esphome");
|
||||
#ifdef ARDUINO
|
||||
delay(1500);
|
||||
#elif defined(ESP_PLATFORM)
|
||||
vTaskDelay(pdMS_TO_TICKS(1500));
|
||||
#endif
|
||||
delay_seconds_(2);
|
||||
id(restart_nspanel).press();
|
||||
|
||||
ESP_LOGD(TAG, "Finished!");
|
||||
Reference in New Issue
Block a user