From 4068ac08a25997a88d76a949958d98ba445cdf8a Mon Sep 17 00:00:00 2001 From: lij <15178961907@163.com> Date: Fri, 23 Feb 2024 17:00:55 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=AD=90=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E6=A1=86=E6=9E=B6=E6=90=AD=E5=BB=BA=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MXC-A36/xrz/LittlevGL.cbp | 2 +- MXC-A36/xrz/LittlevGL.depend | 23 +- MXC-A36/xrz/LittlevGL.layout | 830 +++++++++--------- MXC-A36/xrz/lv_conf.h | 2 +- MXC-A36/xrz/lv_user_code/app/demo.c | 2 +- MXC-A36/xrz/lv_user_code/app/list.c | 35 +- MXC-A36/xrz/lv_user_code/app/mxc_meter.c | 9 +- MXC-A36/xrz/lv_user_code/app/setting_page.c | 506 ++++++++++- MXC-A36/xrz/lv_user_code/include/list.h | 20 +- MXC-A36/xrz/lv_user_code/include/mxc_meter.h | 4 + .../extra/themes/default/lv_theme_default.c | 1 + MXC-A36/xrz/main.c | 3 + 12 files changed, 966 insertions(+), 471 deletions(-) diff --git a/MXC-A36/xrz/LittlevGL.cbp b/MXC-A36/xrz/LittlevGL.cbp index f214ebc..2830a05 100644 --- a/MXC-A36/xrz/LittlevGL.cbp +++ b/MXC-A36/xrz/LittlevGL.cbp @@ -18,10 +18,10 @@ - + diff --git a/MXC-A36/xrz/LittlevGL.depend b/MXC-A36/xrz/LittlevGL.depend index 61c04e7..9c4c62f 100644 --- a/MXC-A36/xrz/LittlevGL.depend +++ b/MXC-A36/xrz/LittlevGL.depend @@ -49133,7 +49133,7 @@ 1659018602 f:\mxc-a36\mxc-a36\xrz\lv_drv_conf.h "lv_conf.h" -1703495808 f:\mxc-a36\mxc-a36\xrz\lv_conf.h +1708656955 f:\mxc-a36\mxc-a36\xrz\lv_conf.h 1659018602 f:\mxc-a36\mxc-a36\xrz\lvgl\lvgl.h @@ -49877,7 +49877,7 @@ 1703724644 f:\mxc-a36\mxc-a36\xrz\lv_user_code\include\demo.h -1708587909 source:f:\mxc-a36\mxc-a36\xrz\lv_user_code\app\demo.c +1708668769 source:f:\mxc-a36\mxc-a36\xrz\lv_user_code\app\demo.c "lvgl.h" "img_def.h" "demo.h" @@ -49893,9 +49893,9 @@ 1679997255 f:\mxc-a36\mxc-a36\xrz\lv_user_code\mode\spde_ipc.h -1708304786 f:\mxc-a36\mxc-a36\xrz\lv_user_code\include\mxc_meter.h +1708649481 f:\mxc-a36\mxc-a36\xrz\lv_user_code\include\mxc_meter.h -1708586743 source:f:\mxc-a36\mxc-a36\xrz\lv_user_code\app\list.c +1708669331 source:f:\mxc-a36\mxc-a36\xrz\lv_user_code\app\list.c "lvgl.h" "img_def.h" "demo.h" @@ -49905,10 +49905,10 @@ "lan_str_table.h" "equipment.h" -1708586772 f:\mxc-a36\mxc-a36\xrz\lv_user_code\include\list.h +1708668627 f:\mxc-a36\mxc-a36\xrz\lv_user_code\include\list.h "lan_str_table.h" -1707121619 source:f:\mxc-a36\mxc-a36\xrz\lv_user_code\app\mxc_meter.c +1708652399 source:f:\mxc-a36\mxc-a36\xrz\lv_user_code\app\mxc_meter.c "lvgl.h" "img_def.h" "mxc_meter.h" @@ -50208,7 +50208,7 @@ 1659018602 source:f:\mxc-a36\mxc-a36\xrz\lvgl\examples\scroll\lv_example_scroll_2.c "../lv_examples.h" -1659018602 source:f:\mxc-a36\mxc-a36\xrz\lvgl\examples\scroll\lv_example_scroll_3.c +1708590334 source:f:\mxc-a36\mxc-a36\xrz\lvgl\examples\scroll\lv_example_scroll_3.c "../lv_examples.h" 1659018602 source:f:\mxc-a36\mxc-a36\xrz\lvgl\examples\styles\lv_example_style_1.c @@ -50545,7 +50545,7 @@ "../misc/lv_gc.h" "../misc/lv_async.h" -1703488882 source:f:\mxc-a36\mxc-a36\xrz\lvgl\src\core\lv_refr.c +1708656678 source:f:\mxc-a36\mxc-a36\xrz\lvgl\src\core\lv_refr.c "lv_refr.h" "lv_disp.h" @@ -50677,7 +50677,7 @@ "lv_theme_basic.h" "../../../misc/lv_gc.h" -1659018602 source:f:\mxc-a36\mxc-a36\xrz\lvgl\src\extra\themes\default\lv_theme_default.c +1708659207 source:f:\mxc-a36\mxc-a36\xrz\lvgl\src\extra\themes\default\lv_theme_default.c "../../../lvgl.h" "lv_theme_default.h" "../../../misc/lv_gc.h" @@ -51217,7 +51217,7 @@ "../misc/lv_txt.h" "../misc/lv_math.h" -1707122330 source:f:\mxc-a36\mxc-a36\xrz\main.c +1708678650 source:f:\mxc-a36\mxc-a36\xrz\main.c "lvgl/lvgl.h" @@ -51246,13 +51246,14 @@ 1708581072 f:\mxc-a36\mxc-a36\xrz\lv_user_code\include\equipment.h "lan_str_table.h" -1708587185 source:f:\mxc-a36\mxc-a36\xrz\lv_user_code\app\setting_page.c +1708673227 source:f:\mxc-a36\mxc-a36\xrz\lv_user_code\app\setting_page.c "lvgl.h" "img_def.h" "demo.h" "mxc_meter.h" "list.h" "language_table.h" + "img_basic.h" "lan_str_table.h" 1708325538 f:\mxc-a36\mxc-a36\xrz\lv_user_code\app\list.h diff --git a/MXC-A36/xrz/LittlevGL.layout b/MXC-A36/xrz/LittlevGL.layout index 6b03cb3..43e3b84 100644 --- a/MXC-A36/xrz/LittlevGL.layout +++ b/MXC-A36/xrz/LittlevGL.layout @@ -2,64 +2,14 @@ - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -67,9 +17,24 @@ - + - + + + + + + + + + + + + + + + + @@ -77,19 +42,54 @@ - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -97,29 +97,319 @@ - + - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -139,184 +429,9 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -324,89 +439,29 @@ - + - + - + - + - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -414,54 +469,14 @@ - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -469,69 +484,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/MXC-A36/xrz/lv_conf.h b/MXC-A36/xrz/lv_conf.h index f3970dd..75ec094 100644 --- a/MXC-A36/xrz/lv_conf.h +++ b/MXC-A36/xrz/lv_conf.h @@ -188,7 +188,7 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/ *-----------*/ /*1: Show CPU usage and FPS count in the right bottom corner*/ -#define LV_USE_PERF_MONITOR 1 +#define LV_USE_PERF_MONITOR 0 /*1: Show the used memory and the memory fragmentation in the left bottom corner * Requires LV_MEM_CUSTOM = 0*/ diff --git a/MXC-A36/xrz/lv_user_code/app/demo.c b/MXC-A36/xrz/lv_user_code/app/demo.c index e916110..29ed971 100644 --- a/MXC-A36/xrz/lv_user_code/app/demo.c +++ b/MXC-A36/xrz/lv_user_code/app/demo.c @@ -248,7 +248,7 @@ static void demo_win_event_handle(lv_event_t *e) switch (key_code) { - case LV_KEY_ENTER: + case LV_KEY_W: // printf("LV_KEY_ENTER.\n"); // close_time_refresh_timer(); close_ui_refresh_timer(); diff --git a/MXC-A36/xrz/lv_user_code/app/list.c b/MXC-A36/xrz/lv_user_code/app/list.c index 61f27b5..80c667f 100644 --- a/MXC-A36/xrz/lv_user_code/app/list.c +++ b/MXC-A36/xrz/lv_user_code/app/list.c @@ -7,8 +7,8 @@ #include "lan_str_table.h" #include "equipment.h" -#define LV_KEY_Q 113 -#define LV_KEY_W 119 +//#define LV_KEY_Q 113 +//#define LV_KEY_W 119 char *list_title[16] = {"主题","亮度","蓝牙","其他\n设置","车辆\n信息","返回","1","2","3","4","5","6","7","8","9","10","11","12"}; char *theme_title[16] = {"主题\n设置","主题\n背景","返回","1","2","3","4","5","6","7","8","9","10","11","12"}; @@ -132,7 +132,8 @@ void enter_mainmenu_win(lv_obj_t *parent) lv_obj_set_style_pad_all(mainmenu_win, 0, 0); lv_obj_set_style_radius(mainmenu_win, 0, 0); lv_obj_set_style_border_width(mainmenu_win, 0, LV_PART_MAIN); - lv_obj_set_style_border_color(mainmenu_win, lv_color_black(), 0); +// lv_obj_set_style_border_color(mainmenu_win, lv_color_black(), 0); + lv_obj_set_style_bg_color(mainmenu_win, lv_color_hex(0x5E5E5E), NULL); lv_obj_clear_flag(mainmenu_win, LV_OBJ_FLAG_SCROLLABLE); lv_obj_t *demo_group = get_key_group(); @@ -151,7 +152,8 @@ void enter_mainmenu_win(lv_obj_t *parent) lv_obj_set_style_radius(mainmenu_tile_win, 0, 0); lv_obj_set_style_pad_all(mainmenu_tile_win, 0, 0); lv_obj_set_style_border_width(mainmenu_tile_win, 0, LV_PART_MAIN); - lv_obj_set_style_border_color(mainmenu_tile_win, lv_color_black(), 0); +// lv_obj_set_style_border_color(mainmenu_tile_win, lv_color_black(), 0); + lv_obj_set_style_bg_color(mainmenu_tile_win, lv_color_hex(0x5E5E5E), NULL); uint32_t page_num = 3; // sum of mainmenu pages uint32_t tile_item_count = 3; // number of items per page @@ -176,9 +178,9 @@ void enter_mainmenu_win(lv_obj_t *parent) mainmenu_tile[i].window_obj = lv_tileview_add_tile(mainmenu_tile_win, mainmenu_tile[i].col_id, mainmenu_tile[i].row_id, mainmenu_tile[i].dir); if (i == cal_check_page) - ((mainmenu_tile_t *)&mainmenu_tile[i])->Init(mainmenu_tile[i].window_obj, dis_item_arr[i], i, tile_item_count, list_str); + ((mainmenu_tile_t *)&mainmenu_tile[i])->Init(mainmenu_tile[i].window_obj, dis_item_arr[i], i, tile_item_count); else - ((mainmenu_tile_t *)&mainmenu_tile[i])->Init(mainmenu_tile[i].window_obj, dis_item_arr[i], i, tile_item_count, list_str); + ((mainmenu_tile_t *)&mainmenu_tile[i])->Init(mainmenu_tile[i].window_obj, dis_item_arr[i], i, tile_item_count); } @@ -227,23 +229,10 @@ static void key_event_handler(lv_event_t *e) page_count = (uint32_t)lv_obj_get_child_id(mainmenu_btn_win); // get display tile index check = lv_obj_get_child_cnt(mainmenu_btn_win) > 1 ? true : false; -// printf("key_code = %d .\n",key_code); switch (key_code) { -// case LV_KEY_HOME: -// printf("page_count = %d \n",page_count); -// if(page_count==2) -// page_count =0; -// else -// page_count++; -// lv_obj_t *tile_display = lv_obj_get_child(mainmenu_tile_win, page_count); -// lv_obj_set_tile(mainmenu_tile_win, tile_display, LV_ANIM_ON); -// break; case LV_KEY_Q: lv_obj_clear_state(mainmenu_button_cur, LV_STATE_FOCUS_KEY); -// if(btn_totalnum >btn_count+1+page_count*3){ -// printf("1---------count = %d.\n",btn_count+1+page_count*3); -// } if(btn_totalnum ==btn_count+1+page_count*3){//最后一个按钮 printf("2---------count = %d.\n",btn_count+1+page_count*3); page_count =0; @@ -257,8 +246,6 @@ static void key_event_handler(lv_event_t *e) break; } - - if(btn_count==2){ btn_count =0; page_count++; @@ -289,8 +276,7 @@ static void key_event_handler(lv_event_t *e) } } -//void init_tile_common(lv_obj_t *mainmenu_btn_win, uint8_t page_num, uint8_t cur_tile_item,char *list_title[]) -void init_tile_common(lv_obj_t *mainmenu_btn_win, uint32_t str_arr[], uint8_t page_num, uint8_t cur_tile_item,LAN_STR_ID list_str[]) +void init_tile_common(lv_obj_t *mainmenu_btn_win, uint32_t str_arr[], uint8_t page_num, uint8_t cur_tile_item) { printf("page_num = %d, cur_tile_item = %d\n",page_num,cur_tile_item); @@ -313,6 +299,7 @@ void init_tile_common(lv_obj_t *mainmenu_btn_win, uint32_t str_arr[], uint8_t pa for (uint8_t i = 0; i < cur_tile_item; i++) { lv_obj_t *imgbtn = lv_btn_create(mainmenu_btn_win); + lv_obj_set_style_bg_opa(imgbtn, LV_OPA_0, 0); uint32_t child_id = lv_obj_get_child_id(imgbtn); switch (child_id) @@ -335,7 +322,6 @@ void init_tile_common(lv_obj_t *mainmenu_btn_win, uint32_t str_arr[], uint8_t pa lv_obj_set_pos(imgbtn, x1, y1); LAN_STR_ID str_id = (LAN_STR_ID)str_arr[i]; -// uint8_t curItemState = getCurItemStateByStrid(str_id); ENUM_EQUIPMENT_ID cur_menu_id = get_menu_iconid_by_strid(str_id); if (cur_menu_id == MAINMENU_ICON_ID_MAX) continue; @@ -346,7 +332,6 @@ void init_tile_common(lv_obj_t *mainmenu_btn_win, uint32_t str_arr[], uint8_t pa } lv_obj_t * label = lv_label_create(imgbtn); -// lv_label_set_text_fmt(label, "%s",lan_str_table[list_str[i+page_num*3]][1]); const LAN_STR_ID Str_id = get_equipment_is_str(cur_menu_id); lv_label_set_text_fmt(label, "%s",lan_str_table[Str_id][1]); lv_obj_center(label); diff --git a/MXC-A36/xrz/lv_user_code/app/mxc_meter.c b/MXC-A36/xrz/lv_user_code/app/mxc_meter.c index c5d1602..add1e66 100644 --- a/MXC-A36/xrz/lv_user_code/app/mxc_meter.c +++ b/MXC-A36/xrz/lv_user_code/app/mxc_meter.c @@ -40,6 +40,11 @@ void Set_UI_page_id(ENUM_CONTROL_WIN_ID id) daily_get_UiData()->ui_page_id = id; } +ENUM_CONTROL_WIN_ID Get_UI_page_id(void) +{ + return daily_get_UiData()->ui_page_id; +} + lv_coord_t get_child_id() { return child_id; @@ -117,7 +122,7 @@ void app_menu_comm_entry(lv_obj_t * obj, ENUM_CONTROL_WIN_ID win_id, bool regis // } } -//ݳʼ +//���ݳ�ʼ�� void system_date_init(void){ custom_data.softwar_host = 0; @@ -143,7 +148,7 @@ void system_date_init(void){ custom_data.return_demo = 0; - //ٶ ת + //�ٶ� ת�� custom_data.velocity = 0; custom_data.veer_velocity = 0; custom_data.grade = 0; diff --git a/MXC-A36/xrz/lv_user_code/app/setting_page.c b/MXC-A36/xrz/lv_user_code/app/setting_page.c index 8aef800..db84f23 100644 --- a/MXC-A36/xrz/lv_user_code/app/setting_page.c +++ b/MXC-A36/xrz/lv_user_code/app/setting_page.c @@ -4,11 +4,14 @@ #include "mxc_meter.h" #include "list.h" #include "language_table.h" +#include "img_basic.h" #include "lan_str_table.h" -void theme_create(lv_obj_t *obj) -{ - printf("enter theme_create\n"); +#define PAGEBTN_COUNT1 1 //bt switching +#define PAGEBTN_COUNT2 2 //theme setting +#define PAGEBTN_COUNT3 3 //other setting + +lv_obj_t * src_win(){ lv_obj_t * scr_parent_main = get_root_win(); lv_obj_t * submenu_win = lv_obj_create(scr_parent_main); @@ -18,41 +21,524 @@ void theme_create(lv_obj_t *obj) lv_obj_set_style_radius(submenu_win, 0, 0); lv_obj_set_style_border_width(submenu_win, 0, LV_PART_MAIN); lv_obj_set_style_border_color(submenu_win, lv_color_black(), 0); +// lv_obj_set_style_bg_color(submenu_win, lv_color_black(), 0); + lv_obj_set_style_bg_color(submenu_win, lv_color_hex(0x5E5E5E), NULL); lv_obj_clear_flag(submenu_win, LV_OBJ_FLAG_SCROLLABLE); + return submenu_win; +} + +static void key_event_handler(lv_event_t *e) +{ + lv_event_code_t code = lv_event_get_code(e); + + lv_obj_t *btn_win = lv_event_get_target(e); +// lv_obj_t *btn = lv_obj_get_child(mainmenu_win, 0); + + if (code == LV_EVENT_KEY) + { + + uint32_t *key = lv_event_get_param(e); + uint8_t key_code = (uint8_t)*key; + +// uint32_t page_count = 0; // display tile index + uint32_t btn_num = 0; // checked item index +// uint32_t page_num = 0; // sum of mainmenu pages +// uint32_t last_item_pos = 0; // last item index of his page +// uint32_t dis_item_arr[MAINMENU_TILE_END][COMMON_PER_PAGE_NUM]; +// memset(dis_item_arr, 0, sizeof(dis_item_arr)); +// uint32_t btn_totalnum = mainmenu_item_process(dis_item_arr, &page_num, &last_item_pos); +// +// bool check = false; +// MAINMENU_ICON_ID_ENUM menu_id = MAINMENU_ICON_ID_MAX; +// ENUM_MAINMENU_ITEM_ID item_id = MAINMENU_ITEM_ID_MAX; +// uint8_t curItemState = 0; + + uint8_t win_child_num = lv_obj_get_child_cnt(btn_win); + // get focus item index + for (uint32_t i = 0; i < win_child_num; i++) + { + lv_obj_t *child = lv_obj_get_child(btn_win, i); + if (lv_obj_has_state(child, LV_STATE_FOCUS_KEY)) + btn_num = i; + } + + lv_obj_t *button_cur = lv_obj_get_child(btn_win, btn_num); // get checked item obj + + switch (key_code) + { + case LV_KEY_Q: + printf("LV_KEY_Q ===>btn_num = %d .\n",btn_num); + lv_obj_clear_state(button_cur, LV_STATE_FOCUS_KEY); + btn_num++; + if(btn_num == win_child_num) + btn_num=0; + lv_obj_t *button_next = lv_obj_get_child(btn_win, btn_num); // get checked item obj + lv_obj_add_state(button_next, LV_STATE_FOCUS_KEY); + if(btn_num == win_child_num-1){ + lv_obj_set_style_bg_opa(button_next, LV_OPA_100, 0); + }else{ + lv_obj_t *button_next = lv_obj_get_child(btn_win, win_child_num-1); + lv_obj_set_style_bg_opa(button_next, LV_OPA_0, 0); + } + break; + case LV_KEY_W: + switch(Get_UI_page_id()){ + case SUBMENU_SET_THEME: + if(btn_num == 0){ + printf("ENTER theme select .\n"); + close_all_win(); + theme_select_create(); + }else if(btn_num == 1){ + printf("ENTER theme bg seletc .\n"); + close_all_win(); + theme_bg_create(); + }else{ + printf("RETURN list .\n"); + close_all_win(); + enter_mainmenu_win(get_root_win()); + } + break; + case SUBMENU_SET_LIGHT: + if(btn_num == 0){ + printf("ENTER light select .\n"); + + }else{ + printf("RETURN list .\n"); + close_all_win(); + enter_mainmenu_win(get_root_win()); + } + break; + case SUBMENU_SET_BLUETOOTH: + if(btn_num == 0){ + printf("ENTER bt switch .\n"); + }else{ + printf("RETURN list .\n"); + close_all_win(); + enter_mainmenu_win(get_root_win()); + } + break; + case SUBMENU_SET_OTHER: + if(btn_num == 0){ + printf("ENTER time setting.\n"); + }else if(btn_num == 1){ + printf("ENTER langguage setting .\n"); + }else if(btn_num == 2){ + printf("ENTER unit setting .\n"); + }else{ + printf("RETURN list .\n"); + close_all_win(); + enter_mainmenu_win(get_root_win()); + } + break; + case SUBMENU_SET_INFORMATION: + printf("INFORMATION RETURN list .\n"); + close_all_win(); + enter_mainmenu_win(get_root_win()); + break; + case SUBMENU_SET_PRESSURE: + if(btn_num == 0){ +// printf("Front tire pressure .\n"); +// }else if(btn_num == 1){ +// printf("Rear tire pressure .\n"); +// }else{ + printf("RETURN list .\n"); + close_all_win(); + enter_mainmenu_win(get_root_win()); + } + break; + case SUBMENU_SET_FAULT_CODE: + printf("FAULT_CODE RETURN list .\n"); + close_all_win(); + enter_mainmenu_win(get_root_win()); + break; + case SUBMENU_THEME_SELECT: + if(btn_num == 0){ + printf("THEME_SELECT 1.\n"); + }else if(btn_num == 1){ + printf("THEME_SELECT 2 .\n"); + }else if(btn_num == 2){ + printf("THEME_SELECT 3 .\n"); + }else{ + printf("RETURN theme .\n"); + } + close_all_win(); + theme_create(); + break; + case SUBMENU_THEME_BG: + if(btn_num == 0){ + printf("THEME_BG 1.\n"); + }else if(btn_num == 1){ + printf("THEME_BG 2 .\n"); + }else if(btn_num == 2){ + printf("THEME_BG 3 .\n"); + }else{ + printf("RETURN theme .\n"); + } + close_all_win(); + theme_create(); + break; + default: + break; + } + break; + default: + break; + } + } +} + +static void batch_btn_creat(lv_obj_t *btn_win ,int win_btn_count){ + for(uint8_t i=0;i",i); + lv_obj_align(label, LV_ALIGN_LEFT_MID, 0, 0); + + if(i==0){ + lv_obj_add_state(btn, LV_STATE_FOCUS_KEY); + lv_obj_align(btn, LV_ALIGN_TOP_MID, -10, -5); + if(win_btn_count==PAGEBTN_COUNT2) + lv_obj_align(btn, LV_ALIGN_TOP_MID, -10, 30); + } + else{ + lv_obj_t * back_btn = lv_obj_get_child(btn_win, i-1); + lv_obj_align_to(btn,back_btn, LV_ALIGN_OUT_BOTTOM_MID, 0, 10); + } + } } -void light_create(lv_obj_t *obj) +static void batch_return_btn(lv_obj_t *btn_win ){ + lv_obj_t * return_btn = lv_btn_create(btn_win); + lv_obj_set_size(return_btn, 90, 50); + lv_obj_set_style_bg_color(return_btn, lv_color_hex(0x02BC2E), NULL); + lv_obj_set_style_bg_opa(return_btn, LV_OPA_0, 0); + lv_obj_align(return_btn, LV_ALIGN_BOTTOM_RIGHT, 0, 0); + lv_obj_t * return_label = lv_label_create(return_btn); + lv_obj_set_style_text_font(return_label,LV_FONT_MXC_WRYH_CT_16PX,0); + lv_label_set_text(return_label, "return"); + lv_obj_align(return_label, LV_ALIGN_LEFT_MID, 0, 0); + +} + +void theme_create() +{ + printf("enter theme_create\n"); + + lv_obj_t * submenu_win = src_win(); + + lv_obj_t * btn_win = lv_obj_create(submenu_win); + lv_obj_set_scrollbar_mode(btn_win, LV_SCROLLBAR_MODE_OFF); + lv_obj_set_size(btn_win, LV_PCT(100), LV_PCT(100)); + lv_obj_align(btn_win, LV_ALIGN_RIGHT_MID, 0, 0); + lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_SCROLLABLE ); + lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_SCROLL_ELASTIC); + lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_GESTURE_BUBBLE); + lv_obj_set_style_bg_color(btn_win, lv_color_hex(0x5E5E5E), NULL); + lv_obj_set_style_border_width(btn_win, 0, LV_PART_MAIN); + + batch_btn_creat(btn_win,PAGEBTN_COUNT2); + + batch_return_btn(btn_win); + + app_menu_comm_entry(btn_win, SUBMENU_SET_THEME, false); + //按键组 + lv_obj_t *demo_group = get_key_group(); + lv_group_add_obj(demo_group, btn_win); + lv_obj_add_event_cb(btn_win, key_event_handler, LV_EVENT_KEY, NULL); + +} + +void theme_select_create(){ + printf("enter theme_select_create\n"); + + lv_obj_t * submenu_win = src_win(); + + lv_obj_t * btn_win = lv_obj_create(submenu_win); + lv_obj_set_scrollbar_mode(btn_win, LV_SCROLLBAR_MODE_OFF); + lv_obj_set_size(btn_win, LV_PCT(100), LV_PCT(100)); + lv_obj_align(btn_win, LV_ALIGN_RIGHT_MID, 0, 0); + lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_SCROLLABLE ); + lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_SCROLL_ELASTIC); + lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_GESTURE_BUBBLE); + lv_obj_set_style_bg_color(btn_win, lv_color_hex(0x5E5E5E), NULL); + lv_obj_set_style_border_width(btn_win, 0, LV_PART_MAIN); + + lv_obj_t * btn = lv_btn_create(btn_win); + lv_obj_set_size(btn, 150, 100); + lv_obj_set_style_bg_opa(btn, LV_OPA_0, 0); + lv_obj_t * label = lv_label_create(btn); + lv_label_set_text(label, "SELECT1"); + lv_obj_align(label, LV_ALIGN_LEFT_MID, 0, 0); + lv_obj_add_state(btn, LV_STATE_FOCUS_KEY); + lv_obj_align(btn, LV_ALIGN_TOP_LEFT, 30, 10); + + lv_obj_t * btn2 = lv_btn_create(btn_win); + lv_obj_set_size(btn2, 150, 100); + lv_obj_set_style_bg_opa(btn2, LV_OPA_0, 0); + lv_obj_t * label2 = lv_label_create(btn2); + lv_label_set_text(label2, "SELECT2"); + lv_obj_align(label2, LV_ALIGN_LEFT_MID, 0, 0); + lv_obj_align(btn2, LV_ALIGN_TOP_RIGHT, -30, 10); + + lv_obj_t * btn3 = lv_btn_create(btn_win); + lv_obj_set_size(btn3, 150, 100); + lv_obj_set_style_bg_opa(btn3, LV_OPA_0, 0); + lv_obj_t * label3 = lv_label_create(btn3); + lv_label_set_text(label3, "SELECT3"); + lv_obj_align(label3, LV_ALIGN_LEFT_MID, 0, 0); + lv_obj_align(btn3, LV_ALIGN_CENTER, 0, 60); + + batch_return_btn(btn_win); + + app_menu_comm_entry(btn_win, SUBMENU_THEME_SELECT, false); + //按键组 + lv_obj_t *demo_group = get_key_group(); + lv_group_add_obj(demo_group, btn_win); + lv_obj_add_event_cb(btn_win, key_event_handler, LV_EVENT_KEY, NULL); + +} + +void theme_bg_create(){ + printf("enter theme_bg_create\n"); + + lv_obj_t * submenu_win = src_win(); + + + lv_obj_t * btn_win = lv_obj_create(submenu_win); + lv_obj_set_scrollbar_mode(btn_win, LV_SCROLLBAR_MODE_OFF); + lv_obj_set_size(btn_win, LV_PCT(100), LV_PCT(100)); + lv_obj_align(btn_win, LV_ALIGN_RIGHT_MID, 0, 0); + lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_SCROLLABLE ); + lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_SCROLL_ELASTIC); + lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_GESTURE_BUBBLE); + lv_obj_set_style_bg_color(btn_win, lv_color_hex(0x5E5E5E), NULL); + lv_obj_set_style_border_width(btn_win, 0, LV_PART_MAIN); + + lv_obj_t * btn = lv_btn_create(btn_win); + lv_obj_set_size(btn, 150, 100); + lv_obj_set_style_bg_opa(btn, LV_OPA_0, 0); + lv_obj_t * label = lv_label_create(btn); + lv_label_set_text(label, "SELECT1"); + lv_obj_align(label, LV_ALIGN_LEFT_MID, 0, 0); + lv_obj_add_state(btn, LV_STATE_FOCUS_KEY); + lv_obj_align(btn, LV_ALIGN_TOP_LEFT, 30, 10); + + lv_obj_t * btn2 = lv_btn_create(btn_win); + lv_obj_set_size(btn2, 150, 100); + lv_obj_set_style_bg_opa(btn2, LV_OPA_0, 0); + lv_obj_t * label2 = lv_label_create(btn2); + lv_label_set_text(label2, "SELECT2"); + lv_obj_align(label2, LV_ALIGN_LEFT_MID, 0, 0); + lv_obj_align(btn2, LV_ALIGN_TOP_RIGHT, -30, 10); + + lv_obj_t * btn3 = lv_btn_create(btn_win); + lv_obj_set_size(btn3, 150, 100); + lv_obj_set_style_bg_opa(btn3, LV_OPA_0, 0); + lv_obj_t * label3 = lv_label_create(btn3); + lv_label_set_text(label3, "SELECT3"); + lv_obj_align(label3, LV_ALIGN_LEFT_MID, 0, 0); + lv_obj_align(btn3, LV_ALIGN_CENTER, 0, 60); + + batch_return_btn(btn_win); + + + app_menu_comm_entry(btn_win, SUBMENU_THEME_BG, false); + //按键组 + lv_obj_t *demo_group = get_key_group(); + lv_group_add_obj(demo_group, btn_win); + lv_obj_add_event_cb(btn_win, key_event_handler, LV_EVENT_KEY, NULL); + +} + +void light_create() { printf("enter light_create\n"); + + lv_obj_t * submenu_win = src_win(); + + lv_obj_t * btn_win = lv_obj_create(submenu_win); + lv_obj_set_scrollbar_mode(btn_win, LV_SCROLLBAR_MODE_OFF); + lv_obj_set_size(btn_win, LV_PCT(100), LV_PCT(100)); + lv_obj_align(btn_win, LV_ALIGN_RIGHT_MID, 0, 0); + lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_SCROLLABLE ); + lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_SCROLL_ELASTIC); + lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_GESTURE_BUBBLE); + lv_obj_set_style_bg_color(btn_win, lv_color_hex(0x5E5E5E), NULL); + lv_obj_set_style_border_width(btn_win, 0, LV_PART_MAIN); + + lv_obj_t * btn = lv_btn_create(btn_win); + lv_obj_set_size(btn, 300, 150); + lv_obj_set_style_bg_opa(btn, LV_OPA_0, 0); + lv_obj_t * label = lv_label_create(btn); + lv_label_set_text(label, "SELECT1"); + lv_obj_align(label, LV_ALIGN_BOTTOM_MID, 0, 10); + lv_obj_add_state(btn, LV_STATE_FOCUS_KEY); + lv_obj_align(btn, LV_ALIGN_CENTER, 0, -10); + + batch_return_btn(btn_win); + + + app_menu_comm_entry(btn_win, SUBMENU_SET_LIGHT, false); + //按键组 + lv_obj_t *demo_group = get_key_group(); + lv_group_add_obj(demo_group, btn_win); + lv_obj_add_event_cb(btn_win, key_event_handler, LV_EVENT_KEY, NULL); } -void bluetooth_create(lv_obj_t *obj) +void bluetooth_create() { printf("enter bluetooth_create\n"); + + lv_obj_t * submenu_win = src_win(); + + lv_obj_t * btn_win = lv_obj_create(submenu_win); + lv_obj_set_scrollbar_mode(btn_win, LV_SCROLLBAR_MODE_OFF); + lv_obj_set_size(btn_win, LV_PCT(100), LV_PCT(100)); + lv_obj_align(btn_win, LV_ALIGN_RIGHT_MID, 0, 0); + lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_SCROLLABLE ); + lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_SCROLL_ELASTIC); + lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_GESTURE_BUBBLE); + lv_obj_set_style_bg_color(btn_win, lv_color_hex(0x5E5E5E), NULL); + lv_obj_set_style_border_width(btn_win, 0, LV_PART_MAIN); + + lv_obj_t * btn = lv_btn_create(btn_win); + lv_obj_set_size(btn, 220, 70); + lv_obj_set_style_bg_opa(btn, LV_OPA_0, 0); + + lv_obj_t * bt_switch = lv_switch_create(btn); + lv_obj_align(bt_switch, LV_ALIGN_RIGHT_MID, 0, 0); + + lv_obj_t * label = lv_label_create(btn); + lv_label_set_text(label, "BT"); + lv_obj_align(label, LV_ALIGN_LEFT_MID, 0, 0); + + lv_obj_add_state(btn, LV_STATE_FOCUS_KEY); + lv_obj_align(btn, LV_ALIGN_CENTER, 0, -10); + + batch_return_btn(btn_win); + + app_menu_comm_entry(btn_win, SUBMENU_SET_BLUETOOTH, false); + //按键组 + lv_obj_t *demo_group = get_key_group(); + lv_group_add_obj(demo_group, btn_win); + lv_obj_add_event_cb(btn_win, key_event_handler, LV_EVENT_KEY, NULL); } -void other_create(lv_obj_t *obj) +void other_create() { printf("enter other_create\n"); + + lv_obj_t * submenu_win = src_win(); + + lv_obj_t * btn_win = lv_obj_create(submenu_win); + lv_obj_set_scrollbar_mode(btn_win, LV_SCROLLBAR_MODE_OFF); + lv_obj_set_size(btn_win, LV_PCT(100), LV_PCT(100)); + lv_obj_align(btn_win, LV_ALIGN_RIGHT_MID, 0, 0); + lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_SCROLLABLE ); + lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_SCROLL_ELASTIC); + lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_GESTURE_BUBBLE); + lv_obj_set_style_bg_color(btn_win, lv_color_hex(0x5E5E5E), NULL); + lv_obj_set_style_border_width(btn_win, 0, LV_PART_MAIN); + + batch_btn_creat(btn_win,PAGEBTN_COUNT3); + + lv_obj_t *child = lv_obj_get_child(btn_win, 1); + lv_obj_t *child_label = lv_obj_get_child(child, 0); + lv_label_set_text_fmt(child_label, "Language"); + + child = lv_obj_get_child(btn_win, 2); + child_label = lv_obj_get_child(child, 0); + lv_label_set_text_fmt(child_label, "unit"); + + batch_return_btn(btn_win); + + app_menu_comm_entry(btn_win, SUBMENU_SET_OTHER, false); + //按键组 + lv_obj_t *demo_group = get_key_group(); + lv_group_add_obj(demo_group, btn_win); + lv_obj_add_event_cb(btn_win, key_event_handler, LV_EVENT_KEY, NULL); + } -void information_create(lv_obj_t *obj) +void information_create() { printf("enter information_create\n"); + lv_obj_t * submenu_win = src_win(); + + lv_obj_t * btn_win = lv_obj_create(submenu_win); + lv_obj_set_scrollbar_mode(btn_win, LV_SCROLLBAR_MODE_OFF); + lv_obj_set_size(btn_win, LV_PCT(100), LV_PCT(100)); + lv_obj_align(btn_win, LV_ALIGN_RIGHT_MID, 0, 0); + lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_SCROLLABLE ); + lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_SCROLL_ELASTIC); + lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_GESTURE_BUBBLE); + lv_obj_set_style_bg_color(btn_win, lv_color_hex(0x5E5E5E), NULL); + lv_obj_set_style_border_width(btn_win, 0, LV_PART_MAIN); + + batch_return_btn(btn_win); + + app_menu_comm_entry(btn_win, SUBMENU_SET_INFORMATION, false); + //按键组 + lv_obj_t *demo_group = get_key_group(); + lv_group_add_obj(demo_group, btn_win); + lv_obj_add_event_cb(btn_win, key_event_handler, LV_EVENT_KEY, NULL); + + } -void pressure_create(lv_obj_t *obj) +void pressure_create() { printf("enter pressure_create\n"); + lv_obj_t * submenu_win = src_win(); + + lv_obj_t * btn_win = lv_obj_create(submenu_win); + lv_obj_set_scrollbar_mode(btn_win, LV_SCROLLBAR_MODE_OFF); + lv_obj_set_size(btn_win, LV_PCT(100), LV_PCT(100)); + lv_obj_align(btn_win, LV_ALIGN_RIGHT_MID, 0, 0); + lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_SCROLLABLE ); + lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_SCROLL_ELASTIC); + lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_GESTURE_BUBBLE); + lv_obj_set_style_bg_color(btn_win, lv_color_hex(0x5E5E5E), NULL); + lv_obj_set_style_border_width(btn_win, 0, LV_PART_MAIN); + + batch_return_btn(btn_win); + + app_menu_comm_entry(btn_win, SUBMENU_SET_PRESSURE, false); + //按键组 + lv_obj_t *demo_group = get_key_group(); + lv_group_add_obj(demo_group, btn_win); + lv_obj_add_event_cb(btn_win, key_event_handler, LV_EVENT_KEY, NULL); } -void fault_code_create(lv_obj_t *obj) +void fault_code_create() { printf("enter fault_code_create\n"); + lv_obj_t * submenu_win = src_win(); + + lv_obj_t * btn_win = lv_obj_create(submenu_win); + lv_obj_set_scrollbar_mode(btn_win, LV_SCROLLBAR_MODE_OFF); + lv_obj_set_size(btn_win, LV_PCT(100), LV_PCT(100)); + lv_obj_align(btn_win, LV_ALIGN_RIGHT_MID, 0, 0); + lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_SCROLLABLE ); + lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_SCROLL_ELASTIC); + lv_obj_clear_flag(btn_win, LV_OBJ_FLAG_GESTURE_BUBBLE); + lv_obj_set_style_bg_color(btn_win, lv_color_hex(0x5E5E5E), NULL); + lv_obj_set_style_border_width(btn_win, 0, LV_PART_MAIN); + + batch_return_btn(btn_win); + + app_menu_comm_entry(btn_win, SUBMENU_SET_FAULT_CODE, false); + //按键组 + lv_obj_t *demo_group = get_key_group(); + lv_group_add_obj(demo_group, btn_win); + lv_obj_add_event_cb(btn_win, key_event_handler, LV_EVENT_KEY, NULL); } -void demo_return(lv_obj_t *obj) +void demo_return() { printf("enter demo_return\n"); lv_demo(get_root_win(),NULL); diff --git a/MXC-A36/xrz/lv_user_code/include/list.h b/MXC-A36/xrz/lv_user_code/include/list.h index 92ffd2e..98e5695 100644 --- a/MXC-A36/xrz/lv_user_code/include/list.h +++ b/MXC-A36/xrz/lv_user_code/include/list.h @@ -13,7 +13,7 @@ #define ICON_RING_2_X 105 #define ICON_RING_3_X 210 -#define ICON_IMG_Y 35+30 +#define ICON_IMG_Y 35+40 #define ICON_IMG_1_X 5+20+20 #define ICON_IMG_2_X 110+30+20+20+10 #define ICON_IMG_3_X 215+60+20+20+20 @@ -127,7 +127,7 @@ typedef struct _lv_mainmenu_icon_t // void init_tile_common(lv_obj_t *mainmenu_btn_win, uint8_t page_num, uint8_t cur_tile_item,char *list_title[]); // void init_tile_common(lv_obj_t *mainmenu_btn_win, uint8_t page_num, uint8_t cur_tile_item,LAN_STR_ID list_str[]); -void init_tile_common(lv_obj_t *mainmenu_btn_win, uint32_t str_arr[], uint8_t page_num, uint8_t cur_tile_item,LAN_STR_ID list_str[]); +void init_tile_common(lv_obj_t *mainmenu_btn_win, uint32_t str_arr[], uint8_t page_num, uint8_t cur_tile_item); static void key_event_handler(lv_event_t *e); uint32_t mainmenu_item_process(uint32_t dis_item_arr[MAINMENU_TILE_END][COMMON_PER_PAGE_NUM], uint32_t *page_num, uint32_t *last_item_pos); @@ -135,14 +135,14 @@ uint32_t mainmenu_item_process(uint32_t dis_item_arr[MAINMENU_TILE_END][COMMON_P void position_in_array(uint32_t res_arr[MAINMENU_TILE_END][COMMON_PER_PAGE_NUM], uint32_t res[2]); //ENUM_MAINMENU_ITEM_ID get_mainmenu_item_id_by_strid(ENUM_RES_STR_ID str_id); -extern void theme_create(lv_obj_t *obj); -extern void light_create(lv_obj_t *obj); -extern void bluetooth_create(lv_obj_t *obj); -extern void other_create(lv_obj_t *obj); -extern void information_create(lv_obj_t *obj); -extern void pressure_create(lv_obj_t *obj); -extern void fault_code_create(lv_obj_t *obj); -extern void demo_return(lv_obj_t *obj); +extern void theme_create(); +extern void light_create(); +extern void bluetooth_create(); +extern void other_create(); +extern void information_create(); +extern void pressure_create(); +extern void fault_code_create(); +extern void demo_return(); #endif diff --git a/MXC-A36/xrz/lv_user_code/include/mxc_meter.h b/MXC-A36/xrz/lv_user_code/include/mxc_meter.h index b301cda..30b2eee 100644 --- a/MXC-A36/xrz/lv_user_code/include/mxc_meter.h +++ b/MXC-A36/xrz/lv_user_code/include/mxc_meter.h @@ -3,6 +3,10 @@ typedef void (*btn_event_func)(lv_obj_t *obj); +#define LV_KEY_Q 113 +#define LV_KEY_W 119 + + typedef enum _ENUM_CONTROL_WIN_ID { IDLE_CONTROL_WIN_ID, // 0, diff --git a/MXC-A36/xrz/lvgl/src/extra/themes/default/lv_theme_default.c b/MXC-A36/xrz/lvgl/src/extra/themes/default/lv_theme_default.c index 056c865..68fcee1 100644 --- a/MXC-A36/xrz/lvgl/src/extra/themes/default/lv_theme_default.c +++ b/MXC-A36/xrz/lvgl/src/extra/themes/default/lv_theme_default.c @@ -259,6 +259,7 @@ static void style_init(void) style_init_reset(&styles->outline_primary); lv_style_set_outline_color(&styles->outline_primary, theme.color_primary); + lv_style_set_outline_color(&styles->outline_primary, lv_color_hex(0x00FF1E)); lv_style_set_outline_width(&styles->outline_primary, OUTLINE_WIDTH); lv_style_set_outline_pad(&styles->outline_primary, OUTLINE_WIDTH); lv_style_set_outline_opa(&styles->outline_primary, LV_OPA_50); diff --git a/MXC-A36/xrz/main.c b/MXC-A36/xrz/main.c index b502359..adb1dec 100644 --- a/MXC-A36/xrz/main.c +++ b/MXC-A36/xrz/main.c @@ -82,6 +82,9 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLi lv_port_indev_init(); moto_animo(); +// other_create(); +// theme_bg_create(); +// lv_example_scroll_3(); // lv_demo(get_root_win(),NULL);