Update nspanel_esphome_addon_upload_tft.yaml

Use target speed only when setup
This commit is contained in:
Edward Firmo
2024-02-09 10:14:06 +01:00
parent 7e70e7c3c1
commit 4750a22ddf

View File

@@ -111,8 +111,8 @@ script:
ESP_LOGD(TAG, "Waiting for empty UART and Nextion queues");
- wait_until:
condition:
- lambda: !lambda return (disp1->queue_size() < 1);
- lambda: !lambda return (tf_uart->available() < 1);
- lambda: return (disp1->queue_size() < 1);
- lambda: return (tf_uart->available() < 1);
timeout: 10s
- delay: 2s
- lambda: |-
@@ -269,7 +269,7 @@ script:
- lambda: page_id->update();
- wait_until:
condition:
- lambda: !lambda return (page_id->state == 26);
- lambda: return (page_id->state == 26);
timeout: 2s
- script.execute:
id: report_upload_progress
@@ -286,20 +286,24 @@ script:
- script.wait: stop_all
- wait_until:
condition:
- lambda: !lambda return (!id(tft_is_valid));
- lambda: return (!id(tft_is_valid));
timeout: 1s
### Attempt twice at the target baud rate
- script.execute:
id: upload_tft_sequence_attempt
baud_rate: !lambda return id(baud_rate_target);
- script.wait: upload_tft_sequence_attempt
- if:
condition:
- lambda: return disp1->is_setup();
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
- if:
condition:
- lambda: |-
return (id(baud_rate_original) != id(baud_rate_target));
return ((id(baud_rate_original) != id(baud_rate_target)) or (!disp1->is_setup()));
then:
- script.execute:
id: upload_tft_sequence_attempt
@@ -324,7 +328,7 @@ script:
- script.wait: report_upload_progress
- wait_until:
condition:
- lambda: !lambda return (!id(tft_is_valid));
- lambda: return (!id(tft_is_valid));
timeout: 3s
- switch.turn_off: screen_power
- delay: 2s
@@ -342,7 +346,7 @@ script:
- script.wait: report_upload_progress
- wait_until:
condition:
- lambda: !lambda return (!id(tft_is_valid));
- lambda: return (!id(tft_is_valid));
timeout: 5s
- script.execute:
id: report_upload_progress
@@ -350,12 +354,12 @@ script:
- script.wait: report_upload_progress
- wait_until:
condition:
- lambda: !lambda return (!id(tft_is_valid));
- lambda: return (!id(tft_is_valid));
timeout: 5s
- switch.turn_off: screen_power
- delay: 2s
# Restart ESPHome
- lambda: !lambda App.safe_reboot();
- lambda: App.safe_reboot();
### This code should never run
- delay: 2s
@@ -395,7 +399,7 @@ script:
mode: single
then:
- logger.log: "Attempting to upload TFT"
- lambda: !lambda id(tft_upload_attempt)++;
- lambda: id(tft_upload_attempt)++;
- lambda: |-
char update_msg[128];
sprintf(update_msg, "Attempt #%d at %" PRIu32 " bps", id(tft_upload_attempt), tf_uart->get_baud_rate());
@@ -404,7 +408,7 @@ script:
- script.wait: report_upload_progress
- wait_until:
condition:
- lambda: !lambda return (!id(tft_is_valid));
- lambda: return (!id(tft_is_valid));
timeout: 1s
- script.execute: nextion_upload
- script.wait: nextion_upload