Compare commits
2 Commits
c60f4e97ce
...
4750a22ddf
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4750a22ddf | ||
|
|
7e70e7c3c1 |
@@ -15,18 +15,15 @@ substitutions:
|
|||||||
##############################################
|
##############################################
|
||||||
|
|
||||||
##### DON'T CHANGE THIS #####
|
##### DON'T CHANGE THIS #####
|
||||||
upload_tft_baud_rate: "921600"
|
upload_tft_baud_rate: "921600" # To do: Move to UI
|
||||||
#############################
|
#############################
|
||||||
|
|
||||||
##### External components #####
|
##### External components #####
|
||||||
external_components:
|
external_components:
|
||||||
- source:
|
- source: github://pr#6192 # Change this when that PR gets released (2024.2?)
|
||||||
type: git
|
|
||||||
url: https://github.com/edwardtfn/esphome
|
|
||||||
ref: nextion-23
|
|
||||||
components:
|
components:
|
||||||
- nextion
|
- nextion
|
||||||
refresh: 300s
|
refresh: 3s # Change this before the release: 300s
|
||||||
|
|
||||||
api:
|
api:
|
||||||
on_client_connected:
|
on_client_connected:
|
||||||
@@ -114,14 +111,14 @@ script:
|
|||||||
ESP_LOGD(TAG, "Waiting for empty UART and Nextion queues");
|
ESP_LOGD(TAG, "Waiting for empty UART and Nextion queues");
|
||||||
- wait_until:
|
- wait_until:
|
||||||
condition:
|
condition:
|
||||||
- lambda: !lambda return (disp1->queue_size() < 1);
|
- lambda: return (disp1->queue_size() < 1);
|
||||||
- lambda: !lambda return (tf_uart->available() < 1);
|
- lambda: return (tf_uart->available() < 1);
|
||||||
timeout: 10s
|
timeout: 10s
|
||||||
- delay: 2s
|
- delay: 2s
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
static const char *const TAG = "addon_upload_tft.script.nextion_upload";
|
static const char *const TAG = "addon_upload_tft.script.nextion_upload";
|
||||||
ESP_LOGD(TAG, "Starting TFT upload...");
|
ESP_LOGD(TAG, "Starting TFT upload...");
|
||||||
id(tft_upload_result) = disp1->upload_tft();
|
id(tft_upload_result) = disp1->upload_tft(!disp1->is_setup());
|
||||||
ESP_LOGD(TAG, "TFT upload: %s", esphome::nextion::Nextion::tft_upload_result_to_string(id(tft_upload_result)));
|
ESP_LOGD(TAG, "TFT upload: %s", esphome::nextion::Nextion::tft_upload_result_to_string(id(tft_upload_result)));
|
||||||
|
|
||||||
- id: open_upload_dialog
|
- id: open_upload_dialog
|
||||||
@@ -272,7 +269,7 @@ script:
|
|||||||
- lambda: page_id->update();
|
- lambda: page_id->update();
|
||||||
- wait_until:
|
- wait_until:
|
||||||
condition:
|
condition:
|
||||||
- lambda: !lambda return (page_id->state == 26);
|
- lambda: return (page_id->state == 26);
|
||||||
timeout: 2s
|
timeout: 2s
|
||||||
- script.execute:
|
- script.execute:
|
||||||
id: report_upload_progress
|
id: report_upload_progress
|
||||||
@@ -289,20 +286,24 @@ script:
|
|||||||
- script.wait: stop_all
|
- script.wait: stop_all
|
||||||
- wait_until:
|
- wait_until:
|
||||||
condition:
|
condition:
|
||||||
- lambda: !lambda return (!id(tft_is_valid));
|
- lambda: return (!id(tft_is_valid));
|
||||||
timeout: 1s
|
timeout: 1s
|
||||||
|
|
||||||
### Attempt twice at the target baud rate
|
### Attempt twice at the target baud rate
|
||||||
- script.execute:
|
- if:
|
||||||
id: upload_tft_sequence_attempt
|
condition:
|
||||||
baud_rate: !lambda return id(baud_rate_target);
|
- lambda: return disp1->is_setup();
|
||||||
- script.wait: upload_tft_sequence_attempt
|
then:
|
||||||
|
- script.execute:
|
||||||
|
id: upload_tft_sequence_attempt
|
||||||
|
baud_rate: !lambda return id(baud_rate_target);
|
||||||
|
- script.wait: upload_tft_sequence_attempt
|
||||||
|
|
||||||
### Attempt twice at the original baud rate
|
### Attempt twice at the original baud rate
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
return (id(baud_rate_original) != id(baud_rate_target));
|
return ((id(baud_rate_original) != id(baud_rate_target)) or (!disp1->is_setup()));
|
||||||
then:
|
then:
|
||||||
- script.execute:
|
- script.execute:
|
||||||
id: upload_tft_sequence_attempt
|
id: upload_tft_sequence_attempt
|
||||||
@@ -327,7 +328,7 @@ script:
|
|||||||
- script.wait: report_upload_progress
|
- script.wait: report_upload_progress
|
||||||
- wait_until:
|
- wait_until:
|
||||||
condition:
|
condition:
|
||||||
- lambda: !lambda return (!id(tft_is_valid));
|
- lambda: return (!id(tft_is_valid));
|
||||||
timeout: 3s
|
timeout: 3s
|
||||||
- switch.turn_off: screen_power
|
- switch.turn_off: screen_power
|
||||||
- delay: 2s
|
- delay: 2s
|
||||||
@@ -345,7 +346,7 @@ script:
|
|||||||
- script.wait: report_upload_progress
|
- script.wait: report_upload_progress
|
||||||
- wait_until:
|
- wait_until:
|
||||||
condition:
|
condition:
|
||||||
- lambda: !lambda return (!id(tft_is_valid));
|
- lambda: return (!id(tft_is_valid));
|
||||||
timeout: 5s
|
timeout: 5s
|
||||||
- script.execute:
|
- script.execute:
|
||||||
id: report_upload_progress
|
id: report_upload_progress
|
||||||
@@ -353,12 +354,12 @@ script:
|
|||||||
- script.wait: report_upload_progress
|
- script.wait: report_upload_progress
|
||||||
- wait_until:
|
- wait_until:
|
||||||
condition:
|
condition:
|
||||||
- lambda: !lambda return (!id(tft_is_valid));
|
- lambda: return (!id(tft_is_valid));
|
||||||
timeout: 5s
|
timeout: 5s
|
||||||
- switch.turn_off: screen_power
|
- switch.turn_off: screen_power
|
||||||
- delay: 2s
|
- delay: 2s
|
||||||
# Restart ESPHome
|
# Restart ESPHome
|
||||||
- lambda: !lambda App.safe_reboot();
|
- lambda: App.safe_reboot();
|
||||||
|
|
||||||
### This code should never run
|
### This code should never run
|
||||||
- delay: 2s
|
- delay: 2s
|
||||||
@@ -398,7 +399,7 @@ script:
|
|||||||
mode: single
|
mode: single
|
||||||
then:
|
then:
|
||||||
- logger.log: "Attempting to upload TFT"
|
- logger.log: "Attempting to upload TFT"
|
||||||
- lambda: !lambda id(tft_upload_attempt)++;
|
- lambda: id(tft_upload_attempt)++;
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
char update_msg[128];
|
char update_msg[128];
|
||||||
sprintf(update_msg, "Attempt #%d at %" PRIu32 " bps", id(tft_upload_attempt), tf_uart->get_baud_rate());
|
sprintf(update_msg, "Attempt #%d at %" PRIu32 " bps", id(tft_upload_attempt), tf_uart->get_baud_rate());
|
||||||
@@ -407,7 +408,7 @@ script:
|
|||||||
- script.wait: report_upload_progress
|
- script.wait: report_upload_progress
|
||||||
- wait_until:
|
- wait_until:
|
||||||
condition:
|
condition:
|
||||||
- lambda: !lambda return (!id(tft_is_valid));
|
- lambda: return (!id(tft_is_valid));
|
||||||
timeout: 1s
|
timeout: 1s
|
||||||
- script.execute: nextion_upload
|
- script.execute: nextion_upload
|
||||||
- script.wait: nextion_upload
|
- script.wait: nextion_upload
|
||||||
@@ -419,14 +420,16 @@ script:
|
|||||||
- script.wait: report_upload_progress
|
- script.wait: report_upload_progress
|
||||||
- if:
|
- if:
|
||||||
condition:
|
condition:
|
||||||
not:
|
- lambda: |-
|
||||||
- lambda: return id(tft_upload_result) == esphome::nextion::Nextion::TFTUploadResult::UNKNOWN;
|
return
|
||||||
- lambda: return id(tft_upload_result) == esphome::nextion::Nextion::TFTUploadResult::UPLOAD_IN_PROGRESS;
|
id(tft_upload_result) != esphome::nextion::Nextion::TFTUploadResult::UNKNOWN and
|
||||||
- lambda: return id(tft_upload_result) == esphome::nextion::Nextion::TFTUploadResult::NEXTION_ERROR_PREPARATION_FAILED;
|
id(tft_upload_result) != esphome::nextion::Nextion::TFTUploadResult::UPLOAD_IN_PROGRESS and
|
||||||
- lambda: return id(tft_upload_result) == esphome::nextion::Nextion::TFTUploadResult::NEXTION_ERROR_INVALID_RESPONSE;
|
id(tft_upload_result) != esphome::nextion::Nextion::TFTUploadResult::NEXTION_ERROR_PREPARATION_FAILED and
|
||||||
|
id(tft_upload_result) != esphome::nextion::Nextion::TFTUploadResult::NEXTION_ERROR_INVALID_RESPONSE;
|
||||||
then:
|
then:
|
||||||
- delay: 5s
|
- delay: 5s
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
|
ESP_LOGI("addon_upload_tft.script.upload_tft_attempt", "Restarting ESPHome");
|
||||||
App.safe_reboot();
|
App.safe_reboot();
|
||||||
|
|
||||||
- id: !extend watchdog
|
- id: !extend watchdog
|
||||||
|
|||||||
Reference in New Issue
Block a user