Compare commits

...

2 Commits

Author SHA1 Message Date
Marc Brooks 51e0c9e421
Show -- for unresolved IPv4 and IPv6 addresses 2025-10-30 05:00:21 -05:00
Marc Brooks af261bd8f0
Make hostname same size as MAC Address 2025-10-30 04:47:21 -05:00
4 changed files with 14 additions and 10 deletions

View File

@ -42,12 +42,18 @@ func switchToMainScreen() {
func updateDisplay() {
if networkManager != nil {
ipv4 := networkManager.IPv4String()
if ipv4 == "" {
ipv4 = "--"
}
nativeInstance.UISetVar("ip_v4_address", ipv4)
nativeInstance.ChangeVisibility("home_info_ipv4_addr", ipv4 != "")
ipv6 := networkManager.IPv6String()
if ipv6 == "" {
ipv6 = "--"
}
nativeInstance.UISetVar("ip_v6_address", ipv6)
nativeInstance.ChangeVisibility("home_info_ipv6_addr", ipv6 != "")
nativeInstance.ChangeVisibility("home_info_ipv6_addr", ipv6 != "" && ipv6 != "--")
nativeInstance.UISetVar("mac_address", networkManager.MACString())
nativeInstance.UISetVar("hostname", networkManager.Hostname())

View File

@ -58,7 +58,7 @@
{
"objID": "316b04e4-a7de-4afc-c413-31f5f36d3843",
"fileName": "vars.c",
"template": "#include <string.h>\n#include <stdio.h>\n//${eez-studio LVGL_INCLUDE}\n#include \"vars.h\"\n\nchar app_version[100] = { 0 };\nchar system_version[100] = { 0 };\nchar lvgl_version[32] = { 0 };\nchar main_screen[32] = \"home_screen\";\nchar mac_address[18] = { 0 };\nchar ip_v4_address[22] = { 0 };\nchar ip_v6_address[46] = { 0 };\nchar hostname[262] = { 0 };\n\nconst char *get_var_ip_v4_address() {\n return ip_v4_address;\n}\n\nvoid set_var_ip_v4_address(const char *value) {\n strncpy(ip_v4_address, value, sizeof(ip_v4_address) / sizeof(char));\n ip_v4_address[sizeof(ip_v4_address) / sizeof(char) - 1] = 0;\n\n tick_screen_home_screen();\n}\n\nconst char *get_var_ip_v6_address() {\n return ip_v6_address;\n}\n\nvoid set_var_ip_v6_address(const char *value) {\n strncpy(ip_v6_address, value, sizeof(ip_v6_address) / sizeof(char));\n ip_v6_address[sizeof(ip_v6_address) / sizeof(char) - 1] = 0;\n\n tick_screen_home_screen();\n}\n\nconst char *get_var_mac_address() {\n return mac_address;\n}\n\nvoid set_var_mac_address(const char *value) {\n strncpy(mac_address, value, sizeof(mac_address) / sizeof(char));\n mac_address[sizeof(mac_address) / sizeof(char) - 1] = 0;\n\n tick_screen_home_screen();\n tick_screen_status_screen();\n}\n\nconst char *get_var_hostname() {\n return hostname;\n}\n\nvoid set_var_hostname(const char *value) {\n strncpy(hostname, value, sizeof(hostname) / sizeof(char));\n hostname[sizeof(hostname) / sizeof(char) - 1] = 0;\n\n tick_screen_home_screen();\n}\n\nconst char *get_var_app_version() {\n return app_version;\n}\n\nvoid set_var_app_version(const char *value) {\n strncpy(app_version, value, sizeof(app_version) / sizeof(char));\n app_version[sizeof(app_version) / sizeof(char) - 1] = 0;\n \n tick_screen_boot_screen();\n tick_screen_about_screen();\n}\n\nconst char *get_var_system_version() {\n return system_version;\n}\n\nvoid set_var_system_version(const char *value) {\n strncpy(system_version, value, sizeof(system_version) / sizeof(char));\n system_version[sizeof(system_version) / sizeof(char) - 1] = 0;\n\n tick_screen_about_screen();\n}\n\nconst char *get_var_lvgl_version() {\n if (lvgl_version[0] == '\\0') {\n char buf[32];\n sprintf(buf, \"%d.%d.%d\", LVGL_VERSION_MAJOR, LVGL_VERSION_MINOR, LVGL_VERSION_PATCH);\n \n \n strncpy(lvgl_version, buf, sizeof(lvgl_version) / sizeof(char));\n app_version[sizeof(lvgl_version) / sizeof(char) - 1] = 0;\n }\n return lvgl_version;\n}\n\nvoid set_var_lvgl_version(const char *value) {\n // intentional NOP since this is actually generated\n \n tick_screen_about_screen();\n}\n\nconst char *get_var_main_screen() {\n return main_screen;\n}\n\nvoid set_var_main_screen(const char *value) {\n strncpy(main_screen, value, sizeof(main_screen) / sizeof(char));\n main_screen[sizeof(main_screen) / sizeof(char) - 1] = 0;\n}\n"
"template": "#include <string.h>\n#include <stdio.h>\n//${eez-studio LVGL_INCLUDE}\n#include \"vars.h\"\n\nchar app_version[100] = { 0 };\nchar system_version[100] = { 0 };\nchar lvgl_version[32] = { 0 };\nchar main_screen[32] = \"home_screen\";\nchar mac_address[18] = { 0 };\nchar ip_v4_address[22] = \"--\";\nchar ip_v6_address[46] = \"--\";\nchar hostname[262] = { 0 };\n\nconst char *get_var_ip_v4_address() {\n return ip_v4_address;\n}\n\nvoid set_var_ip_v4_address(const char *value) {\n strncpy(ip_v4_address, value, sizeof(ip_v4_address) / sizeof(char));\n ip_v4_address[sizeof(ip_v4_address) / sizeof(char) - 1] = 0;\n\n tick_screen_home_screen();\n}\n\nconst char *get_var_ip_v6_address() {\n return ip_v6_address;\n}\n\nvoid set_var_ip_v6_address(const char *value) {\n strncpy(ip_v6_address, value, sizeof(ip_v6_address) / sizeof(char));\n ip_v6_address[sizeof(ip_v6_address) / sizeof(char) - 1] = 0;\n\n tick_screen_home_screen();\n}\n\nconst char *get_var_mac_address() {\n return mac_address;\n}\n\nvoid set_var_mac_address(const char *value) {\n strncpy(mac_address, value, sizeof(mac_address) / sizeof(char));\n mac_address[sizeof(mac_address) / sizeof(char) - 1] = 0;\n\n tick_screen_home_screen();\n tick_screen_status_screen();\n}\n\nconst char *get_var_hostname() {\n return hostname;\n}\n\nvoid set_var_hostname(const char *value) {\n strncpy(hostname, value, sizeof(hostname) / sizeof(char));\n hostname[sizeof(hostname) / sizeof(char) - 1] = 0;\n\n tick_screen_home_screen();\n}\n\nconst char *get_var_app_version() {\n return app_version;\n}\n\nvoid set_var_app_version(const char *value) {\n strncpy(app_version, value, sizeof(app_version) / sizeof(char));\n app_version[sizeof(app_version) / sizeof(char) - 1] = 0;\n \n tick_screen_boot_screen();\n tick_screen_about_screen();\n}\n\nconst char *get_var_system_version() {\n return system_version;\n}\n\nvoid set_var_system_version(const char *value) {\n strncpy(system_version, value, sizeof(system_version) / sizeof(char));\n system_version[sizeof(system_version) / sizeof(char) - 1] = 0;\n\n tick_screen_about_screen();\n}\n\nconst char *get_var_lvgl_version() {\n if (lvgl_version[0] == '\\0') {\n char buf[32];\n sprintf(buf, \"%d.%d.%d\", LVGL_VERSION_MAJOR, LVGL_VERSION_MINOR, LVGL_VERSION_PATCH);\n \n \n strncpy(lvgl_version, buf, sizeof(lvgl_version) / sizeof(char));\n app_version[sizeof(lvgl_version) / sizeof(char) - 1] = 0;\n }\n return lvgl_version;\n}\n\nvoid set_var_lvgl_version(const char *value) {\n // intentional NOP since this is actually generated\n \n tick_screen_about_screen();\n}\n\nconst char *get_var_main_screen() {\n return main_screen;\n}\n\nvoid set_var_main_screen(const char *value) {\n strncpy(main_screen, value, sizeof(main_screen) / sizeof(char));\n main_screen[sizeof(main_screen) / sizeof(char) - 1] = 0;\n}\n"
},
{
"objID": "cbe7cde1-8920-476a-b2a2-1761ae7451b0",
@ -1414,8 +1414,8 @@
"type": "LVGLLabelWidget",
"left": 0,
"top": 0,
"width": 74,
"height": 21,
"width": 60,
"height": 19,
"customInputs": [],
"customOutputs": [],
"style": {
@ -1446,8 +1446,7 @@
"MAIN": {
"DEFAULT": {
"pad_bottom": 2,
"pad_top": -1,
"text_font": "FontBook20"
"pad_top": 0
}
}
}

View File

@ -370,8 +370,7 @@ void create_screen_home_screen() {
lv_obj_clear_flag(obj, LV_OBJ_FLAG_CLICK_FOCUSABLE|LV_OBJ_FLAG_PRESS_LOCK|LV_OBJ_FLAG_SCROLLABLE|LV_OBJ_FLAG_SCROLL_CHAIN_HOR|LV_OBJ_FLAG_SCROLL_CHAIN_VER|LV_OBJ_FLAG_SCROLL_ELASTIC|LV_OBJ_FLAG_SCROLL_MOMENTUM|LV_OBJ_FLAG_SCROLL_WITH_ARROW|LV_OBJ_FLAG_SNAPPABLE);
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_obj_set_style_pad_top(obj, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_label_set_text(obj, "");
}
}

View File

@ -8,8 +8,8 @@ char system_version[100] = { 0 };
char lvgl_version[32] = { 0 };
char main_screen[32] = "home_screen";
char mac_address[18] = { 0 };
char ip_v4_address[22] = { 0 };
char ip_v6_address[46] = { 0 };
char ip_v4_address[22] = "--";
char ip_v6_address[46] = "--";
char hostname[262] = { 0 };
const char *get_var_ip_v4_address() {