From 24fe664ad4c8630a588a9b4f529f988609e89315 Mon Sep 17 00:00:00 2001 From: Marc Brooks Date: Mon, 27 Oct 2025 18:01:55 -0500 Subject: [PATCH] Hide MAC and show hostname when IP address is available --- display.go | 8 +++++++- internal/native/display.go | 12 ++++++++---- internal/native/eez/jetkvm.eez-project | 16 +++++++++------- internal/native/eez/src/ui/screens.c | 4 ++-- 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/display.go b/display.go index 6a37ebd7..2cf243d3 100644 --- a/display.go +++ b/display.go @@ -41,10 +41,15 @@ func switchToMainScreen() { func updateDisplay() { if networkManager != nil { - nativeInstance.UpdateLabelIfChanged("home_info_ipv4_addr", networkManager.IPv4String()) + nativeInstance.UpdateLabelAndChangeVisibility("home_info_ipv4_addr", networkManager.IPv4String()) nativeInstance.UpdateLabelAndChangeVisibility("home_info_ipv6_addr", networkManager.IPv6String()) nativeInstance.UpdateLabelIfChanged("home_info_mac_addr", networkManager.MACString()) nativeInstance.UpdateLabelIfChanged("home_info_hostname", networkManager.Hostname()) + + // we either show the MAC address (if no IP yet) or the hostname (if either IPv4 or IPv6 are available) + hasIP := networkManager.IPv4Ready() || networkManager.IPv6Ready() + nativeInstance.ChangeVisibility("home_info_mac_addr", !hasIP) + nativeInstance.ChangeVisibility("home_info_hostname", hasIP) } _, _ = nativeInstance.UIObjHide("menu_btn_network") @@ -71,6 +76,7 @@ func updateDisplay() { nativeInstance.UpdateLabelIfChanged("hdmi_status_label", "Disconnected") _, _ = nativeInstance.UIObjClearState("hdmi_status_label", "LV_STATE_CHECKED") } + nativeInstance.UpdateLabelIfChanged("cloud_status_label", fmt.Sprintf("%d active", actionSessions)) if networkManager != nil && networkManager.IsUp() { diff --git a/internal/native/display.go b/internal/native/display.go index 9c92378d..f850a92b 100644 --- a/internal/native/display.go +++ b/internal/native/display.go @@ -117,14 +117,18 @@ func (n *Native) UpdateLabelIfChanged(objName string, newText string) { // UpdateLabelAndChangeVisibility updates the label and changes the visibility of the object func (n *Native) UpdateLabelAndChangeVisibility(objName string, newText string) { n.UpdateLabelIfChanged(objName, newText) + n.ChangeVisibility(objName, newText != "") +} +// ChangeVisibility shows or hides an object AND the container it is in +func (n *Native) ChangeVisibility(objName string, show bool) { containerName := objName + "_container" - if newText == "" { - _, _ = n.UIObjHide(objName) - _, _ = n.UIObjHide(containerName) - } else { + if show { _, _ = n.UIObjShow(objName) _, _ = n.UIObjShow(containerName) + } else { + _, _ = n.UIObjHide(objName) + _, _ = n.UIObjHide(containerName) } } diff --git a/internal/native/eez/jetkvm.eez-project b/internal/native/eez/jetkvm.eez-project index 29bbfdc9..8f03aefe 100644 --- a/internal/native/eez/jetkvm.eez-project +++ b/internal/native/eez/jetkvm.eez-project @@ -1227,8 +1227,8 @@ "type": "LVGLLabelWidget", "left": 0, "top": 0, - "width": 174, - "height": 25, + "width": 217, + "height": 31, "customInputs": [], "customOutputs": [], "style": { @@ -1251,7 +1251,7 @@ "checkedStateType": "literal", "disabledStateType": "literal", "states": "", - "useStyle": "LabelFontBold24", + "useStyle": "LabelFontBold30", "localStyles": { "objID": "e584be1c-d434-4f13-fb87-00665e4a53a9" }, @@ -1287,7 +1287,7 @@ "heightUnit": "content", "children": [], "widgetFlags": "CLICK_FOCUSABLE|GESTURE_BUBBLE|PRESS_LOCK|SCROLLABLE|SCROLL_CHAIN_HOR|SCROLL_CHAIN_VER|SCROLL_ELASTIC|SCROLL_MOMENTUM|SCROLL_WITH_ARROW|SNAPPABLE", - "hiddenFlag": true, + "hiddenFlag": false, "hiddenFlagType": "literal", "clickableFlagType": "literal", "checkedStateType": "literal", @@ -1335,6 +1335,7 @@ "heightUnit": "content", "children": [], "widgetFlags": "CLICK_FOCUSABLE|GESTURE_BUBBLE|PRESS_LOCK|SCROLLABLE|SCROLL_CHAIN_HOR|SCROLL_CHAIN_VER|SCROLL_ELASTIC|SCROLL_MOMENTUM|SCROLL_WITH_ARROW|SNAPPABLE", + "hiddenFlag": false, "hiddenFlagType": "literal", "clickableFlagType": "literal", "checkedStateType": "literal", @@ -1362,8 +1363,8 @@ "type": "LVGLLabelWidget", "left": 0, "top": 0, - "width": 60, - "height": 18, + "width": 74, + "height": 21, "customInputs": [], "customOutputs": [], "style": { @@ -1393,7 +1394,8 @@ "MAIN": { "DEFAULT": { "pad_bottom": 2, - "pad_top": -1 + "pad_top": -1, + "text_font": "FontBook20" } } } diff --git a/internal/native/eez/src/ui/screens.c b/internal/native/eez/src/ui/screens.c index cc7d7864..72fc2085 100644 --- a/internal/native/eez/src/ui/screens.c +++ b/internal/native/eez/src/ui/screens.c @@ -318,7 +318,7 @@ void create_screen_home_screen() { objects.home_info_ipv4_addr = obj; lv_obj_set_pos(obj, LV_PCT(0), LV_PCT(0)); lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT); - add_style_label_font_bold24(obj); + add_style_label_font_bold30(obj); lv_label_set_text(obj, "169.254.169.254"); } { @@ -328,7 +328,6 @@ void create_screen_home_screen() { lv_obj_set_pos(obj, LV_PCT(0), LV_PCT(0)); lv_obj_set_size(obj, LV_PCT(100), LV_SIZE_CONTENT); lv_label_set_long_mode(obj, LV_LABEL_LONG_SCROLL_CIRCULAR); - lv_obj_add_flag(obj, LV_OBJ_FLAG_HIDDEN); add_style_label_font16(obj); lv_obj_set_style_text_font(obj, &ui_font_font_book16, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_top(obj, -1, LV_PART_MAIN | LV_STATE_DEFAULT); @@ -354,6 +353,7 @@ void create_screen_home_screen() { add_style_label_font16(obj); lv_obj_set_style_pad_bottom(obj, 2, LV_PART_MAIN | LV_STATE_DEFAULT); lv_obj_set_style_pad_top(obj, -1, LV_PART_MAIN | LV_STATE_DEFAULT); + lv_obj_set_style_text_font(obj, &ui_font_font_book20, LV_PART_MAIN | LV_STATE_DEFAULT); lv_label_set_text(obj, "JetKVM"); } }