nyx: info: use custom action for hw info window

This commit is contained in:
CTCaer
2025-01-24 16:22:19 +02:00
parent 36d415461e
commit d27ba04077
3 changed files with 34 additions and 11 deletions

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2018-2024 CTCaer * Copyright (c) 2018-2025 CTCaer
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License, * under the terms and conditions of the GNU General Public License,
@@ -866,7 +866,7 @@ void nyx_window_toggle_buttons(lv_obj_t *win, bool disable)
} }
} }
lv_res_t lv_win_close_action_custom(lv_obj_t * btn) lv_res_t nyx_win_close_action_custom(lv_obj_t * btn)
{ {
close_btn = NULL; close_btn = NULL;
@@ -886,7 +886,7 @@ lv_obj_t *nyx_create_standard_window(const char *win_title)
lv_win_set_style(win, LV_WIN_STYLE_BG, &win_bg_style); lv_win_set_style(win, LV_WIN_STYLE_BG, &win_bg_style);
lv_obj_set_size(win, LV_HOR_RES, LV_VER_RES); lv_obj_set_size(win, LV_HOR_RES, LV_VER_RES);
close_btn = lv_win_add_btn(win, NULL, SYMBOL_CLOSE" Close", lv_win_close_action_custom); close_btn = lv_win_add_btn(win, NULL, SYMBOL_CLOSE" Close", nyx_win_close_action_custom);
return win; return win;
} }
@@ -2079,6 +2079,7 @@ static void _create_status_bar(lv_theme_t * th)
{ {
static lv_obj_t *status_bar_bg; static lv_obj_t *status_bar_bg;
status_bar_bg = lv_cont_create(lv_layer_top(), NULL); status_bar_bg = lv_cont_create(lv_layer_top(), NULL);
status_bar.bar_bg = status_bar_bg;
static lv_style_t status_bar_style; static lv_style_t status_bar_style;
lv_style_copy(&status_bar_style, &lv_style_plain_color); lv_style_copy(&status_bar_style, &lv_style_plain_color);
@@ -2131,9 +2132,9 @@ static void _create_status_bar(lv_theme_t * th)
lv_obj_set_size(btn_mid, LV_DPI * 5 / 2, LV_DPI / 2); lv_obj_set_size(btn_mid, LV_DPI * 5 / 2, LV_DPI / 2);
lv_obj_align(btn_mid, NULL, LV_ALIGN_CENTER, 0, 0); lv_obj_align(btn_mid, NULL, LV_ALIGN_CENTER, 0, 0);
status_bar.mid = btn_mid; status_bar.mid = btn_mid;
lv_obj_set_opa_scale(status_bar.mid, LV_OPA_0); lv_obj_set_opa_scale(btn_mid, LV_OPA_0);
lv_obj_set_opa_scale_enable(status_bar.mid, true); lv_obj_set_opa_scale_enable(btn_mid, true);
lv_obj_set_click(status_bar.mid, false); lv_obj_set_click(btn_mid, false);
lv_btn_set_action(btn_mid, LV_BTN_ACTION_CLICK, _save_options_action); lv_btn_set_action(btn_mid, LV_BTN_ACTION_CLICK, _save_options_action);
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2018-2019 CTCaer * Copyright (c) 2018-2025 CTCaer
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License, * under the terms and conditions of the GNU General Public License,
@@ -36,6 +36,7 @@ typedef struct _emmc_tool_gui_t
typedef struct _gui_status_bar_ctx typedef struct _gui_status_bar_ctx
{ {
lv_obj_t *bar_bg;
lv_obj_t *mid; lv_obj_t *mid;
lv_obj_t *time_temp; lv_obj_t *time_temp;
lv_obj_t *temp_symbol; lv_obj_t *temp_symbol;
@@ -72,6 +73,7 @@ void reload_nyx();
lv_img_dsc_t *bmp_to_lvimg_obj(const char *path); lv_img_dsc_t *bmp_to_lvimg_obj(const char *path);
lv_res_t mbox_action(lv_obj_t * btns, const char * txt); lv_res_t mbox_action(lv_obj_t * btns, const char * txt);
bool nyx_emmc_check_battery_enough(); bool nyx_emmc_check_battery_enough();
lv_res_t nyx_win_close_action_custom(lv_obj_t * btn);
void nyx_window_toggle_buttons(lv_obj_t *win, bool disable); void nyx_window_toggle_buttons(lv_obj_t *win, bool disable);
lv_obj_t *nyx_create_standard_window(const char *win_title); lv_obj_t *nyx_create_standard_window(const char *win_title);
lv_obj_t *nyx_create_window_custom_close_btn(const char *win_title, lv_action_t rel_action); lv_obj_t *nyx_create_window_custom_close_btn(const char *win_title, lv_action_t rel_action);

View File

@@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2018 naehrwert * Copyright (c) 2018 naehrwert
* Copyright (c) 2018-2024 CTCaer * Copyright (c) 2018-2025 CTCaer
* Copyright (c) 2018 balika011 * Copyright (c) 2018 balika011
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
@@ -351,9 +351,21 @@ out:
return LV_RES_OK; return LV_RES_OK;
} }
static lv_res_t _create_window_fuses_info_status(lv_obj_t *btn) static lv_obj_t *hw_info_ver = NULL;
static lv_res_t _action_win_hw_info_status_close(lv_obj_t *btn)
{ {
lv_obj_t *win = nyx_create_standard_window(SYMBOL_CHIP" HW & Fuses Info"); if (hw_info_ver)
{
lv_obj_del(hw_info_ver);
hw_info_ver = NULL;
}
return nyx_win_close_action_custom(btn);
}
static lv_res_t _create_window_hw_info_status(lv_obj_t *btn)
{
lv_obj_t *win = nyx_create_window_custom_close_btn(SYMBOL_CHIP" HW & Fuses Info", _action_win_hw_info_status_close);
lv_win_add_btn(win, NULL, SYMBOL_DOWNLOAD" Dump fuses", _fuse_dump_window_action); lv_win_add_btn(win, NULL, SYMBOL_DOWNLOAD" Dump fuses", _fuse_dump_window_action);
lv_win_add_btn(win, NULL, SYMBOL_INFO" CAL0 Info", _create_mbox_cal0); lv_win_add_btn(win, NULL, SYMBOL_INFO" CAL0 Info", _create_mbox_cal0);
@@ -365,6 +377,14 @@ static lv_res_t _create_window_fuses_info_status(lv_obj_t *btn)
lv_label_set_recolor(lb_desc, true); lv_label_set_recolor(lb_desc, true);
lv_label_set_style(lb_desc, &monospace_text); lv_label_set_style(lb_desc, &monospace_text);
char version[32];
s_printf(version, "%s%d.%d.%d%c", NYX_VER_RL ? "v" : "", NYX_VER_MJ, NYX_VER_MN, NYX_VER_HF, NYX_VER_RL > 'A' ? NYX_VER_RL : 0);
lv_obj_t * lbl_ver = lv_label_create(lv_scr_act(), NULL);
lv_label_set_style(lbl_ver, &hint_small_style_white);
lv_label_set_text(lbl_ver, version);
lv_obj_align(lbl_ver, status_bar.bar_bg, LV_ALIGN_OUT_TOP_RIGHT, -LV_DPI * 9 / 23, -LV_DPI * 2 / 13);
hw_info_ver = lbl_ver;
lv_label_set_static_text(lb_desc, lv_label_set_static_text(lb_desc,
"#FF8000 SoC:#\n" "#FF8000 SoC:#\n"
"#FF8000 SKU:#\n" "#FF8000 SKU:#\n"
@@ -2551,7 +2571,7 @@ void create_tab_info(lv_theme_t *th, lv_obj_t *parent)
lv_btn_set_fit(btn3, true, true); lv_btn_set_fit(btn3, true, true);
lv_label_set_static_text(label_btn, SYMBOL_CIRCUIT" HW & Fuses"); lv_label_set_static_text(label_btn, SYMBOL_CIRCUIT" HW & Fuses");
lv_obj_align(btn3, line_sep, LV_ALIGN_OUT_BOTTOM_LEFT, LV_DPI / 4, LV_DPI / 2); lv_obj_align(btn3, line_sep, LV_ALIGN_OUT_BOTTOM_LEFT, LV_DPI / 4, LV_DPI / 2);
lv_btn_set_action(btn3, LV_BTN_ACTION_CLICK, _create_window_fuses_info_status); lv_btn_set_action(btn3, LV_BTN_ACTION_CLICK, _create_window_hw_info_status);
// Create KFuses button. // Create KFuses button.
lv_obj_t *btn4 = lv_btn_create(h1, btn); lv_obj_t *btn4 = lv_btn_create(h1, btn);