diff --git a/advanced/esphome/nspanel_esphome_addon_upload_tft.yaml b/advanced/esphome/nspanel_esphome_addon_upload_tft.yaml index 9bc9f44..fcb5b39 100644 --- a/advanced/esphome/nspanel_esphome_addon_upload_tft.yaml +++ b/advanced/esphome/nspanel_esphome_addon_upload_tft.yaml @@ -71,6 +71,8 @@ script: - lambda: |- static const char *const TAG = "script.upload_tft_new"; ESP_LOGVV(TAG, "Starting..."); + id(is_uploading_tft) = true; + nextion_status->execute(); auto delay_seconds_ = [](int seconds) { @@ -187,6 +189,7 @@ script: delay_seconds_(2); App.safe_reboot(); + id(is_uploading_tft) = false; ESP_LOGD(TAG, "Finished!"); - id: upload_tft @@ -197,6 +200,8 @@ script: - lambda: |- static const char *const TAG = "script.upload_tft"; ESP_LOGD(TAG, "Starting..."); + id(is_uploading_tft) = true; + char update_msg[128]; auto delay_seconds_ = [](int seconds) { @@ -226,9 +231,9 @@ script: auto send_nextion_command = [](const std::string &command) -> bool { static const char *const TAG = "script.upload_tft.send_nextion_command"; ESP_LOGD(TAG, "Sending: %s", command.c_str()); - id(tf_uart).write_str(command.c_str()); + tf_uart->write_str(command.c_str()); const uint8_t to_send[3] = {0xFF, 0xFF, 0xFF}; - id(tf_uart).write_array(to_send, sizeof(to_send)); + tf_uart->write_array(to_send, sizeof(to_send)); return true; }; @@ -285,15 +290,15 @@ script: start = millis(); - while ((timeout == 0 && id(tf_uart).available()) || millis() - start <= timeout) + while ((timeout == 0 && tf_uart->available()) || millis() - start <= timeout) { - if (!id(tf_uart).available()) + if (!tf_uart->available()) { App.feed_wdt(); continue; } - id(tf_uart).read_byte(&c); + tf_uart->read_byte(&c); if (c == 0xFF) { nr_of_ff_bytes++; @@ -424,7 +429,7 @@ script: for (int i = 0; i < range; i += 4096) { App.feed_wdt(); write_len = content_length_ < 4096 ? content_length_ : 4096; - id(tf_uart).write_array(&transfer_buffer_[i], write_len); + tf_uart->write_array(&transfer_buffer_[i], write_len); content_length_ -= write_len; ESP_LOGD(TAG, "Uploaded %0.1f %%, remaining %d bytes, heap: %d", 100.0 * (tft_size_ - content_length_) / tft_size_, @@ -543,19 +548,19 @@ script: // If it fails for any reason a power cycle of the display will be needed sprintf(command, "whmi-wris %d,%d,1", content_length_, update_baud_rate_); - ESP_LOGD(TAG, "Clear serial receive buffer: %d", id(tf_uart).available()); + ESP_LOGD(TAG, "Clear serial receive buffer: %d", tf_uart->available()); // Clear serial receive buffer uint8_t d; - while (id(tf_uart).available()) { - id(tf_uart).read_byte(&d); + while (tf_uart->available()) { + tf_uart->read_byte(&d); }; send_nextion_command(command); - if (update_baud_rate_ != id(tf_uart).get_baud_rate()) { + if (update_baud_rate_ != tf_uart->get_baud_rate()) { set_baud_rate_(update_baud_rate_); - //id(tf_uart).set_baud_rate(update_baud_rate_); - //id(tf_uart).setup(); + //tf_uart->set_baud_rate(update_baud_rate_); + //tf_uart->setup(); //delay_seconds_(2); } @@ -809,16 +814,16 @@ script: // Clear serial receive buffer uint8_t d; - while (id(tf_uart).available()) { - id(tf_uart).read_byte(&d); + while (tf_uart->available()) { + tf_uart->read_byte(&d); }; send_nextion_command(command); - if (update_baud_rate_ != id(tf_uart).get_baud_rate()) { + if (update_baud_rate_ != tf_uart->get_baud_rate()) { set_baud_rate_(update_baud_rate_); - //id(tf_uart).set_baud_rate(update_baud_rate_); - //id(tf_uart).setup(); + //tf_uart->set_baud_rate(update_baud_rate_); + //tf_uart->setup(); } std::string response; @@ -1019,6 +1024,7 @@ script: delay_seconds_(2); App.safe_reboot(); + id(is_uploading_tft) = false; ESP_LOGD(TAG, "Finished!"); select: diff --git a/advanced/esphome/nspanel_esphome_advanced.yaml b/advanced/esphome/nspanel_esphome_advanced.yaml index ec56498..fd7940e 100644 --- a/advanced/esphome/nspanel_esphome_advanced.yaml +++ b/advanced/esphome/nspanel_esphome_advanced.yaml @@ -59,14 +59,6 @@ sensor: accuracy_decimals: 0 update_interval: never - ##### WIFI Signal stregth - - name: ${device_name} RSSI - platform: wifi_signal - update_interval: 60s - on_value: - - script.execute: - id: refresh_wifi_icon - text_sensor: ##### ESPhome version used to compile the app ##### - name: ${device_name} ESPhome Version diff --git a/advanced/esphome/nspanel_esphome_core.yaml b/advanced/esphome/nspanel_esphome_core.yaml index 50a795f..db7f558 100644 --- a/advanced/esphome/nspanel_esphome_core.yaml +++ b/advanced/esphome/nspanel_esphome_core.yaml @@ -104,6 +104,12 @@ wifi: ap: ssid: "${device_name}" password: ${wifi_password} + on_connect: + then: + - script.execute: watchdog + on_disconnect: + then: + - script.execute: watchdog ##### OTA PASSWORD ##### ota: @@ -148,8 +154,9 @@ time: on_time: - seconds: 0 then: - - script.execute: - id: refresh_datetime + - script.execute: refresh_datetime + - script.execute: watchdog + on_time_sync: then: - logger.log: "System clock synchronized" @@ -160,6 +167,10 @@ time: api: id: api_server reboot_timeout: 0s + on_client_connected: + - script.execute: watchdog + on_client_disconnected: + - script.execute: watchdog services: ##### Service to send a command "printf" directly to the display ##### @@ -364,7 +375,6 @@ api: - lambda: |- ESP_LOGV("service.notification_show", "Starting"); - disp1->send_command_printf("is_notification=1"); disp1->goto_page("notification"); disp1->set_component_text_printf("notification.notifi_label", "%s", label.c_str()); @@ -373,13 +383,13 @@ api: notification_label->publish_state(label.c_str()); notification_text->publish_state(message.c_str()); timer_reset_all->execute(current_page->state.c_str()); + refresh_notification->execute(); notification_unread->turn_on(); if (notification_sound->state) buzzer->play("two short:d=4,o=5,b=100:16e6,16e6"); ##### Service to clear the notification ##### - service: notification_clear then: - - logger.log: "Service: notification_clear" - script.execute: notification_clear ##### Service to open information for settings-page(s) @@ -427,7 +437,6 @@ api: then: - lambda: |- if (current_page->state == "climate") detailed_entity->publish_state(entity); - - script.execute: id: set_climate current_temp: !lambda "return current_temp;" @@ -731,6 +740,18 @@ display: ##### START - GLOBALS CONFIGURATION ##### globals: + ##### Is uploading TFT ##### + - id: is_uploading_tft + type: bool + restore_value: false + initial_value: 'false' + + ##### Is blueprint updated ##### + - id: is_blueprint_updated + type: bool + restore_value: false + initial_value: 'false' + ##### Is boot sequence completed? ##### - id: setup_sequence_completed type: bool @@ -1027,8 +1048,7 @@ binary_sensor: id: api_status on_state: then: - - script.execute: - id: refresh_wifi_icon + - script.execute: watchdog ##### START - BUTTON CONFIGURATION ##### button: @@ -1268,8 +1288,8 @@ sensor: - lambda: |- timer_reset_all->execute("settings"); - - id: page_id - name: ${device_name} Page Id + - name: ${device_name} Page Id + id: page_id platform: nextion variable_name: dp precision: 0 @@ -1284,8 +1304,8 @@ sensor: } ##### Display mode (1 = EU, 2 = US, 3 = US Landscape) - - id: display_mode - name: ${device_name} Display mode + - name: ${device_name} Display mode + id: display_mode platform: nextion variable_name: display_mode precision: 0 @@ -1293,14 +1313,22 @@ sensor: entity_category: diagnostic ##### Charset (1 = International (original), 2 = CJK languages) - - id: display_charset - name: ${device_name} Display charset + - name: ${device_name} Display charset + id: display_charset platform: nextion variable_name: charset precision: 0 internal: true entity_category: diagnostic + ##### WIFI Signal stregth + - name: ${device_name} RSSI + id: wifi_rssi + platform: wifi_signal + internal: false + disabled_by_default: true + entity_category: diagnostic + ##### START - SWITCH CONFIGURATION ##### switch: @@ -1373,7 +1401,7 @@ switch: timeout: 20s - lambda: |- if (id(setup_sequence_completed)) { - nextion_init->publish_state(true); + nextion_init->publish_state(disp1->is_setup()); disp1->goto_page(wakeup_page_name->state.c_str()); } on_turn_off: @@ -1497,7 +1525,6 @@ text_sensor: std::string service = ""; // Send event to Home Assistant - auto ha_event = new esphome::api::CustomAPIDevice(); if (event == "short_click" or event == "long_click") { ha_button->execute(page.c_str(), component.c_str(), event.c_str()); } else if (event == "click" and page == "home" and component == "climate") { @@ -1505,6 +1532,7 @@ text_sensor: disp1->set_component_value("climate.embedded", id(is_embedded_thermostat) ? 1 : 0); disp1->goto_page("climate"); } else if (page == "light" or page == "climate" or page == "notification") { // Generic event + auto ha_event = new esphome::api::CustomAPIDevice(); ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint", { {"type", "generic"}, {"page", page}, @@ -1532,29 +1560,6 @@ text_sensor: } else service_call_alarm_control_panel->execute(entity.c_str(), key.c_str(), code_format.c_str(), ""); } - else if (page == "blank") page_blank->execute(); - else if (page == "boot") - { - // Contruct page boot - page_boot->execute(); - - // Detect TFT version - version_tft->update(); - check_versions->execute(); - - // Detect timeout - if (event == "timeout") - { - ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint", - { - {"type", "boot"}, - {"step", "timeout"}, - {"value", value} - }); - if (stof(value) >= 5) - disp1->goto_page(wakeup_page_name->state.c_str()); - } - } else if (page == "climate") { if (embedded==1) addon_climate_service_call->execute(key.c_str(), value.c_str()); @@ -1596,7 +1601,7 @@ text_sensor: - id: version_tft name: ${device_name} TFT version platform: nextion - component_name: boot.tft_version + component_name: tft_version entity_category: diagnostic internal: true on_value: @@ -1605,7 +1610,6 @@ text_sensor: ESP_LOGD(TAG, "TFT version: %s", version_tft->state.c_str()); if (current_page->state == "boot") { disp1->send_command_printf("tm_esphome.en=0"); - disp1->send_command_printf("tm_pageid.en=0"); page_boot->execute(); timer_reset_all->execute("boot"); } @@ -1731,30 +1735,17 @@ script: mode: restart then: - logger.log: "Exit reparse" - - uart.write: - id: tf_uart - data: "DRAKJHSUYDGBNCJHGJKSHBDN" - - uart.write: - id: tf_uart - data: [0xFF, 0xFF, 0xFF] - - uart.write: - id: tf_uart - data: "recmod=0" - - uart.write: - id: tf_uart - data: [0xFF, 0xFF, 0xFF] - - uart.write: - id: tf_uart - data: "recmod=0" - - uart.write: - id: tf_uart - data: [0xFF, 0xFF, 0xFF] - - uart.write: - id: tf_uart - data: "connect" - - uart.write: - id: tf_uart - data: [0xFF, 0xFF, 0xFF] + - uart.write: "DRAKJHSUYDGBNCJHGJKSHBDN" + - uart.write: [0xFF, 0xFF, 0xFF] + - uart.write: "connect" + - uart.write: [0xFF, 0xFF, 0xFF] + - uart.write: [0xFF, 0xFF] + - uart.write: "connect" + - uart.write: [0xFF, 0xFF, 0xFF] + - uart.write: "recmod=0" + - uart.write: [0xFF, 0xFF, 0xFF] + - uart.write: "recmod=0" + - uart.write: [0xFF, 0xFF, 0xFF] - id: global_settings mode: restart @@ -1836,6 +1827,7 @@ script: timer_reset_all->execute(wakeup_page_name->state.c_str()); - lambda: |- + id(is_blueprint_updated) = true; ESP_LOGV("script.global_settings", "Finished"); - id: ha_button @@ -1933,12 +1925,11 @@ script: mode: restart then: - lambda: |- - disp1->send_command_printf("is_notification=0"); if (current_page->state == "notification") disp1->goto_page("home"); notification_label->publish_state(""); notification_text->publish_state(""); notification_unread->turn_off(); - if (current_page->state == "home") disp1->hide_component("bt_notific"); + refresh_notification->execute(); - id: open_entity_settings_page mode: restart @@ -1987,7 +1978,6 @@ script: disp1->set_component_text_printf("esp_version", "ESP: ${version}"); // ESPHome version disp1->set_component_text_printf("framework", framework.c_str()); // ESPHome framework disp1->send_command_printf("tm_esphome.en=0"); - disp1->send_command_printf("tm_pageid.en=0"); - id: page_boot mode: restart @@ -2161,16 +2151,8 @@ script: - id: page_home mode: restart then: - - lambda: |- - static const char *const TAG = "script.page_home"; - if (current_page->state == "home") { // Is home page visible? - ESP_LOGV(TAG, "Update home page"); - refresh_relays->execute(); - refresh_wifi_icon->execute(); - disp1->send_command_printf("is_notification=%i", (notification_text->state.empty() and notification_label->state.empty()) ? 0 : 1); - set_component_color->execute("home.bt_notific", notification_unread->state ? id(home_notify_icon_color_unread) : id(home_notify_icon_color_normal)); - refresh_datetime->execute(); - } + - script.execute: refresh_relays + - script.execute: refresh_datetime - id: page_keyb_num mode: restart @@ -2280,6 +2262,21 @@ script: } else disp1->set_component_text_printf("home.meridiem", " "); disp1->set_component_text_printf("home.time", "%s", id(time_provider).now().strftime(time_format_str).c_str()); + - id: refresh_notification + mode: restart + then: + - lambda: |- + bool is_notification = (notification_text->state.empty() and notification_label->state.empty()); + disp1->send_command_printf("is_notification=%i", is_notification ? 0 : 1); + set_component_color->execute("home.bt_notific", notification_unread->state ? id(home_notify_icon_color_unread) : id(home_notify_icon_color_normal)); + if (current_page->state == "home") { + if (is_notification) { + disp1->show_component("bt_notific"); + } else { + disp1->hide_component("bt_notific"); + } + } + - id: refresh_relays mode: restart then: @@ -2297,30 +2294,17 @@ script: mode: restart then: - lambda: |- - static const char *const TAG = "script.refresh_wifi_icon"; - bool wifi_connected = wifi_component->is_connected(); - bool api_connected = api_server->is_connected(); - bool blueprint_connected = (not id(version_blueprint).empty()); - uint8_t api_val = (wifi_connected and api_connected and blueprint_connected) ? 1 : 0; - ESP_LOGV(TAG, "Wifi: %s", wifi_connected ? "Connected" : "DISCONNECTED"); - ESP_LOGV(TAG, "API: %s", api_connected ? "Connected" : "DISCONNECTED"); - ESP_LOGV(TAG, "Blueprint: %s", blueprint_connected ? id(version_blueprint).c_str() : "DISCONNECTED"); - ESP_LOGV(TAG, "Init: %s", nextion_init->state ? "True" : "False"); - ESP_LOGV(TAG, "Nextion api: %i", api_val); - if (nextion_init->state) { - // Update api value on Nextion - disp1->send_command_printf("api=%i", api_val); // Update Wi-Fi icon color - disp1->set_component_font_color("home.wifi_icon", (api_val > 0) ? 33808 : 63488); + disp1->set_component_font_color("home.wifi_icon", (id(is_blueprint_updated)) ? 33808 : 63488); // Update Wi-Fi icon disp1->set_component_text_printf("home.wifi_icon", "%s", - wifi_connected ? - (api_connected ? - (blueprint_connected ? "\uE5A8" : // mdi:wifi - All right! - "\uE7CF") : // mdi:home-assistant - Blueprint is out - "\uF256") : // mdi:api-off - "\uE5A9"); // mdi:wifi-off + wifi_component->is_connected() ? + (api_server->is_connected() ? + (id(is_blueprint_updated) ? "\uE5A8" : // mdi:wifi - All right! + "\uE7CF") : // mdi:home-assistant - Blueprint is out + "\uF256") : // mdi:api-off + "\uE5A9"); // mdi:wifi-off } - id: relay_settings @@ -2597,8 +2581,8 @@ script: disp1->send_command_printf("settings.dimslider.val=%i", id(display_dim_brightness_global)); disp1->send_command_printf("brightness_sleep=%i", int(display_sleep_brightness->state)); ESP_LOGD(TAG, "Report to Home Assistant"); - nextion_init->publish_state(true); - if (api_server->is_connected()) { + nextion_init->publish_state(disp1->is_setup()); + if (api_server->is_connected() and disp1->is_setup()) { auto ha_event = new esphome::api::CustomAPIDevice(); ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint", { @@ -2702,6 +2686,7 @@ script: timer_sleep->stop(); update_alarm_icon->stop(); update_climate_icon->stop(); + watchdog->stop(); ESP_LOGD(TAG, "Finished"); ###### Timers ###### @@ -2917,3 +2902,95 @@ script: disp1->set_component_font_color(component.c_str(), 1530); // cyan break; } + + - id: watchdog + mode: restart + then: + - lambda: |- + static const char *const TAG = "script.watchdog"; + ESP_LOGV(TAG, "Starting"); + if (id(is_uploading_tft)) { + ESP_LOGW(TAG, "TFT upload in progress"); + } else { + // report Wi-Fi status + bool wifi_connected = wifi_component->is_connected(); + if (wifi_connected) + ESP_LOGD(TAG, "Wi-Fi: %.0fdB", wifi_rssi->state); + else + ESP_LOGW(TAG, "Wi-Fi: DISCONNECTED"); + + // report API status + bool api_connected = api_server->is_connected(); + if (api_connected) + ESP_LOGD(TAG, "API: Connected"); + else + ESP_LOGW(TAG, "API: DISCONNECTED"); + + // Report blueprint version + id(is_blueprint_updated) = id(is_blueprint_updated) and wifi_connected and api_connected and (not id(version_blueprint).empty()); + if (id(is_blueprint_updated)) + ESP_LOGD(TAG, "Blueprint: %s", id(version_blueprint).c_str()); + else + ESP_LOGW(TAG, "Blueprint: %s", (wifi_connected and api_connected) ? "Pending" : "DISCONNECTED"); + + refresh_wifi_icon->execute(); + + // Report ESPHome + ESP_LOGD(TAG, "ESPHome:"); + ESP_LOGD(TAG, " Version: ${version}"); + // Report framework + #ifdef ARDUINO + ESP_LOGD(TAG, " Framework: arduino"); + #elif defined(USE_ESP_IDF) + ESP_LOGD(TAG, " Framework: esp-idf"); + #endif + + // Report UART + ESP_LOGD(TAG, "UART queue: %d", tf_uart->available()); + + // Report Nextion status + nextion_init->publish_state(nextion_init->state and disp1->is_setup()); + ESP_LOGD(TAG, "Nextion:"); + if (disp1->is_setup()) + ESP_LOGD(TAG, " Is setup: True"); + else if (disp1->is_detected()) + ESP_LOGW(TAG, " Is detected: %s", disp1->is_detected() ? "True" : "False"); + if (nextion_init->state) + ESP_LOGD(TAG, " Init: True"); + else + ESP_LOGW(TAG, " Init: False"); + if (version_tft->state.empty()) + ESP_LOGW(TAG, " TFT: UNKNOWN"); + else + ESP_LOGD(TAG, " TFT: %s", version_tft->state.c_str()); + // Update api value on Nextion + disp1->send_command_printf("api=%i", id(is_blueprint_updated) ? 1 : 0); + + if (!wifi_connected) { + ESP_LOGD(TAG, "Retry Wi-Fi connection"); + wifi_component->retry_connect(); + } + if (api_connected) { + if (not id(is_blueprint_updated)) { + ESP_LOGD(TAG, "Requesting blueprint settings"); + auto ha_event = new esphome::api::CustomAPIDevice(); + ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint", + { + {"type", "boot"}, + {"step", "timeout"} + }); + } + } else { + id(is_blueprint_updated) = false; + if (current_page->state != "blank" and + current_page->state != "boot" and + current_page->state != "home" and + current_page->state != "screensaver" and + current_page->state != "settings" and + current_page->state != "qrcode") { + ESP_LOGD(TAG, "Fallback to page Home"); + disp1->goto_page("home"); + } + } + } + ESP_LOGV(TAG, "Finished"); diff --git a/advanced/hmi/nspanel_blank.HMI b/advanced/hmi/nspanel_blank.HMI index b6252cd..39fa315 100644 Binary files a/advanced/hmi/nspanel_blank.HMI and b/advanced/hmi/nspanel_blank.HMI differ diff --git a/advanced/hmi/nspanel_blank_code/Program.s.txt b/advanced/hmi/nspanel_blank_code/Program.s.txt index 47bc91e..df4824f 100644 --- a/advanced/hmi/nspanel_blank_code/Program.s.txt +++ b/advanced/hmi/nspanel_blank_code/Program.s.txt @@ -1,5 +1,7 @@ Program.s //The following code is only run once when power on, and is generally used for global variable definition and power on initialization data + int sys0=0 + int display_mode=4 // 1 = EU, 2 = US, 3 = US landscape, 4 = blank dim=100//Configure backlight recmod=0//Serial data parsing mode:0-Passive mode;1-Active mode printh 00 00 00 ff ff ff 88 ff ff ff//Output power on information to serial port diff --git a/advanced/hmi/nspanel_blank_code/blank.txt b/advanced/hmi/nspanel_blank_code/blank.txt index 332d75a..16113ef 100644 --- a/advanced/hmi/nspanel_blank_code/blank.txt +++ b/advanced/hmi/nspanel_blank_code/blank.txt @@ -13,19 +13,7 @@ Page blank Events Preinitialize Event sendme - printh 92 - prints "currentpage",0 - printh 00 - prints "blank",0 - printh 00 - printh FF FF FF dim=100 - printh 92 - prints "nspanelevent",0 - printh 00 - prints "{\"page\": \"blank\", \"component\": \"currentpage\", \"value\": \"pagechange\", \"version\": \"2023.11.1\"}",0 - printh 00 - printh FF FF FF covx baud,baud_rate.txt,0,0 baud_rate.txt+=" bps" @@ -37,12 +25,18 @@ Page blank dim=100 tm0.en=1 -Variable (string) nspanelevent +Variable (int32) counter + Attributes + ID : 9 + Scope: local + Value: 0 + +Variable (string) aux1 Attributes ID : 10 Scope : local Text : - Max. Text Size: 150 + Max. Text Size: 10 Text file_name Attributes @@ -89,7 +83,7 @@ Text tft_version Dragging : 0 Send Component ID : on press and release Associated Keyboard: none - Text : TFT: v2023.12.1 + Text : TFT: v2023.12.2 Max. Text Size : 20 Events @@ -190,30 +184,30 @@ Timer tm_esphome Events Timer Event - if(baud==115200) + counter.val++ + if(counter.val>60) { - bauds=921600 - }else + rest + } + sendme + printh 91 + prints "display_mode",0 + printh 00 + prints display_mode,0 + printh FF FF FF + printh 92 + prints "tft_version",0 + printh 00 + prints tft_version.txt,0 + printh 00 + printh FF FF FF + covx counter.val,aux1.txt,0,0 + esp_version.txt="ESP: Retry #"+aux1.txt + sys0=counter.val%10 + if(sys0==0) { - bauds=115200 + baud=115200 } covx baud,baud_rate.txt,0,0 baud_rate.txt+=" bps" -Timer tm_pageid - Attributes - ID : 9 - Scope : local - Period (ms): 2500 - Enabled : yes - - Events - Timer Event - nspanelevent.txt="{\"page\": \"blank\", \"event\": \"pagechanged\", \"version\": \""+tft_version.txt+"\"}" - printh 92 - prints "localevent",0 - printh 00 - prints nspanelevent.txt,0 - printh 00 - printh FF FF FF - diff --git a/advanced/hmi/nspanel_eu.HMI b/advanced/hmi/nspanel_eu.HMI index aa595e9..d3309d2 100644 Binary files a/advanced/hmi/nspanel_eu.HMI and b/advanced/hmi/nspanel_eu.HMI differ diff --git a/advanced/hmi/nspanel_eu_code/Program.s.txt b/advanced/hmi/nspanel_eu_code/Program.s.txt index 88b6588..0558b85 100644 --- a/advanced/hmi/nspanel_eu_code/Program.s.txt +++ b/advanced/hmi/nspanel_eu_code/Program.s.txt @@ -9,7 +9,7 @@ Program.s int api=0 // 0 = disconnected from HA, 1 = connected to HA int is_entities=0,is_qrcode=0,is_notification=0 int brightness=100,brightness_dim=40,brightness_sleep=0 - int display_mode=1 // 1 = EU, 2 = US, 3 = US landscape + int display_mode=1 // 1 = EU, 2 = US, 3 = US landscape, 4 = blank int charset=2 // 1 = International (original), 2 = CJK //bauds=115200//Configure baudrate recmod=0//Serial data parsing mode:0-Passive mode;1-Active mode diff --git a/advanced/hmi/nspanel_eu_code/boot.txt b/advanced/hmi/nspanel_eu_code/boot.txt index 8fe509d..eac39c0 100644 --- a/advanced/hmi/nspanel_eu_code/boot.txt +++ b/advanced/hmi/nspanel_eu_code/boot.txt @@ -13,53 +13,26 @@ Page boot Events Preinitialize Event sendme - dim=0 + dim=100 + vis bt_reboot,0 + sendme + dim=100 vis bt_reboot,0 covx baud,baud_rate.txt,0,0 baud_rate.txt+=" bps" - covx display_mode,aux2.txt,0,0 - covx charset,aux3.txt,0,0 - nspanelevent.txt="{\"page\": \"boot\", \"event\": \"pagechanged\", \"version\": \""+tft_version.txt+"\", \"display_mode\": \""+aux2.txt+"\", \"charset\": \""+aux3.txt+"\"}" - printh 92 - prints "localevent",0 - printh 00 - prints nspanelevent.txt,0 - printh 00 - printh FF FF FF Page Exit Event dim=0 Variable (int32) counter Attributes - ID : 12 + ID : 11 Scope: local Value: 0 Variable (string) aux1 Attributes - ID : 13 - Scope : local - Text : - Max. Text Size: 10 - -Variable (string) nspanelevent - Attributes - ID : 14 - Scope : local - Text : - Max. Text Size: 150 - -Variable (string) aux2 - Attributes - ID : 15 - Scope : local - Text : - Max. Text Size: 10 - -Variable (string) aux3 - Attributes - ID : 21 + ID : 12 Scope : local Text : Max. Text Size: 10 @@ -131,7 +104,7 @@ Text tft_version Dragging : 0 Send Component ID : on press and release Associated Keyboard: none - Text : 4.2dev.2 + Text : 4.2dev.3 Max. Text Size : 9 Text esph_version @@ -156,7 +129,7 @@ Text bluep_version Text baud_rate Attributes - ID : 18 + ID : 14 Scope : local Dragging : 0 Send Component ID : on press and release @@ -166,7 +139,7 @@ Text baud_rate Text framework Attributes - ID : 20 + ID : 15 Scope : local Dragging : 0 Send Component ID : on press and release @@ -184,85 +157,44 @@ Dual-state Button bt_reboot Text : Reboot Max. Text Size : 6 -Timer timer - Attributes - ID : 11 - Scope : local - Period (ms): 65534 - Enabled : yes - - Events - Timer Event - counter.val++ - covx counter.val,aux1.txt,0,0 - covx display_mode,aux2.txt,0,0 - nspanelevent.txt="{\"page\": \"boot\", \"event\": \"timeout\", \"value\": "+aux1.txt+", \"version\": \""+tft_version.txt+"\", \"display_mode\": \""+aux2.txt+"\"}" - bluep_version.txt="Retry: "+aux1.txt - printh 92 - prints "nspanelevent",0 - printh 00 - prints nspanelevent.txt,0 - printh 00 - printh FF FF FF - -Timer wakeup_timer - Attributes - ID : 16 - Scope : local - Period (ms): 50 - Enabled : yes - - Events - Timer Event - if(dim<100) - { - dimdelta=100-dim - dimdelta/=25 - if(dimdelta<1) - { - dimdelta=1 - } - dim+=dimdelta - }else - { - wakeup_timer.en=0 - } - Timer tm_esphome Attributes - ID : 17 + ID : 13 Scope : local Period (ms): 30000 Enabled : yes Events Timer Event - if(baud==115200) + counter.val++ + if(counter.val>60) { - bauds=921600 - }else + rest + } + sendme + printh 91 + prints "display_mode",0 + printh 00 + prints display_mode,0 + printh FF FF FF + printh 91 + prints "charset",0 + printh 00 + prints charset,0 + printh FF FF FF + printh 92 + prints "tft_version",0 + printh 00 + prints tft_version.txt,0 + printh 00 + printh FF FF FF + covx counter.val,aux1.txt,0,0 + esph_version.txt="Retry #"+aux1.txt + sys0=counter.val%10 + if(sys0==0) { - bauds=115200 + baud=115200 } covx baud,baud_rate.txt,0,0 baud_rate.txt+=" bps" -Timer tm_pageid - Attributes - ID : 19 - Scope : local - Period (ms): 2500 - Enabled : yes - - Events - Timer Event - covx display_mode,aux2.txt,0,0 - covx charset,aux3.txt,0,0 - nspanelevent.txt="{\"page\": \"boot\", \"event\": \"pagechanged\", \"version\": \""+tft_version.txt+"\", \"display_mode\": \""+aux2.txt+"\", \"charset\": \""+aux3.txt+"\"}" - printh 92 - prints "localevent",0 - printh 00 - prints nspanelevent.txt,0 - printh 00 - printh FF FF FF - diff --git a/advanced/hmi/nspanel_us.HMI b/advanced/hmi/nspanel_us.HMI index ac31742..432b915 100644 Binary files a/advanced/hmi/nspanel_us.HMI and b/advanced/hmi/nspanel_us.HMI differ diff --git a/advanced/hmi/nspanel_us_code/Program.s.txt b/advanced/hmi/nspanel_us_code/Program.s.txt index c21ddc1..f0e5999 100644 --- a/advanced/hmi/nspanel_us_code/Program.s.txt +++ b/advanced/hmi/nspanel_us_code/Program.s.txt @@ -9,7 +9,7 @@ Program.s int api=0 // 0 = disconnected from HA, 1 = connected to HA int is_entities=0,is_qrcode=0,is_notification=0 int brightness=100,brightness_dim=40,brightness_sleep=0 - int display_mode=2 // 1 = EU, 2 = US, 3 = US landscape + int display_mode=2 // 1 = EU, 2 = US, 3 = US landscape, 4 = blank int charset=1 // 1 = International (original), 2 = CJK //bauds=115200//Configure baudrate recmod=0//Serial data parsing mode:0-Passive mode;1-Active mode diff --git a/advanced/hmi/nspanel_us_code/boot.txt b/advanced/hmi/nspanel_us_code/boot.txt index 8fe509d..c94bf2f 100644 --- a/advanced/hmi/nspanel_us_code/boot.txt +++ b/advanced/hmi/nspanel_us_code/boot.txt @@ -13,53 +13,23 @@ Page boot Events Preinitialize Event sendme - dim=0 + dim=100 vis bt_reboot,0 covx baud,baud_rate.txt,0,0 baud_rate.txt+=" bps" - covx display_mode,aux2.txt,0,0 - covx charset,aux3.txt,0,0 - nspanelevent.txt="{\"page\": \"boot\", \"event\": \"pagechanged\", \"version\": \""+tft_version.txt+"\", \"display_mode\": \""+aux2.txt+"\", \"charset\": \""+aux3.txt+"\"}" - printh 92 - prints "localevent",0 - printh 00 - prints nspanelevent.txt,0 - printh 00 - printh FF FF FF Page Exit Event dim=0 Variable (int32) counter Attributes - ID : 12 + ID : 11 Scope: local Value: 0 Variable (string) aux1 Attributes - ID : 13 - Scope : local - Text : - Max. Text Size: 10 - -Variable (string) nspanelevent - Attributes - ID : 14 - Scope : local - Text : - Max. Text Size: 150 - -Variable (string) aux2 - Attributes - ID : 15 - Scope : local - Text : - Max. Text Size: 10 - -Variable (string) aux3 - Attributes - ID : 21 + ID : 12 Scope : local Text : Max. Text Size: 10 @@ -131,7 +101,7 @@ Text tft_version Dragging : 0 Send Component ID : on press and release Associated Keyboard: none - Text : 4.2dev.2 + Text : 4.2dev.3 Max. Text Size : 9 Text esph_version @@ -156,7 +126,7 @@ Text bluep_version Text baud_rate Attributes - ID : 18 + ID : 14 Scope : local Dragging : 0 Send Component ID : on press and release @@ -166,7 +136,7 @@ Text baud_rate Text framework Attributes - ID : 20 + ID : 15 Scope : local Dragging : 0 Send Component ID : on press and release @@ -184,85 +154,44 @@ Dual-state Button bt_reboot Text : Reboot Max. Text Size : 6 -Timer timer - Attributes - ID : 11 - Scope : local - Period (ms): 65534 - Enabled : yes - - Events - Timer Event - counter.val++ - covx counter.val,aux1.txt,0,0 - covx display_mode,aux2.txt,0,0 - nspanelevent.txt="{\"page\": \"boot\", \"event\": \"timeout\", \"value\": "+aux1.txt+", \"version\": \""+tft_version.txt+"\", \"display_mode\": \""+aux2.txt+"\"}" - bluep_version.txt="Retry: "+aux1.txt - printh 92 - prints "nspanelevent",0 - printh 00 - prints nspanelevent.txt,0 - printh 00 - printh FF FF FF - -Timer wakeup_timer - Attributes - ID : 16 - Scope : local - Period (ms): 50 - Enabled : yes - - Events - Timer Event - if(dim<100) - { - dimdelta=100-dim - dimdelta/=25 - if(dimdelta<1) - { - dimdelta=1 - } - dim+=dimdelta - }else - { - wakeup_timer.en=0 - } - Timer tm_esphome Attributes - ID : 17 + ID : 13 Scope : local Period (ms): 30000 Enabled : yes Events Timer Event - if(baud==115200) + counter.val++ + if(counter.val>60) { - bauds=921600 - }else + rest + } + sendme + printh 91 + prints "display_mode",0 + printh 00 + prints display_mode,0 + printh FF FF FF + printh 91 + prints "charset",0 + printh 00 + prints charset,0 + printh FF FF FF + printh 92 + prints "tft_version",0 + printh 00 + prints tft_version.txt,0 + printh 00 + printh FF FF FF + covx counter.val,aux1.txt,0,0 + esph_version.txt="Retry #"+aux1.txt + sys0=counter.val%10 + if(sys0==0) { - bauds=115200 + baud=115200 } covx baud,baud_rate.txt,0,0 baud_rate.txt+=" bps" -Timer tm_pageid - Attributes - ID : 19 - Scope : local - Period (ms): 2500 - Enabled : yes - - Events - Timer Event - covx display_mode,aux2.txt,0,0 - covx charset,aux3.txt,0,0 - nspanelevent.txt="{\"page\": \"boot\", \"event\": \"pagechanged\", \"version\": \""+tft_version.txt+"\", \"display_mode\": \""+aux2.txt+"\", \"charset\": \""+aux3.txt+"\"}" - printh 92 - prints "localevent",0 - printh 00 - prints nspanelevent.txt,0 - printh 00 - printh FF FF FF - diff --git a/nspanel_blank.tft b/nspanel_blank.tft index 689e1ce..ec300cc 100644 Binary files a/nspanel_blank.tft and b/nspanel_blank.tft differ