Add variables and MAC address to device screen

Also cleaned up all the scrolling and click/gesture handling so all the menus work correctly.
This commit is contained in:
Marc Brooks 2025-10-28 17:00:02 -05:00
parent 24fe664ad4
commit 9d9fb94023
No known key found for this signature in database
GPG Key ID: 583A6AF2D6AE1DC6
16 changed files with 1004 additions and 2880 deletions

View File

@ -41,10 +41,16 @@ func switchToMainScreen() {
func updateDisplay() {
if networkManager != nil {
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())
ipv4 := networkManager.IPv4String()
nativeInstance.UISetVar("ip_v4_address", ipv4)
nativeInstance.ChangeVisibility("home_info_ipv4_addr", ipv4 != "")
ipv6 := networkManager.IPv6String()
nativeInstance.UISetVar("ip_v6_address", ipv6)
nativeInstance.ChangeVisibility("home_info_ipv6_addr", ipv6 != "")
nativeInstance.UISetVar("mac_address", networkManager.MACString())
nativeInstance.UISetVar("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()
@ -210,7 +216,8 @@ func waitCtrlAndRequestDisplayUpdate(shouldWakeDisplay bool, reason string) {
func updateStaticContents() {
//contents that never change
if networkManager != nil {
nativeInstance.UpdateLabelIfChanged("home_info_mac_addr", networkManager.MACString())
mac := networkManager.MACString()
nativeInstance.UISetVar("mac_address", mac)
}
// get cpu info
@ -236,7 +243,7 @@ func updateStaticContents() {
nativeInstance.UpdateLabelAndChangeVisibility("build_date", version.BuildDate)
nativeInstance.UpdateLabelAndChangeVisibility("golang_version", version.GoVersion)
// nativeInstance.UpdateLabelAndChangeVisibility("boot_screen_device_id", GetDeviceID())
nativeInstance.UpdateLabelAndChangeVisibility("device_id", GetDeviceID())
}
// setDisplayBrightness sets /sys/class/backlight/backlight/brightness to alter

View File

@ -98,6 +98,10 @@ func uiGetLVGLVersion() string {
return ""
}
func uiTick() {
panicPlatformNotSupported()
}
func videoGetStreamQualityFactor() (float64, error) {
panicPlatformNotSupported()
return 0, nil

View File

@ -109,6 +109,7 @@ func (n *Native) UpdateLabelIfChanged(objName string, newText string) {
if changed {
l.Msg("label changed")
uiTick()
} else {
l.Msg("label not changed")
}
@ -130,6 +131,8 @@ func (n *Native) ChangeVisibility(objName string, show bool) {
_, _ = n.UIObjHide(objName)
_, _ = n.UIObjHide(containerName)
}
uiTick()
}
// SwitchToScreenIf switches to the screen if the screen name is different from the current screen and the screen name is in the shouldSwitch list

File diff suppressed because one or more lines are too long

View File

@ -56,6 +56,10 @@ void action_switch_to_reboot(lv_event_t *e) {
loadScreen(SCREEN_ID_REBOOT_SCREEN);
}
void action_switch_to_network(lv_event_t *e) {
loadScreen(SCREEN_ID_MENU_NETWORK_SCREEN);
}
void action_menu_screen_gesture(lv_event_t * e) {
handle_gesture_main_screen_switch(e, LV_DIR_RIGHT);
}
@ -76,6 +80,11 @@ void action_about_screen_gesture(lv_event_t * e) {
handle_gesture_screen_switch(e, LV_DIR_RIGHT, SCREEN_ID_MENU_SCREEN);
}
void action_status_screen_gesture(lv_event_t *e) {
handle_gesture_screen_switch(e, LV_DIR_RIGHT, SCREEN_ID_MENU_SCREEN);
}
// user_data doesn't seem to be working, so we use a global variable here
static uint32_t t_reset_config;
static uint32_t t_reboot;
@ -168,9 +177,9 @@ void action_dhcpc(lv_event_t * e) {
.lock = &b_dhcpc_lock,
.hold_time_seconds = DHCPC_HOLD_TIME,
.rpc_method = "toggleDHCPClient",
.button_obj = NULL, // No button/spinner for reboot
.button_obj = NULL, // No button/spinner for dhcp client change
.spinner_obj = NULL,
.label_obj = objects.dhcpc_label,
.label_obj = objects.dhcp_client_label,
.default_text = "Press and hold for\n5 seconds"
};

View File

@ -26,6 +26,8 @@ extern void action_reboot(lv_event_t * e);
extern void action_switch_to_reboot(lv_event_t * e);
extern void action_dhcpc(lv_event_t * e);
extern void action_switch_to_dhcpc(lv_event_t * e);
extern void action_status_screen_gesture(lv_event_t * e);
extern void action_switch_to_network(lv_event_t * e);
#ifdef __cplusplus

View File

@ -8,7 +8,6 @@ extern "C" {
#endif
extern const lv_font_t ui_font_font_bold30;
extern const lv_font_t ui_font_font_bold24;
extern const lv_font_t ui_font_font_book16;
extern const lv_font_t ui_font_font_book18;
extern const lv_font_t ui_font_font_book20;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -26,7 +26,7 @@ typedef struct _objects_t {
lv_obj_t *no_network_header_logo;
lv_obj_t *no_network_content_container;
lv_obj_t *no_network_title;
lv_obj_t *home_info_ipv6_addr_1;
lv_obj_t *no_network_connect_cable;
lv_obj_t *home_header_container;
lv_obj_t *home_header_logo;
lv_obj_t *cloud_status_icon;
@ -51,15 +51,15 @@ typedef struct _objects_t {
lv_obj_t *menu_btn_access;
lv_obj_t *menu_btn_advanced;
lv_obj_t *menu_btn_about;
lv_obj_t *menu_header_container_1;
lv_obj_t *menu_items_container_1;
lv_obj_t *menu_advanced_header_container;
lv_obj_t *menu_advanced_items_container;
lv_obj_t *menu_btn_advanced_developer_mode;
lv_obj_t *menu_btn_advanced_usb_emulation;
lv_obj_t *menu_btn_advanced_reboot;
lv_obj_t *menu_btn_dhcp_client;
lv_obj_t *menu_btn_advanced_reset_config;
lv_obj_t *menu_header_container_2;
lv_obj_t *menu_items_container_2;
lv_obj_t *menu_network_header_container;
lv_obj_t *menu_network_items_container;
lv_obj_t *menu_btn_network_ipv4;
lv_obj_t *menu_btn_network_ipv6;
lv_obj_t *menu_btn_network_lldp;
@ -85,32 +85,39 @@ typedef struct _objects_t {
lv_obj_t *status_items_container;
lv_obj_t *device_id_container;
lv_obj_t *device_id;
lv_obj_t *device_mac_address_container;
lv_obj_t *device_mac_address;
lv_obj_t *cloud_account_id_container;
lv_obj_t *app_version_1;
lv_obj_t *cloud_account_id;
lv_obj_t *cloud_domain_container;
lv_obj_t *cloud_domain;
lv_obj_t *reset_config_header;
lv_obj_t *reset_config_container;
lv_obj_t *reset_config_label_container;
lv_obj_t *reset_config_label;
lv_obj_t *reset_config_spinner_container;
lv_obj_t *reset_config_spinner;
lv_obj_t *reset_config_button_container;
lv_obj_t *reset_config_button;
lv_obj_t *obj0;
lv_obj_t *reset_config_button_label;
lv_obj_t *reboot_header;
lv_obj_t *reboot_container;
lv_obj_t *reboot_label_container;
lv_obj_t *reboot_label;
lv_obj_t *reboot_config_button;
lv_obj_t *obj1;
lv_obj_t *reboot_device_button_container;
lv_obj_t *reboot_device_button;
lv_obj_t *reboot_device_button_label;
lv_obj_t *reboot_in_progress_container;
lv_obj_t *reboot_in_progress_logo;
lv_obj_t *reboot_in_progress_label;
lv_obj_t *dhcp_client_header;
lv_obj_t *dhcp_client_container;
lv_obj_t *dhcp_client_label_container;
lv_obj_t *dhcpc_label;
lv_obj_t *dhcp_client_label;
lv_obj_t *dhcp_client_spinner_container;
lv_obj_t *dhcp_client_spinner;
lv_obj_t *dhcp_client_button;
lv_obj_t *obj2;
lv_obj_t *dhcp_client_change_button_container;
lv_obj_t *dhcp_client_change_button;
lv_obj_t *dhcp_client_change_label;
} objects_t;

View File

@ -170,11 +170,9 @@ void remove_style_flow_row_start_center(lv_obj_t *obj) {
void init_style_flex_column_start_MAIN_DEFAULT(lv_style_t *style) {
init_style_flow_row_space_between_MAIN_DEFAULT(style);
lv_style_set_layout(style, LV_LAYOUT_FLEX);
lv_style_set_flex_flow(style, LV_FLEX_FLOW_COLUMN);
lv_style_set_flex_track_place(style, LV_FLEX_ALIGN_START);
lv_style_set_flex_cross_place(style, LV_FLEX_ALIGN_START);
lv_style_set_flex_main_place(style, LV_FLEX_ALIGN_SPACE_EVENLY);
lv_style_set_flex_flow(style, LV_FLEX_FLOW_COLUMN);
};
lv_style_t *get_style_flex_column_start_MAIN_DEFAULT() {
@ -294,37 +292,6 @@ void remove_style_label_font16(lv_obj_t *obj) {
lv_obj_remove_style(obj, get_style_label_font16_MAIN_DEFAULT(), LV_PART_MAIN | LV_STATE_DEFAULT);
};
//
// Style: LabelFontBold24
//
void init_style_label_font_bold24_MAIN_DEFAULT(lv_style_t *style) {
init_style_label_font16_MAIN_DEFAULT(style);
lv_style_set_text_font(style, &ui_font_font_bold24);
lv_style_set_length(style, 0);
};
lv_style_t *get_style_label_font_bold24_MAIN_DEFAULT() {
static lv_style_t *style;
if (!style) {
style = lv_malloc(sizeof(lv_style_t));
lv_style_init(style);
init_style_label_font_bold24_MAIN_DEFAULT(style);
}
return style;
};
void add_style_label_font_bold24(lv_obj_t *obj) {
(void)obj;
lv_obj_add_style(obj, get_style_label_font_bold24_MAIN_DEFAULT(), LV_PART_MAIN | LV_STATE_DEFAULT);
};
void remove_style_label_font_bold24(lv_obj_t *obj) {
(void)obj;
lv_obj_remove_style(obj, get_style_label_font_bold24_MAIN_DEFAULT(), LV_PART_MAIN | LV_STATE_DEFAULT);
};
//
// Style: LabelFontBold30
//
@ -558,7 +525,6 @@ void add_style(lv_obj_t *obj, int32_t styleIndex) {
add_style_flex_screen,
add_style_flex_screen_menu,
add_style_label_font16,
add_style_label_font_bold24,
add_style_label_font_bold30,
add_style_header_link,
add_style_menu_button,
@ -582,7 +548,6 @@ void remove_style(lv_obj_t *obj, int32_t styleIndex) {
remove_style_flex_screen,
remove_style_flex_screen_menu,
remove_style_label_font16,
remove_style_label_font_bold24,
remove_style_label_font_bold30,
remove_style_header_link,
remove_style_menu_button,

View File

@ -52,11 +52,6 @@ lv_style_t *get_style_label_font16_MAIN_DEFAULT();
void add_style_label_font16(lv_obj_t *obj);
void remove_style_label_font16(lv_obj_t *obj);
// Style: LabelFontBold24
lv_style_t *get_style_label_font_bold24_MAIN_DEFAULT();
void add_style_label_font_bold24(lv_obj_t *obj);
void remove_style_label_font_bold24(lv_obj_t *obj);
// Style: LabelFontBold30
lv_style_t *get_style_label_font_bold30_MAIN_DEFAULT();
void add_style_label_font_bold30(lv_obj_t *obj);

View File

@ -10,8 +10,6 @@ void ui_call_rpc_handler(const char *method, const char *params);
#if defined(EEZ_FOR_LVGL)
#include <eez/flow/lvgl_api.h>
#endif

View File

@ -7,15 +7,79 @@ char app_version[100] = { 0 };
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 hostname[262] = { 0 };
const char *get_var_ip_v4_address() {
return ip_v4_address;
}
void set_var_ip_v4_address(const char *value) {
strncpy(ip_v4_address, value, sizeof(ip_v4_address) / sizeof(char));
ip_v4_address[sizeof(ip_v4_address) / sizeof(char) - 1] = 0;
tick_screen_home_screen();
}
const char *get_var_ip_v6_address() {
return ip_v6_address;
}
void set_var_ip_v6_address(const char *value) {
strncpy(ip_v6_address, value, sizeof(ip_v6_address) / sizeof(char));
ip_v6_address[sizeof(ip_v6_address) / sizeof(char) - 1] = 0;
tick_screen_home_screen();
}
const char *get_var_mac_address() {
return mac_address;
}
void set_var_mac_address(const char *value) {
strncpy(mac_address, value, sizeof(mac_address) / sizeof(char));
mac_address[sizeof(mac_address) / sizeof(char) - 1] = 0;
tick_screen_home_screen();
tick_screen_status_screen();
}
const char *get_var_hostname() {
return hostname;
}
void set_var_hostname(const char *value) {
strncpy(hostname, value, sizeof(hostname) / sizeof(char));
hostname[sizeof(hostname) / sizeof(char) - 1] = 0;
tick_screen_home_screen();
}
const char *get_var_app_version() {
return app_version;
}
void set_var_app_version(const char *value) {
strncpy(app_version, value, sizeof(app_version) / sizeof(char));
app_version[sizeof(app_version) / sizeof(char) - 1] = 0;
tick_screen_boot_screen();
tick_screen_about_screen();
}
const char *get_var_system_version() {
return system_version;
}
void set_var_system_version(const char *value) {
strncpy(system_version, value, sizeof(system_version) / sizeof(char));
system_version[sizeof(system_version) / sizeof(char) - 1] = 0;
tick_screen_about_screen();
}
const char *get_var_lvgl_version() {
if (lvgl_version[0] == '\0') {
char buf[32];
@ -28,23 +92,17 @@ const char *get_var_lvgl_version() {
return lvgl_version;
}
void set_var_app_version(const char *value) {
strncpy(app_version, value, sizeof(app_version) / sizeof(char));
app_version[sizeof(app_version) / sizeof(char) - 1] = 0;
}
void set_var_lvgl_version(const char *value) {
// intentional NOP since this is actually generated
void set_var_system_version(const char *value) {
strncpy(system_version, value, sizeof(system_version) / sizeof(char));
system_version[sizeof(system_version) / sizeof(char) - 1] = 0;
}
void set_var_lvgl_version(const char *value) {}
void set_var_main_screen(const char *value) {
strncpy(main_screen, value, sizeof(main_screen) / sizeof(char));
main_screen[sizeof(main_screen) / sizeof(char) - 1] = 0;
tick_screen_about_screen();
}
const char *get_var_main_screen() {
return main_screen;
}
void set_var_main_screen(const char *value) {
strncpy(main_screen, value, sizeof(main_screen) / sizeof(char));
main_screen[sizeof(main_screen) / sizeof(char) - 1] = 0;
}

View File

@ -4,6 +4,11 @@
#include <stdint.h>
#include <stdbool.h>
void tick_screen_home_screen();
void tick_screen_status_screen();
void tick_screen_boot_screen();
void tick_screen_about_screen();
#ifdef __cplusplus
extern "C" {
#endif
@ -18,7 +23,11 @@ enum FlowGlobalVariables {
FLOW_GLOBAL_VARIABLE_APP_VERSION = 0,
FLOW_GLOBAL_VARIABLE_SYSTEM_VERSION = 1,
FLOW_GLOBAL_VARIABLE_LVGL_VERSION = 2,
FLOW_GLOBAL_VARIABLE_MAIN_SCREEN = 3
FLOW_GLOBAL_VARIABLE_MAIN_SCREEN = 3,
FLOW_GLOBAL_VARIABLE_MAC_ADDRESS = 4,
FLOW_GLOBAL_VARIABLE_IP_V6_ADDRESS = 5,
FLOW_GLOBAL_VARIABLE_IP_V4_ADDRESS = 6,
FLOW_GLOBAL_VARIABLE_HOSTNAME = 7
};
// Native global variables
@ -31,6 +40,14 @@ extern const char *get_var_lvgl_version();
extern void set_var_lvgl_version(const char *value);
extern const char *get_var_main_screen();
extern void set_var_main_screen(const char *value);
extern const char *get_var_mac_address();
extern void set_var_mac_address(const char *value);
extern const char *get_var_ip_v6_address();
extern void set_var_ip_v6_address(const char *value);
extern const char *get_var_ip_v4_address();
extern void set_var_ip_v4_address(const char *value);
extern const char *get_var_hostname();
extern void set_var_hostname(const char *value);
#ifdef __cplusplus

View File

@ -873,7 +873,7 @@ export default function KvmIdRoute() {
style={{ animationDuration: "500ms" }}
className="animate-slideUpFade pointer-events-none absolute inset-0 flex items-center justify-center p-4"
>
<div className="relative h-full max-h-[720px] w-full max-w-[1280px] rounded-md">
<div className="relative h-full max-h-[720px] w-full max-w-7xl rounded-md">
{!!ConnectionStatusElement && ConnectionStatusElement}
</div>
</div>