diff --git a/nspanel_blueprint.yaml b/nspanel_blueprint.yaml index a5dd6be..0f14425 100644 --- a/nspanel_blueprint.yaml +++ b/nspanel_blueprint.yaml @@ -33,7 +33,7 @@ blueprint: 🎉 Roadmap can be found here: [Roadmap](https://github.com/Blackymas/NSPanel_HA_Blueprint/labels/roadmap) - ℹ️ Version: v4.0 + ℹ️ Version: v4.0dev source_url: https://github.com/Blackymas/NSPanel_HA_Blueprint/blob/main/nspanel_blueprint.yaml domain: automation @@ -154,7 +154,6 @@ blueprint: - label: 'QR code page' value: '17' - ##### WEATHER - Page Home / Weather 01-04 ##### ##### PLACEHOLDER ###################################################################### placeholder01: @@ -3479,7 +3478,7 @@ trigger_variables: variables: ##### GENERAL ##### - blueprint_version: '4.0' + blueprint_version: '4.0dev' date_format_temp: !input 'date_format' #Avoid breaking change for existing users with legacy type format date_format: > @@ -6203,22 +6202,6 @@ trigger: - unavailable id: climate_button09_state - ##### Trigger - Notifications ################################################################################################################# - - ##### Notification Text - Trigger 'notification_text_state' ##### - - platform: event - event_type: state_changed - event_data: - entity_id: '{{ notification_text }}' - id: notification_text_state - - ##### Notification Text - Trigger 'notification_text_state' ##### - - platform: event - event_type: state_changed - event_data: - entity_id: '{{ notification_unread }}' - id: notification_unread_state - ##### Trigger - Hardware buttons ################################################################################################################# ##### Left Button - State 'left_button_state' ##### @@ -6403,6 +6386,10 @@ action: - &variables-home_buttons variables: + bt_notific: + icon: !input 'home_button04_icon' #E1ED + color_normal: !input 'home_button04_icon_color01' + color_unread: !input 'home_button04_icon_color02' bt_entities: enabled: !input 'entitypages_enabled' icon: !input 'home_button06_icon' #EDCF @@ -6426,6 +6413,14 @@ action: - service: '{{ nextion.command.page_home_settings }}' data: + notification_icon: > + {{ + all_icons[bt_notific.icon.split(":")[1]] | default(bt_notific.icon + if bt_notific.icon is string + else all_icons["email"]) + }} + notification_icon_color_normal: '{{ [ bt_notific.color_normal ] if is_number(bt_notific.color_normal) else bt_notific.color_normal }}' + notification_icon_color_unread: '{{ [ bt_notific.color_unread ] if is_number(bt_notific.color_unread) else bt_notific.color_unread }}' qrcode: '{{ bt_qrcode.enabled }}' qrcode_icon: > {{ @@ -6433,15 +6428,7 @@ action: if bt_qrcode.icon is string else all_icons["format-list-bulleted-square"]) }} - qrcode_icon_color: > - {{ - bt_qrcode.color_rgb - if is_number(bt_qrcode.color_rgb) - else - ((bt_qrcode.color_rgb[0] //(2**3)) *(2**11))+ - ((bt_qrcode.color_rgb[1] //(2**2)) *(2**5))+ - (bt_qrcode.color_rgb[2] //(2**3)) - }} + qrcode_icon_color: '{{ [ bt_qrcode.color_rgb ] if is_number(bt_qrcode.color_rgb) else bt_qrcode.color_rgb }}' entities_pages: '{{ bt_entities.enabled }}' entities_pages_icon: > {{ @@ -6449,15 +6436,7 @@ action: if bt_entities.icon is string else all_icons["format-list-bulleted-square"]) }} - entities_pages_icon_color: > - {{ - bt_entities.color_rgb - if is_number(bt_entities.color_rgb) - else - ((bt_entities.color_rgb[0] //(2**3)) *(2**11))+ - ((bt_entities.color_rgb[1] //(2**2)) *(2**5))+ - (bt_entities.color_rgb[2] //(2**3)) - }} + entities_pages_icon_color: '{{ [ bt_entities.color_rgb ] if is_number(bt_entities.color_rgb) else bt_entities.color_rgb }}' alarm_state: > {{ states(alarm) | default("") @@ -6984,60 +6963,6 @@ action: }} continue_on_error: true - ##### Set notify icon ##### - - &refresh-page_home-notifications_icon - if: '{{ true }}' - then: - - variables: - notification_unread_state: '{{ states(notification_unread) | default("unavailable") if notification_unread is string else "unavailable" }}' - - condition: '{{ notification_unread_state in ["on", "off"] }}' - - variables: - bt_notific: - icon: !input 'home_button04_icon' #E1ED - color_rgb: - "on": !input 'home_button04_icon_color01' - "off": !input 'home_button04_icon_color02' - notification_text_state: '{{ states(notification_text) | default(None) if notification_text is string else None }}' - set_button04_icon: > - {{ - all_icons[bt_notific.icon.split(":")[1]] | default(bt_notific.icon if bt_notific.icon is string else all_icons.unknown) - if notification_unread_state == "on" and notification_text_state | length > 0 - else all_icons.blank - }} - set_button04_icon_font: > - {{ - ( [ bt_notific.color_rgb[notification_unread_state] ] if is_number(bt_notific.color_rgb[notification_unread_state]) else bt_notific.color_rgb[notification_unread_state] ) - if notification_unread_state in ["on", "off"] and notification_text_state | length > 0 - else nextion.color.grey_light - }} - ##### SET ICON Font - Notify ##### - - *delay-default - - service: '{{ nextion.command.text_printf }}' - data: - component: home.bt_notific - message: '{{ set_button04_icon }}' - continue_on_error: true - - ##### SET ICON Font Color - Notify ##### - - *delay-default - - service: '{{ nextion.command.set_component_color }}' - data: - component: home.bt_notific - foreground: '{{ set_button04_icon_font }}' - background: [] - continue_on_error: true - - ##### Show/Hide notification button ##### - - *delay-default - - service: '{{ nextion.command.printf }}' - data: - cmd: is_notification={{ 1 if notification_unread_state == "on" and notification_text_state | length > 0 and set_button04_icon != all_icons.blank else 0 }} - continue_on_error: true - #- service: '{{ nextion.command.show if notification_unread_state == "on" and notification_text_state | length > 0 and set_button04_icon != all_icons.blank else nextion.command.hide }}' - # data: - # component: home.bt_notific - # continue_on_error: true - ## BUTTON PAGES 01 - 04 ## - alias: Button pages conditions: '{{ nspanel_event.page in page.buttonpages }}' @@ -8480,24 +8405,6 @@ action: - *delay-default else: *forecast_unavailable - ## PAGE NOTIFICATION ## - - alias: Notification page - conditions: - - '{{ nspanel_event.page == page.notification }}' - - '{{ confirmation_message is string and states(confirmation_message) | default("unavailable") != "on" }}' - sequence: - - service: '{{ nextion.command.text_printf }}' - data: - component: notification.notifi_text01 - message: '{{ states(notification_text) | default(mui[language].unavailable) if notification_text is string else mui[language].unavailable }}' - continue_on_error: true - - *delay-default - - service: '{{ nextion.command.text_printf }}' - data: - component: notification.notifi_label - message: '{{ states(notification_label) | default(mui[language].unavailable) if notification_label is string else mui[language].unavailable }}' - continue_on_error: true - ##### Button click ##### - alias: Button click conditions: @@ -9106,18 +9013,6 @@ action: sequence: - *display-home_page_status_bar - #### SHOW BUTTON - notification #### - - alias: Show button - Notification - conditions: - - condition: trigger - id: - - notification_text_state - - notification_unread_state - - '{{ page.current == page.home }}' - - '{{ trigger.event.data.new_state.state not in ["unavailable", "unknown", "", None] }}' - sequence: - - *refresh-page_home-notifications_icon - ##### HW BUTTON - state ##### - alias: Hardware button - State conditions: diff --git a/nspanel_esphome.yaml b/nspanel_esphome.yaml index 5362672..f79c4d8 100644 --- a/nspanel_esphome.yaml +++ b/nspanel_esphome.yaml @@ -10,7 +10,7 @@ substitutions: notification_line_length_limit: "39" ##### DON'T CHANGE THIS ##### - version: "4.0" + version: "4.0dev" ############################# ##### WIFI SETUP ##### @@ -238,32 +238,10 @@ api: id(disp1).send_command_printf("page notification"); id(disp1).set_component_text_printf("notification.notifi_label", "%s", label.c_str()); - int maxChars = ${notification_line_length_limit}; - int startPos = 0; - int endPos = 0; - std::string wrappedText = ""; - while (startPos < text.length()) { - while (text[startPos] == ' ' and startPos < text.length()) { startPos++; } - int endPos = startPos + maxChars; - if (endPos >= text.length()) endPos = text.length(); - else - { - while (endPos > startPos && text[endPos] != ' ') { endPos--; } - if (endPos == startPos) endPos = startPos + maxChars; // Handle case of long word - } - wrappedText += text.substr(startPos, endPos-startPos); - if (endPos < text.length()) - { - while (text[endPos] == ' ') { endPos--; } - if (endPos >= startPos) wrappedText += "\\r"; - } - startPos = endPos + 1; // Skip the space - while (text[startPos] == ' ' and startPos < text.length()) { startPos++; } - } - ESP_LOGV("service.notification_show", "text (new): %s", wrappedText.c_str()); - id(disp1).set_component_text_printf("notification.notifi_text01", "%s", wrappedText.c_str()); + id(display_wrapped_text).execute("notification.notifi_text01", text.c_str(), id(display_mode) == 2 ? 23 : 32); + id(notification_label).publish_state(label.c_str()); - id(notification_text).publish_state(wrappedText.c_str()); + id(notification_text).publish_state(text.c_str()); - switch.turn_on: notification_unread - if: condition: @@ -460,8 +438,6 @@ api: // Logs - Begin ESP_LOGV("service.global_settings", "Starting"); ESP_LOGD("service.global_settings", "Blueprint version: %s", blueprint_version.c_str()); - ESP_LOGD("service.global_settings", "ESPHome version: ${version}"); - if (blueprint_version != "${version}") ESP_LOGW("service.global_settings", "Blueprint and ESPHome versions mismatch!"); ESP_LOGV("service.global_settings", "relay1_local_control: %i", (relay1_local_control) ? 1 : 0); ESP_LOGV("service.global_settings", "relay1_icon: %s", relay1_icon.c_str()); ESP_LOGV("service.global_settings", "relay1_icon_color: %i", relay1_icon_color); @@ -474,6 +450,10 @@ api: ESP_LOGV("service.global_settings", "embedded_climate: %i", (embedded_climate) ? 1 : 0); ESP_LOGV("service.global_settings", "wakeup_page: %i", wakeup_page); + // Blueprint version + id(version_blueprint) = blueprint_version; + id(check_versions).execute(); + // Relays id(relay1_local).publish_state(relay1_local_control); id(relay2_local).publish_state(relay2_local_control); @@ -544,36 +524,46 @@ api: #### Service to populate the page Home ##### - service: page_home_settings variables: + notification_icon: string + notification_icon_color_normal: int[] + notification_icon_color_unread: int[] qrcode: bool qrcode_icon: string - qrcode_icon_color: int + qrcode_icon_color: int[] entities_pages: bool entities_pages_icon: string - entities_pages_icon_color: int + entities_pages_icon_color: int[] alarm_state: string then: - lambda: |- // Logs - Begin ESP_LOGV("service.page_home_settings", "Starting"); + ESP_LOGV("service.page_home_settings", "notification_icon: %s", notification_icon.c_str()); ESP_LOGV("service.page_home_settings", "qrcode: %i", (qrcode) ? 1 : 0); ESP_LOGV("service.page_home_settings", "qrcode_icon: %s", qrcode_icon.c_str()); - ESP_LOGV("service.page_home_settings", "qrcode_icon_color: %i", qrcode_icon_color); ESP_LOGV("service.page_home_settings", "entities_pages: %i", (entities_pages) ? 1 : 0); ESP_LOGV("service.page_home_settings", "entities_pages_icon: %s", entities_pages_icon.c_str()); - ESP_LOGV("service.page_home_settings", "entities_pages_icon_color: %i", entities_pages_icon_color); ESP_LOGV("service.page_home_settings", "alarm_state: %s", alarm_state.c_str()); + // Notification button + ESP_LOGV("service.page_home_settings", "Notification button - Start"); + id(disp1).send_command_printf("is_notification=%i", (id(notification_text).state.empty() and id(notification_label).state.empty()) ? 0 : 1); + id(disp1).set_component_text_printf("home.bt_notific", "%s", notification_icon.c_str()); + id(set_component_color).execute("home.bt_notific", id(notification_unread).state ? notification_icon_color_unread : notification_icon_color_normal, {}); + id(home_notify_icon_color_normal) = notification_icon_color_normal; + id(home_notify_icon_color_unread) = notification_icon_color_unread; + // QRCode button ESP_LOGV("service.page_home_settings", "QRcode button - Start"); id(disp1).send_command_printf("is_qrcode=%i", (qrcode) ? 1 : 0); id(disp1).set_component_text_printf("home.bt_qrcode", "%s", qrcode_icon.c_str()); - id(disp1).set_component_font_color("home.bt_qrcode", qrcode_icon_color); + id(set_component_color).execute("home.bt_qrcode", qrcode_icon_color, {}); // Entities pages button ESP_LOGV("service.page_home_settings", "Entities pages button - Start"); id(disp1).send_command_printf("is_entities=%i", (entities_pages) ? 1 : 0); id(disp1).set_component_text_printf("home.bt_entities", "%s", entities_pages_icon.c_str()); - id(disp1).set_component_font_color("home.bt_entities", entities_pages_icon_color); + id(set_component_color).execute("home.bt_entities", entities_pages_icon_color, {}); // Alarm button ESP_LOGV("service.page_home_settings", "Alarm button - Start"); @@ -718,6 +708,12 @@ api: ##### START - GLOBALS CONFIGURATION ##### globals: + ##### Display mode (1 = EU, 2 = US, 3 = US Landscape) + - id: display_mode + type: int + restore_value: true + initial_value: '0' + ##### Save Display Brightness for NSPanel reboot ##### - id: display_brightness_global type: int @@ -777,12 +773,32 @@ globals: restore_value: true initial_value: '65535' + - id: home_notify_icon_color_normal + type: std::vector + restore_value: false + #initial_value: '52857' + + - id: home_notify_icon_color_unread + type: std::vector + restore_value: false + #initial_value: '63488' + ##### Wakeup page ID ##### - id: wakeup_page_id type: int restore_value: true initial_value: '0' + ##### Versions ##### + - id: version_blueprint + type: std::string + restore_value: false + initial_value: '' + - id: version_tft + type: std::string + restore_value: false + initial_value: '' + ##### START - BINARY SENSOR CONFIGURATION ##### binary_sensor: @@ -1144,20 +1160,43 @@ text_sensor: id(disp1).set_component_text_printf("icon_bright", "%s", "\uE0DD"); //mdi:brightness-5 id(disp1).set_component_text_printf("icon_dim", "%s", "\uE0DE"); //mdi:brightness-5 } + else if (page=="notification") + { + if (not id(confirmation_message).state) + { + id(disp1).set_component_text_printf("notification.notifi_label", "%s", id(notification_label).state.c_str()); + id(display_wrapped_text).execute("notification.notifi_text01", id(notification_text).state.c_str(), id(display_mode) == 2 ? 23 : 32); + } + } } - else if (page=="boot" and component=="timeout") + if (page=="boot") { - ESP_LOGV("text_sensor.nspanelevent", "Trigger boot timeout event"); - ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint", + // Detect display mode - Need review + std::string display_mode_str = doc["display_mode"]; + ESP_LOGV("text_sensor.nspanelevent", "display_mode: %s", display_mode_str.c_str()); + float display_mode_float = stof(display_mode_str); + if (display_mode_float > 0) id(display_mode) = int(display_mode_float); + + // Detect TFT version + std::string version_tmp = doc["version"]; + id(version_tft) = version_tmp; + id(check_versions).execute(); + + // Detect timeout + if (component=="timeout") { - {"type", "boot"}, - {"step", "timeout"}, - {"value", value} - }); - if (stof(value) >= 5) - { - ESP_LOGV("text_sensor.nspanelevent", "Jump to wakeup page: %i", id(wakeup_page_id)); - id(disp1).send_command_printf("page %i", id(wakeup_page_id)); + ESP_LOGV("text_sensor.nspanelevent", "Trigger boot timeout event"); + ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint", + { + {"type", "boot"}, + {"step", "timeout"}, + {"value", value} + }); + if (stof(value) >= 5) + { + ESP_LOGV("text_sensor.nspanelevent", "Jump to wakeup page: %i", id(wakeup_page_id)); + id(disp1).send_command_printf("page %i", id(wakeup_page_id)); + } } } @@ -1259,6 +1298,10 @@ switch: entity_category: config optimistic: true restore_mode: RESTORE_DEFAULT_ON + on_turn_on: + - lambda: id(set_component_color).execute("home.bt_notific", id(home_notify_icon_color_unread), {}); + on_turn_off: + - lambda: id(set_component_color).execute("home.bt_notific", id(home_notify_icon_color_normal), {}); ##### Notification sound ##### - name: ${device_name} Notification sound @@ -1500,10 +1543,7 @@ script: - lambda: ESP_LOGV("script.page_timer", "start page-timer delay %i", int(id(page_timeout).state)); - delay: !lambda return delay *1000; - lambda: |- - DynamicJsonDocument doc(1024); - deserializeJson(doc, id(disp1_nspanel_event).state); - std::string page = doc["page"]; - if (page == "home" or page == "screensaver" or page == "boot" or int(id(page_timeout).state) == 0) + if (id(current_page).state == "home" or id(current_page).state == "screensaver" or id(current_page).state == "boot" or int(id(page_timeout).state) == 0) ESP_LOGD("script.page_timer", "no page-jump"); else { @@ -1655,9 +1695,13 @@ script: id: current_page state: 'home' then: - - script.execute: refresh_datetime - script.execute: refresh_relays - script.execute: refresh_wifi_icon + - lambda: |- + ESP_LOGV("script.update_page_home", "is_notification=%i", (id(notification_text).state.empty() and id(notification_label).state.empty()) ? 0 : 1); + id(disp1).send_command_printf("is_notification=%i", (id(notification_text).state.empty() and id(notification_label).state.empty()) ? 0 : 1); + id(set_component_color).execute("home.bt_notific", id(notification_unread).state ? id(home_notify_icon_color_unread) : id(home_notify_icon_color_normal), {}); + - script.execute: refresh_datetime - script.execute: addon_climate_update_page_home - lambda: ESP_LOGV("script.update_page_home", "Finished"); @@ -1941,6 +1985,57 @@ script: ESP_LOGV("script.set_component_color", "Finished"); + - id: display_wrapped_text + mode: queued + parameters: + component: string + text: string + line_length_limit: int + then: + - lambda: |- + int startPos = 0; + int endPos = 0; + std::string wrappedText = ""; + while (startPos < text.length()) { + while (text[startPos] == ' ' and startPos < text.length()) { startPos++; } + int endPos = startPos + line_length_limit; + if (endPos >= text.length()) endPos = text.length(); + else + { + while (endPos > startPos && text[endPos] != ' ') { endPos--; } + if (endPos == startPos) endPos = startPos + line_length_limit; // Handle case of long word + } + wrappedText += text.substr(startPos, endPos-startPos); + if (endPos < text.length()) + { + while (text[endPos] == ' ') { endPos--; } + if (endPos >= startPos) wrappedText += "\\r"; + } + startPos = endPos + 1; // Skip the space + while (text[startPos] == ' ' and startPos < text.length()) { startPos++; } + } + ESP_LOGV("script.display_wrapped_text", "text (new): %s", wrappedText.c_str()); + id(disp1).set_component_text_printf(component.c_str(), "%s", wrappedText.c_str()); + + - id: check_versions + mode: restart + then: + - delay: 15s + - lambda: |- + ESP_LOGD("script.check_versions", "ESPHome version: ${version}"); + ESP_LOGD("script.check_versions", "TFT version: %s", id(version_tft).c_str()); + if (id(version_tft) != "${version}") ESP_LOGE("script.check_versions", "TFT version mismatch!"); + ESP_LOGD("script.check_versions", "Blueprint version: %s", id(version_blueprint).c_str()); + if (id(version_blueprint) != "${version}") ESP_LOGE("script.check_versions", "Blueprint version mismatch!"); + auto ha_event = new esphome::api::CustomAPIDevice(); + ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint", + { + {"type", "version"}, + {"tft", id(version_tft).c_str()}, + {"esphome", "${version}"}, + {"blueprint", id(version_blueprint).c_str()} + }); + ##### ADD-ONS ############################################################ ##### Add-on - Climate ##### - id: addon_climate_service_call diff --git a/nspanel_eu.HMI b/nspanel_eu.HMI index b1ccafa..5324ec1 100644 Binary files a/nspanel_eu.HMI and b/nspanel_eu.HMI differ diff --git a/nspanel_eu.tft b/nspanel_eu.tft index 3623500..06c4f2d 100644 Binary files a/nspanel_eu.tft and b/nspanel_eu.tft differ diff --git a/nspanel_eu_code/Program.s.txt b/nspanel_eu_code/Program.s.txt index ee36d95..38c65b6 100644 --- a/nspanel_eu_code/Program.s.txt +++ b/nspanel_eu_code/Program.s.txt @@ -8,10 +8,14 @@ Program.s int sleep_mode=0 int is_alarm=0,is_entities=0,is_qrcode=0,is_notification=0 int brightness=100,brightness_dim=40 - bauds=115200//Configure baudrat + int display_mode=1 // 1 = EU, 2 = US, 3 = US landscape + bauds=115200//Configure baudrate 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 - lcd_dev fffb 0002 0000 0020// Fix touch offset for EU Version + if(display_mode==1) + { + lcd_dev fffb 0002 0000 0020// Fix touch offset for EU Version + } printh 92 prints "nspanelevent",0 printh 00 diff --git a/nspanel_eu_code/boot.txt b/nspanel_eu_code/boot.txt index ff347d7..0e727fd 100644 --- a/nspanel_eu_code/boot.txt +++ b/nspanel_eu_code/boot.txt @@ -13,10 +13,12 @@ Page boot Events Preinitialize Event dim=100 + covx display_mode,aux2.txt,0,0 + nspanelevent.txt="{\"page\": \"boot\", \"component\": \"currentpage\", \"value\": \"pagechange\", \"version\": \""+tft_version.txt+"\", \"display_mode\": \""+aux2.txt+"\"}" printh 92 prints "nspanelevent",0 printh 00 - prints "{\"page\": \"boot\", \"component\": \"currentpage\", \"value\": \"pagechange\"}",0 + prints nspanelevent.txt,0 printh 00 printh FF FF FF @@ -26,7 +28,7 @@ Variable (int32) counter Scope: local Value: 0 -Variable (string) aux +Variable (string) aux1 Attributes ID : 13 Scope : local @@ -38,7 +40,14 @@ Variable (string) nspanelevent ID : 14 Scope : local Text : - Max. Text Size: 100 + Max. Text Size: 150 + +Variable (string) aux2 + Attributes + ID : 15 + Scope : local + Text : + Max. Text Size: 10 Text ip_addr Attributes @@ -107,7 +116,7 @@ Text tft_version Dragging : 0 Send Component ID : disabled Associated Keyboard: none - Text : 4.0 + Text : 4.0dev Max. Text Size : 8 Text esph_version @@ -150,9 +159,10 @@ Timer timer Events Timer Event counter.val++ - covx counter.val,aux.txt,0,0 - nspanelevent.txt="{\"page\": \"boot\", \"component\": \"timeout\", \"value\": "+aux.txt+"}" - bluep_version.txt="Retry: "+aux.txt + covx counter.val,aux1.txt,0,0 + covx display_mode,aux2.txt,0,0 + nspanelevent.txt="{\"page\": \"boot\", \"component\": \"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 diff --git a/nspanel_eu_code/home.txt b/nspanel_eu_code/home.txt index 97dae18..607d307 100644 --- a/nspanel_eu_code/home.txt +++ b/nspanel_eu_code/home.txt @@ -25,6 +25,11 @@ Page home vis bt_qrcode,is_qrcode vis bt_entities,is_entities vis bt_alarm,is_alarm + if(display_mode==3) + { + vis left_bt_text,0 + vis right_bt_text,0 + } Variable (int32) disdim Attributes diff --git a/nspanel_us.HMI b/nspanel_us.HMI index d455080..c2144b9 100644 Binary files a/nspanel_us.HMI and b/nspanel_us.HMI differ diff --git a/nspanel_us.tft b/nspanel_us.tft index 632e18b..f8539ae 100644 Binary files a/nspanel_us.tft and b/nspanel_us.tft differ diff --git a/nspanel_us_code/Program.s.txt b/nspanel_us_code/Program.s.txt index 9ed7c01..3548a25 100644 --- a/nspanel_us_code/Program.s.txt +++ b/nspanel_us_code/Program.s.txt @@ -8,9 +8,14 @@ Program.s int sleep_mode=0 int is_alarm=0,is_entities=0,is_qrcode=0,is_notification=0 int brightness=100,brightness_dim=40 - bauds=115200//Configure baudrat + int display_mode=2 // 1 = EU, 2 = US, 3 = US landscape + bauds=115200//Configure baudrate 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 + if(display_mode==1) + { + lcd_dev fffb 0002 0000 0020// Fix touch offset for EU Version + } printh 92 prints "nspanelevent",0 printh 00 diff --git a/nspanel_us_code/boot.txt b/nspanel_us_code/boot.txt index ff347d7..0e727fd 100644 --- a/nspanel_us_code/boot.txt +++ b/nspanel_us_code/boot.txt @@ -13,10 +13,12 @@ Page boot Events Preinitialize Event dim=100 + covx display_mode,aux2.txt,0,0 + nspanelevent.txt="{\"page\": \"boot\", \"component\": \"currentpage\", \"value\": \"pagechange\", \"version\": \""+tft_version.txt+"\", \"display_mode\": \""+aux2.txt+"\"}" printh 92 prints "nspanelevent",0 printh 00 - prints "{\"page\": \"boot\", \"component\": \"currentpage\", \"value\": \"pagechange\"}",0 + prints nspanelevent.txt,0 printh 00 printh FF FF FF @@ -26,7 +28,7 @@ Variable (int32) counter Scope: local Value: 0 -Variable (string) aux +Variable (string) aux1 Attributes ID : 13 Scope : local @@ -38,7 +40,14 @@ Variable (string) nspanelevent ID : 14 Scope : local Text : - Max. Text Size: 100 + Max. Text Size: 150 + +Variable (string) aux2 + Attributes + ID : 15 + Scope : local + Text : + Max. Text Size: 10 Text ip_addr Attributes @@ -107,7 +116,7 @@ Text tft_version Dragging : 0 Send Component ID : disabled Associated Keyboard: none - Text : 4.0 + Text : 4.0dev Max. Text Size : 8 Text esph_version @@ -150,9 +159,10 @@ Timer timer Events Timer Event counter.val++ - covx counter.val,aux.txt,0,0 - nspanelevent.txt="{\"page\": \"boot\", \"component\": \"timeout\", \"value\": "+aux.txt+"}" - bluep_version.txt="Retry: "+aux.txt + covx counter.val,aux1.txt,0,0 + covx display_mode,aux2.txt,0,0 + nspanelevent.txt="{\"page\": \"boot\", \"component\": \"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 diff --git a/nspanel_us_code/home.txt b/nspanel_us_code/home.txt index f85a09e..423f75b 100644 --- a/nspanel_us_code/home.txt +++ b/nspanel_us_code/home.txt @@ -25,6 +25,11 @@ Page home vis bt_qrcode,is_qrcode vis bt_entities,is_entities vis bt_alarm,is_alarm + if(display_mode==3) + { + vis left_bt_text,0 + vis right_bt_text,0 + } Variable (int32) disdim Attributes diff --git a/nspanel_us_land.HMI b/nspanel_us_land.HMI index d3b75a0..2c965c1 100644 Binary files a/nspanel_us_land.HMI and b/nspanel_us_land.HMI differ diff --git a/nspanel_us_land.tft b/nspanel_us_land.tft index 803c58d..60b0dde 100644 Binary files a/nspanel_us_land.tft and b/nspanel_us_land.tft differ diff --git a/nspanel_us_land_code/Program.s.txt b/nspanel_us_land_code/Program.s.txt index 8dd032e..ec8dfba 100644 --- a/nspanel_us_land_code/Program.s.txt +++ b/nspanel_us_land_code/Program.s.txt @@ -8,10 +8,14 @@ Program.s int sleep_mode=0 int is_alarm=0,is_entities=0,is_qrcode=0,is_notification=0 int brightness=100,brightness_dim=40 - bauds=115200//Configure baudrat + int display_mode=3 // 1 = EU, 2 = US, 3 = US landscape + bauds=115200//Configure baudrate 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 - //lcd_dev fffb 0002 0000 0020// Fix touch offset for EU Version + if(display_mode==1) + { + lcd_dev fffb 0002 0000 0020// Fix touch offset for EU Version + } printh 92 prints "nspanelevent",0 printh 00 diff --git a/nspanel_us_land_code/boot.txt b/nspanel_us_land_code/boot.txt index ff347d7..0e727fd 100644 --- a/nspanel_us_land_code/boot.txt +++ b/nspanel_us_land_code/boot.txt @@ -13,10 +13,12 @@ Page boot Events Preinitialize Event dim=100 + covx display_mode,aux2.txt,0,0 + nspanelevent.txt="{\"page\": \"boot\", \"component\": \"currentpage\", \"value\": \"pagechange\", \"version\": \""+tft_version.txt+"\", \"display_mode\": \""+aux2.txt+"\"}" printh 92 prints "nspanelevent",0 printh 00 - prints "{\"page\": \"boot\", \"component\": \"currentpage\", \"value\": \"pagechange\"}",0 + prints nspanelevent.txt,0 printh 00 printh FF FF FF @@ -26,7 +28,7 @@ Variable (int32) counter Scope: local Value: 0 -Variable (string) aux +Variable (string) aux1 Attributes ID : 13 Scope : local @@ -38,7 +40,14 @@ Variable (string) nspanelevent ID : 14 Scope : local Text : - Max. Text Size: 100 + Max. Text Size: 150 + +Variable (string) aux2 + Attributes + ID : 15 + Scope : local + Text : + Max. Text Size: 10 Text ip_addr Attributes @@ -107,7 +116,7 @@ Text tft_version Dragging : 0 Send Component ID : disabled Associated Keyboard: none - Text : 4.0 + Text : 4.0dev Max. Text Size : 8 Text esph_version @@ -150,9 +159,10 @@ Timer timer Events Timer Event counter.val++ - covx counter.val,aux.txt,0,0 - nspanelevent.txt="{\"page\": \"boot\", \"component\": \"timeout\", \"value\": "+aux.txt+"}" - bluep_version.txt="Retry: "+aux.txt + covx counter.val,aux1.txt,0,0 + covx display_mode,aux2.txt,0,0 + nspanelevent.txt="{\"page\": \"boot\", \"component\": \"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 diff --git a/nspanel_us_land_code/home.txt b/nspanel_us_land_code/home.txt index 12fc59e..987fc73 100644 --- a/nspanel_us_land_code/home.txt +++ b/nspanel_us_land_code/home.txt @@ -27,6 +27,11 @@ Page home vis bt_alarm,is_alarm vis left_bt_text,0 vis right_bt_text,0 + if(display_mode==3) + { + vis left_bt_text,0 + vis right_bt_text,0 + } Variable (int32) disdim Attributes diff --git a/nspanel_us_land_code/instructions.md b/nspanel_us_land_code/instructions.md index 774fb93..932d017 100644 --- a/nspanel_us_land_code/instructions.md +++ b/nspanel_us_land_code/instructions.md @@ -1,14 +1,9 @@ # Creating `nspanel_us_land.HMI` from `nspanel_eu.HMI`: ## Program.s: -Comment out `lcd_dev fffb 0002 0000 0020` +Change to `display_mode=3` ## Page `home`: 1. Change left_bt_pic (x,y,w,h) from ( 47,307,120,3) to (467,173,3,120) 2. Change right_bt_pic(x,y,w,h) from (288,307,120,3) to (467, 27,3,120) -3. Rotate pictures 30 & 31 by 90degrees - You will find the pics under pics folder where this instruction file is -4. Add the following to "Preinitialize Event" on page `home` (at the end) to hide those elements: -``` -vis left_bt_text,0 -vis right_bt_text,0 -``` +3. Rotate pictures 30 & 31 by 90degrees - You will find the rotated pics under pics folder where this instruction file is.