Skip to content

Commit 13d348c

Browse files
committed
Hide MAC and show hostname when IP address is available
1 parent 3538d15 commit 13d348c

File tree

4 files changed

+26
-14
lines changed

4 files changed

+26
-14
lines changed

display.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,15 @@ func switchToMainScreen() {
4141

4242
func updateDisplay() {
4343
if networkManager != nil {
44-
nativeInstance.UpdateLabelIfChanged("home_info_ipv4_addr", networkManager.IPv4String())
44+
nativeInstance.UpdateLabelAndChangeVisibility("home_info_ipv4_addr", networkManager.IPv4String())
4545
nativeInstance.UpdateLabelAndChangeVisibility("home_info_ipv6_addr", networkManager.IPv6String())
4646
nativeInstance.UpdateLabelIfChanged("home_info_mac_addr", networkManager.MACString())
4747
nativeInstance.UpdateLabelIfChanged("home_info_hostname", networkManager.Hostname())
48+
49+
// we either show the MAC address (if no IP yet) or the hostname (if either IPv4 or IPv6 are available)
50+
hasIP := networkManager.IPv4Ready() || networkManager.IPv6Ready()
51+
nativeInstance.ChangeVisibility("home_info_mac_addr", !hasIP)
52+
nativeInstance.ChangeVisibility("home_info_hostname", hasIP)
4853
}
4954

5055
_, _ = nativeInstance.UIObjHide("menu_btn_network")
@@ -71,6 +76,7 @@ func updateDisplay() {
7176
nativeInstance.UpdateLabelIfChanged("hdmi_status_label", "Disconnected")
7277
_, _ = nativeInstance.UIObjClearState("hdmi_status_label", "LV_STATE_CHECKED")
7378
}
79+
7480
nativeInstance.UpdateLabelIfChanged("cloud_status_label", fmt.Sprintf("%d active", actionSessions))
7581

7682
if networkManager != nil && networkManager.IsUp() {

internal/native/display.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,18 @@ func (n *Native) UpdateLabelIfChanged(objName string, newText string) {
117117
// UpdateLabelAndChangeVisibility updates the label and changes the visibility of the object
118118
func (n *Native) UpdateLabelAndChangeVisibility(objName string, newText string) {
119119
n.UpdateLabelIfChanged(objName, newText)
120+
n.ChangeVisibility(objName, newText != "")
121+
}
120122

123+
// ChangeVisibility shows or hides an object AND the container it is in
124+
func (n *Native) ChangeVisibility(objName string, show bool) {
121125
containerName := objName + "_container"
122-
if newText == "" {
123-
_, _ = n.UIObjHide(objName)
124-
_, _ = n.UIObjHide(containerName)
125-
} else {
126+
if show {
126127
_, _ = n.UIObjShow(objName)
127128
_, _ = n.UIObjShow(containerName)
129+
} else {
130+
_, _ = n.UIObjHide(objName)
131+
_, _ = n.UIObjHide(containerName)
128132
}
129133
}
130134

internal/native/eez/jetkvm.eez-project

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,8 +1227,8 @@
12271227
"type": "LVGLLabelWidget",
12281228
"left": 0,
12291229
"top": 0,
1230-
"width": 174,
1231-
"height": 25,
1230+
"width": 217,
1231+
"height": 31,
12321232
"customInputs": [],
12331233
"customOutputs": [],
12341234
"style": {
@@ -1251,7 +1251,7 @@
12511251
"checkedStateType": "literal",
12521252
"disabledStateType": "literal",
12531253
"states": "",
1254-
"useStyle": "LabelFontBold24",
1254+
"useStyle": "LabelFontBold30",
12551255
"localStyles": {
12561256
"objID": "e584be1c-d434-4f13-fb87-00665e4a53a9"
12571257
},
@@ -1287,7 +1287,7 @@
12871287
"heightUnit": "content",
12881288
"children": [],
12891289
"widgetFlags": "CLICK_FOCUSABLE|GESTURE_BUBBLE|PRESS_LOCK|SCROLLABLE|SCROLL_CHAIN_HOR|SCROLL_CHAIN_VER|SCROLL_ELASTIC|SCROLL_MOMENTUM|SCROLL_WITH_ARROW|SNAPPABLE",
1290-
"hiddenFlag": true,
1290+
"hiddenFlag": false,
12911291
"hiddenFlagType": "literal",
12921292
"clickableFlagType": "literal",
12931293
"checkedStateType": "literal",
@@ -1335,6 +1335,7 @@
13351335
"heightUnit": "content",
13361336
"children": [],
13371337
"widgetFlags": "CLICK_FOCUSABLE|GESTURE_BUBBLE|PRESS_LOCK|SCROLLABLE|SCROLL_CHAIN_HOR|SCROLL_CHAIN_VER|SCROLL_ELASTIC|SCROLL_MOMENTUM|SCROLL_WITH_ARROW|SNAPPABLE",
1338+
"hiddenFlag": false,
13381339
"hiddenFlagType": "literal",
13391340
"clickableFlagType": "literal",
13401341
"checkedStateType": "literal",
@@ -1362,8 +1363,8 @@
13621363
"type": "LVGLLabelWidget",
13631364
"left": 0,
13641365
"top": 0,
1365-
"width": 60,
1366-
"height": 18,
1366+
"width": 74,
1367+
"height": 21,
13671368
"customInputs": [],
13681369
"customOutputs": [],
13691370
"style": {
@@ -1393,7 +1394,8 @@
13931394
"MAIN": {
13941395
"DEFAULT": {
13951396
"pad_bottom": 2,
1396-
"pad_top": -1
1397+
"pad_top": -1,
1398+
"text_font": "FontBook20"
13971399
}
13981400
}
13991401
}

internal/native/eez/src/ui/screens.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ void create_screen_home_screen() {
318318
objects.home_info_ipv4_addr = obj;
319319
lv_obj_set_pos(obj, LV_PCT(0), LV_PCT(0));
320320
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
321-
add_style_label_font_bold24(obj);
321+
add_style_label_font_bold30(obj);
322322
lv_label_set_text(obj, "169.254.169.254");
323323
}
324324
{
@@ -328,7 +328,6 @@ void create_screen_home_screen() {
328328
lv_obj_set_pos(obj, LV_PCT(0), LV_PCT(0));
329329
lv_obj_set_size(obj, LV_PCT(100), LV_SIZE_CONTENT);
330330
lv_label_set_long_mode(obj, LV_LABEL_LONG_SCROLL_CIRCULAR);
331-
lv_obj_add_flag(obj, LV_OBJ_FLAG_HIDDEN);
332331
add_style_label_font16(obj);
333332
lv_obj_set_style_text_font(obj, &ui_font_font_book16, LV_PART_MAIN | LV_STATE_DEFAULT);
334333
lv_obj_set_style_pad_top(obj, -1, LV_PART_MAIN | LV_STATE_DEFAULT);
@@ -354,6 +353,7 @@ void create_screen_home_screen() {
354353
add_style_label_font16(obj);
355354
lv_obj_set_style_pad_bottom(obj, 2, LV_PART_MAIN | LV_STATE_DEFAULT);
356355
lv_obj_set_style_pad_top(obj, -1, LV_PART_MAIN | LV_STATE_DEFAULT);
356+
lv_obj_set_style_text_font(obj, &ui_font_font_book20, LV_PART_MAIN | LV_STATE_DEFAULT);
357357
lv_label_set_text(obj, "JetKVM");
358358
}
359359
}

0 commit comments

Comments
 (0)