800*320工程文件+初始demo提交

This commit is contained in:
2024-03-07 16:46:43 +08:00
parent 33e6eb45b3
commit 70ec3005bb
3306 changed files with 3374364 additions and 2563 deletions

View File

@ -1,9 +1,6 @@
#include "lvgl.h"
#include "img_def.h"
#include "demo.h"
#include "mxc_meter.h"
#include "list.h"
#include "language_table.h"
#include "img_basic.h"
#include "lan_str_table.h"
@ -41,7 +38,7 @@ static void WinKey_event_MainToGtor_handle(lv_event_t* e)
//close_ui_refresh_timer();
close_all_win();
//主界面进入到类型界面
Generator_SubUI_Gtor_src_win();
Generator_SubUI_Gtor_src_win(get_root_win());
break;
default:
break;
@ -72,7 +69,7 @@ static void WinKey_event_GtorToErr_handle(lv_event_t* e)
//close_ui_refresh_timer();
close_all_win();
//主界面进入到类型界面
Generator_SubUI_ERROR_src_win();
Generator_SubUI_ERROR_src_win(get_root_win());
break;
default:
break;
@ -104,7 +101,7 @@ static void WinKey_event_ErrToMain_handle(lv_event_t* e)
//close_ui_refresh_timer();
close_all_win();
//主界面进入到类型界面
Generator_src_win();
Generator_src_win(get_root_win());
break;
default:
break;
@ -113,9 +110,9 @@ static void WinKey_event_ErrToMain_handle(lv_event_t* e)
}
//获取主屏幕
lv_obj_t* Generator_src_win()
lv_obj_t* Generator_src_win(lv_obj_t * scr_parent_main)
{
lv_obj_t * scr_parent_main = get_root_win();
// lv_obj_t * scr_parent_main = get_root_win();
lv_obj_t * MainUI_win = lv_obj_create(scr_parent_main);
lv_obj_set_scrollbar_mode(MainUI_win, LV_SCROLLBAR_MODE_OFF); //关闭滑轮功能
@ -368,10 +365,10 @@ lv_obj_t* Generator_src_win()
}
lv_obj_t* Generator_SubUI_Gtor_src_win()
lv_obj_t* Generator_SubUI_Gtor_src_win(lv_obj_t * scr_parent_main)
{
//生成窗口对象
lv_obj_t* scr_parent_main = get_root_win();
// lv_obj_t* scr_parent_main = get_root_win();
lv_obj_t* pSubUI_Gtor_win = lv_obj_create(scr_parent_main);
//初始化窗口对象,配置窗口对象属性
@ -532,9 +529,9 @@ lv_obj_t* Generator_SubUI_Gtor_src_win()
}
lv_obj_t* Generator_SubUI_ERROR_src_win()
lv_obj_t* Generator_SubUI_ERROR_src_win(lv_obj_t * scr_parent_main)
{
lv_obj_t * scr_parent_main = get_root_win();
// lv_obj_t * scr_parent_main = get_root_win();
lv_obj_t* pSubUI_ERROR_win = lv_obj_create(scr_parent_main);
lv_obj_set_scrollbar_mode(pSubUI_ERROR_win, LV_SCROLLBAR_MODE_OFF); //关闭滑轮功能

View File

@ -2,7 +2,7 @@
#include "img_def.h"
#include "demo.h"
#include "mxc_meter.h"
#include "list.h"
#include "menu_list"
//#include "language_table.h"
#include "lan_str_table.h"
#include "equipment.h"

View File

@ -2,650 +2,7 @@
#include "img_def.h"
#include "demo.h"
#include "mxc_meter.h"
#include "list.h"
#include "menu_list"
#include "language_table.h"
#include "lan_str_table.h"
#include "equipment.h"
//#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"};
__attribute__((section("resource_section"))) static const lv_mainmenu_win_t mainmenu_page_group[MAINMENU_ITEM_ID_MAX] =
{
{MAINMENU_ITEM_ID_THEME, STR_ID_THEME, MAINMENU_ICON_ID_THEME, (void *)theme_create},
{MAINMENU_ITEM_ID_LIGHT, STR_ID_LIGHT, MAINMENU_ICON_ID_LIGHT, (void *)light_create},
{MAINMENU_ITEM_ID_BLUETOOTH, STR_ID_BLUETOOTH, MAINMENU_ICON_ID_BLUETOOTH, (void *)bluetooth_create},
{MAINMENU_ITEM_ID_OTHER, STR_ID_OTHER_SETTING, MAINMENU_ICON_ID_OTHER, (void *)other_create},
{MAINMENU_ITEM_ID_INFORMATION, STR_ID_INFORMATION, MAINMENU_ICON_ID_INFORMATION, (void *)information_create},
{MAINMENU_ITEM_ID_PRESSURE, STR_ID_PRESSURE, MAINMENU_ICON_ID_PRESSURE, (void *)pressure_create},
{MAINMENU_ITEM_ID_FAULT_CODE, STR_ID_FAULT_CODE, MAINMENU_ICON_ID_FAULT_CODE, (void *)fault_code_create},
{EQUIPMENT_ID_RETURN, STR_ID_RETURN, MAINMENU_ICON_ID_RETURN, (void *)demo_return},
};
const btn_event_func getDeviceEntryByStrId(const LAN_STR_ID str_id)
{
btn_event_func p_btn_func = NULL;
for (uint8_t i = MAINMENU_ITEM_ID_THEME; i < MAINMENU_ITEM_ID_MAX; i++)
{
// printf("mainmenu_page_group[i].str_id = %d ,str_id = %d ",mainmenu_page_group[i].str_id,str_id);
if (mainmenu_page_group[i].str_id == str_id)
{
p_btn_func = mainmenu_page_group[i].event_handler;
break;
}
}
if (p_btn_func != NULL)
{
p_btn_func(NULL);
}
else
{
LV_ASSERT(true);
}
return NULL;
}
ENUM_EQUIPMENT_ID get_menu_iconid_by_strid(const LAN_STR_ID str_id)
{
for (uint8_t i = EQUIPMENT_ID_THEME; i < EQUIPMENT_ID_MAX; i++)
{
if (mainmenu_page_group[i].str_id == str_id)
return mainmenu_page_group[i].mainmenu_icon_id;
}
return EQUIPMENT_ID_MAX;
}
LAN_STR_ID list_str[16] = {
STR_ID_THEME,
STR_ID_LIGHT,
STR_ID_BLUETOOTH,
STR_ID_OTHER_SETTING,
STR_ID_INFORMATION,
STR_ID_PRESSURE,
STR_ID_FAULT_CODE,
STR_ID_RETURN,
STR_ID_RETURN,
STR_ID_RETURN,
STR_ID_RETURN,
STR_ID_RETURN,
STR_ID_RETURN,
STR_ID_RETURN,
STR_ID_RETURN,
STR_ID_RETURN,
STR_ID_RETURN,
};
//lan_str_table[STR_ID_FOCUS_BREATHING][1]
mainmenu_tile_t mainmenu_tile[]=
{
[MAINMENU_TILE_ZERO] = {.window_obj = NULL, .col_id = 0, .row_id = 0, .dir = LV_DIR_HOR, .Init = init_tile_common}, // <20><><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD>
[MAINMENU_TILE_ONE] = {.window_obj = NULL, .col_id = 1, .row_id = 0, .dir = LV_DIR_HOR, .Init = init_tile_common},
[MAINMENU_TILE_TWO] = {.window_obj = NULL, .col_id = 2, .row_id = 0, .dir = LV_DIR_HOR, .Init = init_tile_common},
};
#if 0
LV_ATTRIBUTE_LARGE_CONST static const lv_img_dsc_t* test_list[4] =
{
IMG_DM1_OIL,
IMG_DM1_TCS,
IMG_DM1_TEMP,
IMG_DM1_NULL,
};
#endif
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)
{
uint32_t mainmenu_item_sum = 0;
// calculate how many devices need display
for (uint8_t i = EQUIPMENT_ID_THEME; i < EQUIPMENT_ID_MAX; i++)
{
if (get_equipment_is_display(i))
mainmenu_item_sum++;
}
//mainmenu_item_sum++; // add device manage item
// calculate page_num according to mainmenu_item_sum
*page_num = mainmenu_item_sum / COMMON_PER_PAGE_NUM;
if (mainmenu_item_sum % COMMON_PER_PAGE_NUM != 0)
(*page_num)++;
// Store the device str_id to be displayed into an array in order
*last_item_pos = mainmenu_item_sum % COMMON_PER_PAGE_NUM;
get_display_equipment_str(dis_item_arr);
*last_item_pos == 0 ? (dis_item_arr[(*page_num) - 1][COMMON_PER_PAGE_NUM - 1] = STR_ID_RETURN) : (dis_item_arr[(*page_num) - 1][(*last_item_pos) - 1] = STR_ID_RETURN);
return mainmenu_item_sum;
}
void enter_mainmenu_win(lv_obj_t *parent)
{
lv_obj_t *mainmenu_win = lv_obj_create(parent);
lv_obj_set_style_bg_color(mainmenu_win, lv_color_make(0x00, 0x00, 0x00), 0);
lv_obj_set_scrollbar_mode(mainmenu_win, LV_SCROLLBAR_MODE_OFF);
lv_obj_set_size(mainmenu_win, LV_PCT(100), LV_PCT(100));
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_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();
lv_group_add_obj(demo_group, mainmenu_win);
lv_obj_t *mainmenu_tile_win = lv_tileview_create(mainmenu_win);
lv_obj_set_style_bg_color(mainmenu_tile_win, lv_color_black(), 0);
lv_obj_clear_flag(mainmenu_tile_win, LV_OBJ_FLAG_SCROLLABLE);
lv_obj_clear_flag(mainmenu_tile_win, LV_OBJ_FLAG_EVENT_BUBBLE);
lv_obj_set_scrollbar_mode(mainmenu_tile_win, LV_SCROLLBAR_MODE_OFF);
lv_obj_set_scroll_dir(mainmenu_tile_win, LV_DIR_HOR);
lv_obj_clear_flag(mainmenu_tile_win, LV_OBJ_FLAG_SCROLL_ELASTIC);
lv_obj_add_flag(mainmenu_tile_win, LV_OBJ_FLAG_SCROLL_MOMENTUM);
lv_obj_add_flag(mainmenu_tile_win, LV_OBJ_FLAG_SCROLL_ONE);
lv_obj_set_size(mainmenu_tile_win, LV_PCT(100), LV_PCT(100));
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_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
uint32_t last_item_pos = 0;
uint8_t cal_check_page = 0;
// uint8_t cal_check_item = 0;
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);
printf("btn_totalnum = %d .\n",btn_totalnum);
printf("page_num = %d last_num = %d .\n",page_num,last_item_pos);
// Loop create tile
for (uint8_t i = MAINMENU_TILE_ZERO; i < page_num; i++)
{
// calculate number of items on the last page
if ((i == page_num - 1) && (last_item_pos))
tile_item_count = last_item_pos;
// add tile
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);
else
((mainmenu_tile_t *)&mainmenu_tile[i])->Init(mainmenu_tile[i].window_obj, dis_item_arr[i], i, tile_item_count);
}
lv_obj_set_tile_id(mainmenu_tile_win, mainmenu_tile[cal_check_page].col_id, mainmenu_tile[cal_check_page].row_id, LV_ANIM_ON);
lv_obj_add_event_cb(mainmenu_win, key_event_handler, LV_EVENT_KEY, NULL);
}
static void key_event_handler(lv_event_t *e)
{
lv_event_code_t code = lv_event_get_code(e);
lv_obj_t *mainmenu_win = lv_event_get_target(e);
lv_obj_t *mainmenu_tile_win = lv_obj_get_child(mainmenu_win, 0);
lv_obj_t *mainmenu_btn_win = lv_tileview_get_tile_act(mainmenu_tile_win); // get display tile
lv_obj_t *img_side = lv_obj_get_child(mainmenu_win, 1);
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_count = 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;
// get focus item index
for (uint32_t i = 0; i < lv_obj_get_child_cnt(mainmenu_btn_win); i++)
{
lv_obj_t *child = lv_obj_get_child(mainmenu_btn_win, i);
if (lv_obj_has_state(child, LV_STATE_FOCUS_KEY))
btn_count = i;
}
lv_obj_t *mainmenu_button_cur = lv_obj_get_child(mainmenu_btn_win, btn_count); // get checked item obj
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;
switch (key_code)
{
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("2---------count = %d.\n",btn_count+1+page_count*3);
page_count =0;
btn_count =0;
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);
mainmenu_btn_win = lv_tileview_get_tile_act(mainmenu_tile_win);
lv_obj_t *mainmenu_next_button = lv_obj_get_child(mainmenu_btn_win, btn_count);
lv_obj_add_state(mainmenu_next_button, LV_STATE_FOCUS_KEY);
printf("LV_KEY_Q page_count = %d ,btn_count = %d\n",page_count,btn_count);
break;
}
if(btn_count==2){
btn_count =0;
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);
}else
btn_count++;
mainmenu_btn_win = lv_tileview_get_tile_act(mainmenu_tile_win);
lv_obj_t *mainmenu_next_button = lv_obj_get_child(mainmenu_btn_win, btn_count);
lv_obj_add_state(mainmenu_next_button, LV_STATE_FOCUS_KEY);
printf("LV_KEY_Q page_count = %d ,btn_count = %d\n",page_count,btn_count);
break;
case LV_KEY_W:
printf("LV_KEY_W page_count = %d ,btn_count = %d,",page_count,btn_count);
printf("count = %d.\n",btn_count+1+page_count*3);
// ENUM_MAINMENU_ITEM_ID item_id = get_mainmenu_item_id_by_strid(dis_item_arr[page_count][btn_count]);
// Set_check_menu_item(item_id);
close_all_win();
SubmenuBtnEnter(get_root_win(), page_count, btn_count);
break;
default:
// printf("other key:%d\r\n", key_code);
break;
}
}
}
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);
lv_obj_t *mainmenu_tile_win = lv_obj_get_parent(mainmenu_btn_win);
lv_obj_t *mainmenu_win = lv_obj_get_parent(mainmenu_tile_win);
lv_obj_t *img_side = lv_obj_get_child(mainmenu_win, 1);
uint32_t x1 = 0, y1 = 0, x2 = 0, y2 = 0;
uint32_t page_id = lv_obj_get_child_id(mainmenu_btn_win);
lv_obj_set_style_pad_all(mainmenu_btn_win, 0, 0);
lv_obj_set_style_opa(mainmenu_btn_win, LV_OPA_100, 0);
lv_obj_set_scrollbar_mode(mainmenu_btn_win, LV_SCROLLBAR_MODE_ACTIVE);
lv_obj_clear_flag(mainmenu_btn_win, LV_OBJ_FLAG_SCROLL_ELASTIC);
lv_obj_set_size(mainmenu_btn_win, LV_PCT(100), LV_PCT(100));
lv_obj_set_style_radius(mainmenu_btn_win, 0, 0);
lv_obj_set_style_bg_color(mainmenu_btn_win, lv_color_hex(0x7000BB), 0);
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)
{
case 0:
x1 = ICON_IMG_1_X;
x2 = ICON_RING_1_X;
break;
case 1:
x1 = ICON_IMG_2_X;
x2 = ICON_RING_2_X;
break;
default:
x1 = ICON_IMG_3_X;
x2 = ICON_RING_3_X;
break;
}
y1 = ICON_IMG_Y;
lv_obj_set_size(imgbtn, MAINMENU_ICON_WIDTH_UNCHECK, MAINMENU_ICON_HEIGHT_UNCHECK);
lv_obj_set_pos(imgbtn, x1, y1);
LAN_STR_ID str_id = (LAN_STR_ID)str_arr[i];
ENUM_EQUIPMENT_ID cur_menu_id = get_menu_iconid_by_strid(str_id);
if (cur_menu_id == MAINMENU_ICON_ID_MAX)
continue;
if(page_id == 0 && i==0){
lv_obj_add_state(imgbtn, LV_STATE_FOCUS_KEY);
}
lv_obj_t * label = lv_label_create(imgbtn);
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);
}
lv_obj_clear_flag(mainmenu_btn_win, LV_OBJ_FLAG_SCROLL_ELASTIC);
lv_obj_clear_flag(mainmenu_btn_win, LV_OBJ_FLAG_GESTURE_BUBBLE);
}
ENUM_MAINMENU_ITEM_ID Get_menu_btn_item(uint32_t btn_count){
switch(btn_count){
case 0:
break;
case 1:
break;
case 2:
break;
default:
break;
}
return MAINMENU_ITEM_ID_MAX;
}
ENUM_MAINMENU_ITEM_ID Get_menu_item(uint32_t page_count ,uint32_t btn_count){
switch(page_count){
case 0:
break;
case 1:
break;
case 2:
break;
default:
break;
}
return MAINMENU_ITEM_ID_MAX;
}
void SubmenuBtnEnter(lv_obj_t * scr_parent_main , uint32_t page_count ,uint32_t btn_count)
{
uint8_t mainmenu_item_sum = 0;
uint8_t page_num = 0;
uint8_t tile_item_count = COMMON_PER_PAGE_NUM;
lv_obj_t *submenu_win = lv_obj_create(scr_parent_main);
lv_obj_set_scrollbar_mode(submenu_win, LV_SCROLLBAR_MODE_OFF);
lv_obj_set_size(submenu_win, LV_PCT(100), LV_PCT(100));
lv_obj_set_style_pad_all(submenu_win, 0, 0);
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_clear_flag(submenu_win, LV_OBJ_FLAG_SCROLLABLE);
// ENUM_MAINMENU_ITEM_ID page_type = Get_menu_item(page_count,btn_count);
// printf("SubmenuBtnEnter ====== page_count = %d ,btn_count = %d .page_type = %d\n",page_count,btn_count,page_type);
//
// uint32_t last_item_pos = mainmenu_item_sum % COMMON_PER_PAGE_NUM;
uint32_t dis_item_arr[MAINMENU_TILE_END][COMMON_PER_PAGE_NUM];
memset(dis_item_arr, 0, sizeof(dis_item_arr));
get_display_equipment_str(dis_item_arr);
// last_item_pos == 0 ? \
// (dis_item_arr[page_num-1][COMMON_PER_PAGE_NUM-1]=STR_ID_DEVICE_MANAGE) : \
// (dis_item_arr[page_num-1][last_item_pos-1]=STR_ID_DEVICE_MANAGE);
getDeviceEntryByStrId(dis_item_arr[page_count][btn_count]);
// printf("dis_item_arr = %d \n",dis_item_arr[page_count][btn_count]);
}
/**************************************************************************************/
static void scroll_begin_event(lv_event_t * e)
{
/*Disable the scroll animations. Triggered when a tab button is clicked */
if(lv_event_get_code(e) == LV_EVENT_SCROLL_BEGIN) {
lv_anim_t * a = lv_event_get_param(e);
if(a) a->time = 0;
}
}
static void scroll_event_cb(lv_event_t * e)
{
lv_obj_t * cont = lv_event_get_target(e);
lv_area_t cont_a;
lv_obj_get_coords(cont, &cont_a);
lv_coord_t cont_y_center = cont_a.y1 + lv_area_get_height(&cont_a) / 2;
lv_coord_t r = lv_obj_get_height(cont) * 7 / 10;
uint32_t i;
uint32_t child_cnt = lv_obj_get_child_cnt(cont);
for(i = 0; i < child_cnt; i++) {
lv_obj_t * child = lv_obj_get_child(cont, i);
lv_area_t child_a;
lv_obj_get_coords(child, &child_a);
lv_coord_t child_y_center = child_a.y1 + lv_area_get_height(&child_a) / 2;
lv_coord_t diff_y = child_y_center - cont_y_center;
diff_y = LV_ABS(diff_y);
/*Get the x of diff_y on a circle.*/
lv_coord_t x;
/*If diff_y is out of the circle use the last point of the circle (the radius)*/
if(diff_y >= r) {
x = r;
} else {
/*Use Pythagoras theorem to get x from radius and y*/
uint32_t x_sqr = r * r - diff_y * diff_y;
lv_sqrt_res_t res;
lv_sqrt(x_sqr, &res, 0x8000); /*Use lvgl's built in sqrt root function*/
x = r - res.i;
}
/*Translate the item by the calculated X coordinate*/
lv_obj_set_style_translate_x(child, x, 0);
/*Use some opacity with larger translations*/
lv_opa_t opa = lv_map(x, 0, r, LV_OPA_TRANSP, LV_OPA_COVER);
lv_obj_set_style_opa(child, LV_OPA_COVER - opa, 0);
}
}
void test(lv_obj_t* parent){
lv_obj_t *mainmenu_win = lv_obj_create(parent);
lv_obj_set_style_bg_color(mainmenu_win, lv_color_make(0x00, 0x00, 0x00), 0);
lv_obj_set_scrollbar_mode(mainmenu_win, LV_SCROLLBAR_MODE_OFF);
lv_obj_set_size(mainmenu_win, LV_PCT(100), LV_PCT(100));
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_clear_flag(mainmenu_win, LV_OBJ_FLAG_SCROLLABLE);
// lv_obj_t *mainmenu_win = NULL;
// gui_create_new_window(mainmenu_win);
Set_UI_page_id(PAGE_MAINMENU_WIN_ID);
// app_menu_comm_entry(mainmenu_win,PAGE_MAINMENU_WIN_ID,false);
// #if !MMI_WIN32_SIM
// lv_group_t *g = lv_get_keypad_group();
// lv_group_remove_all_objs(g);
// lv_group_add_obj(g, mainmenu_win);
// #endif
uint8_t style_num =1;
lv_obj_t * cont = NULL;
lv_obj_t * cont_parent = NULL;
uint8_t i =0;
static lv_style_t style;
lv_obj_t *tabview;
switch(style_num){
case 0:
/*Create a Tab view object*/
tabview = lv_tabview_create(lv_scr_act(), LV_DIR_LEFT, 100);
lv_obj_add_event_cb(lv_tabview_get_content(tabview), scroll_begin_event, LV_EVENT_SCROLL_BEGIN, NULL);
lv_obj_set_style_bg_color(tabview, lv_palette_lighten(LV_PALETTE_RED, 2), 0);
lv_obj_t * tab_btns = lv_tabview_get_tab_btns(tabview);
lv_obj_set_style_bg_color(tab_btns, lv_palette_darken(LV_PALETTE_GREY, 3), 0);
lv_obj_set_style_text_color(tab_btns, lv_palette_lighten(LV_PALETTE_GREY, 5), 0);
lv_obj_set_style_border_side(tab_btns, LV_BORDER_SIDE_RIGHT, LV_PART_ITEMS | LV_STATE_CHECKED);
/*Add 3 tabs (the tabs are page (lv_page) and can be scrolled*/
lv_obj_t *tab1 = lv_tabview_add_tab(tabview, "Tab 1");
lv_obj_set_size(tab1, LV_PCT(100), LV_PCT(100));
lv_obj_t *tab2 = lv_tabview_add_tab(tabview, "Tab 2");
lv_obj_set_size(tab2, LV_PCT(100), LV_PCT(100));
lv_obj_t *tab3 = lv_tabview_add_tab(tabview, "Tab 3");
lv_obj_set_size(tab3, LV_PCT(100), LV_PCT(100));
lv_obj_t *tab4 = lv_tabview_add_tab(tabview, "Tab 4");
lv_obj_set_size(tab4, LV_PCT(100), LV_PCT(100));
lv_obj_t *tab5 = lv_tabview_add_tab(tabview, "Tab 5");
lv_obj_set_size(tab5, LV_PCT(100), LV_PCT(100));
lv_obj_set_style_bg_color(tab2, lv_palette_lighten(LV_PALETTE_AMBER, 3), 0);
lv_obj_set_style_bg_opa(tab2, LV_OPA_COVER, 0);
/*Add content to the tabs*/
lv_obj_t * label = lv_label_create(tab1);
lv_label_set_text(label, "First tab 1111111111111111");
label = lv_label_create(tab2);
lv_label_set_text(label, "Second tab 2222222222222222");
label = lv_label_create(tab3);
lv_label_set_text(label, "Third tab 333333333333333333333");
label = lv_label_create(tab4);
lv_label_set_text(label, "Forth tab 444");
label = lv_label_create(tab5);
lv_label_set_text(label, "Fifth tab 5");
// lv_obj_clear_flag(lv_tabview_get_content(tabview), LV_OBJ_FLAG_SCROLLABLE);
// //横向按钮列表
// cont = lv_obj_create(mainmenu_win);
// lv_obj_set_size(cont, lv_pct(100), lv_pct(100));
// lv_obj_center(cont);
// lv_obj_set_flex_flow(cont, LV_FLEX_FLOW_ROW );
// lv_obj_add_event_cb(cont, scroll_event_cb, LV_EVENT_SCROLL, NULL);
// lv_obj_set_style_radius(cont, LV_RADIUS_CIRCLE, 0);//圆弧框
// lv_obj_set_style_clip_corner(cont, true, 0);//隐藏四个角落
// lv_obj_set_scroll_dir(cont, LV_DIR_VER);
// lv_obj_set_scroll_snap_y(cont, LV_SCROLL_SNAP_CENTER);
// lv_obj_set_scrollbar_mode(cont, LV_SCROLLBAR_MODE_OFF);
// lv_obj_clear_flag(cont, LV_OBJ_FLAG_SCROLLABLE);
//
// for(i = 0; i < 7; i++) {
// lv_obj_t * btn = lv_btn_create(cont);
// lv_obj_set_width(btn, 100);
// lv_obj_set_height(btn, lv_pct(70));
//
// lv_obj_t * label = lv_label_create(btn);
// lv_label_set_text_fmt(label, "%d", i);
// }
//
// lv_event_send(cont, LV_EVENT_SCROLL, NULL);
//
// lv_obj_scroll_to_view(lv_obj_get_child(cont, 0), LV_ANIM_OFF);
break;
case 1:
//弧形按钮列表
cont_parent = lv_obj_create(mainmenu_win);
lv_obj_set_size(cont_parent, 180, lv_pct(100));
lv_obj_align(cont_parent,LV_ALIGN_TOP_LEFT, 0, 0);
lv_obj_set_style_bg_color(cont_parent, lv_color_hex(0xff0000), 0);
lv_obj_clear_flag(cont_parent, LV_OBJ_FLAG_SCROLLABLE);
cont = lv_obj_create(cont_parent);
lv_obj_set_size(cont, 150, 150);
lv_obj_center(cont);
lv_obj_set_flex_flow(cont, LV_FLEX_FLOW_COLUMN);
lv_obj_add_event_cb(cont, scroll_event_cb, LV_EVENT_SCROLL, NULL);
lv_obj_set_style_radius(cont, LV_RADIUS_CIRCLE, 0);//圆弧框
lv_obj_set_style_clip_corner(cont, true, 0);//隐藏四个角落
lv_obj_set_scroll_dir(cont, LV_DIR_VER);
lv_obj_set_scroll_snap_y(cont, LV_SCROLL_SNAP_CENTER);
lv_obj_set_scrollbar_mode(cont, LV_SCROLLBAR_MODE_OFF);
lv_obj_clear_flag(cont, LV_OBJ_FLAG_SCROLLABLE);
for(i = 0; i < 7; i++) {
lv_obj_t * btn = lv_btn_create(cont);
lv_obj_set_width(btn, lv_pct(90));
lv_obj_set_height(btn, lv_pct(70));
lv_obj_t * label = lv_label_create(btn);
lv_label_set_text_fmt(label, "%d", i);
}
lv_event_send(cont, LV_EVENT_SCROLL, NULL);
lv_obj_scroll_to_view(lv_obj_get_child(cont, 0), LV_ANIM_OFF);
break;
case 2:
//循环滚动列表
lv_style_init(&style);
lv_style_set_bg_color(&style, lv_color_black());
lv_style_set_text_color(&style, lv_color_hex(0x5e0000));
lv_style_set_border_width(&style, 0);
lv_style_set_pad_all(&style, 0);
lv_obj_add_style(mainmenu_win, &style, 0);
lv_obj_t *roller1 = lv_roller_create(mainmenu_win);
lv_obj_add_style(roller1, &style, 0);
// lv_obj_set_style_bg_opa(roller1, LV_OPA_TRANSP, LV_PART_SELECTED);
lv_roller_set_options(roller1,
"January\n"
"February\n"
"March\n"
"April\n"
"May\n"
"June\n"
"July\n"
"August\n"
"September\n"
"October\n"
"November\n"
"December",
LV_ROLLER_MODE_INFINITE);
lv_obj_center(roller1);
lv_roller_set_visible_row_count(roller1, 3);
break;
}
}

View File

@ -1,7 +1,7 @@
#include "lvgl.h"
#include "img_def.h"
#include "mxc_meter.h"
#include "list.h"
#include "menu_list.h"
Local_UiCommon_t local_UiCommon = {0};

View File

@ -2,7 +2,7 @@
#include "img_def.h"
#include "demo.h"
#include "mxc_meter.h"
#include "list.h"
#include "menu_list"
#include "language_table.h"
#include "img_basic.h"
#include "lan_str_table.h"

View File

@ -52,18 +52,4 @@ lv_obj_t* lv_img_big_create(lv_obj_t* parent, const lv_img_dsc_t **src , lv_coor
return cont1;
}
//liulin 2024.2.29 增加销毁img创建接口,功能待实现
void lv_img_big_free(lv_obj_t* pObj)
{
if(pObj == NULL)
{
printf("free img obj pointer is NULL, return\n");
return;
}
//lv_img_buf_free(panel_light_group1_src);
//lv_mem_free(pObj->user_data);
}

View File

@ -1,454 +1,2 @@
#include <stdint.h>
#include <stddef.h>
//
////#include "os_task.h"
////#include "os_msg_q.h"
////#include "os_timer.h"
////#include "user_task.h"
//#include "button.h"
//
////#include "driver_pmu.h"
//
//#define BUTTON_IDX_MAX 1
//
//#define BUTTON_SHORT_DURING 0x08 // x10ms
//#define BUTTON_LONG_DURING 0x14 // x100ms
//#define BUTTON_LONG_LONG_DURING 0x28 // x100ms
//#define BUTTON_MULTI_INTERVAL 0x14 // x10ms
//#define BUTTON_LONG_PRESSING_INTERVAL 0x1e // x10ms
//
//uint8_t current_state = BUTTON_WORKING_STATE_IDLE;
//uint16_t button_task_id;
////os_timer_t button_anti_shake_timer;
////os_timer_t button_pressing_timer;
////os_timer_t button_state_timer;
//
///* which io is enabled for button function */
//uint32_t button_io_mask = 0;
//uint32_t curr_button_before_anti_shake = 0;
//uint32_t current_pressed_button = 0;
//uint32_t last_saved_button = 0;
//uint32_t button_to_be_send = 0; //for multi click
//uint8_t pressed_cnt = 0; //for multi click
//
//void button_toggle_detected(uint32_t curr_button)
//{
// //co_printf("button_toggle_detected curr_button :%x,button_io_mask :%x\r\n",curr_button,button_io_mask);
//
// if(button_io_mask != 0) {
// curr_button_before_anti_shake = curr_button & button_io_mask;
// os_timer_start(&button_anti_shake_timer, 10, false);
// }
//}
//
//void button_int_isr(uint32_t changed_button)
//{
// uint32_t curr_button;
// os_event_t toggle_event;
//
// curr_button = current_pressed_button ^ changed_button;
//
// toggle_event.event_id = BUTTON_TOGGLE;
// toggle_event.param = (void *)&curr_button;
// toggle_event.param_len = sizeof(uint32_t);
// os_msg_post(button_task_id, &toggle_event);
//}
//
//void button_send_event(uint8_t event, uint32_t button, uint8_t cnt)
//{
// os_event_t button_event;
// struct button_msg_t msg;
//
// msg.button_index = button;
// msg.button_type = event;
// msg.button_cnt = cnt;
//
// button_event.event_id = USER_EVT_BUTTON;
// button_event.src_task_id = button_task_id;
// button_event.param = (void *)&msg;
// button_event.param_len = sizeof(msg);
//
// os_msg_post(get_user_task_id(), &button_event);
//
// pressed_cnt = 0;
//}
//
//static void button_idle(uint8_t event)
//{
// if(event == BUTTON_WORKING_EVENT_SINGLE_PRESSED)
// {
// current_state = BUTTON_WORKING_STATE_JUST_PRESSED;
// os_timer_start(&button_state_timer, BUTTON_SHORT_DURING*10, false);
// button_send_event(BUTTON_PRESSED, current_pressed_button, pressed_cnt);
// }
// else if(event == BUTTON_WORKING_EVENT_COMB_PRESSED)
// {
// current_state = BUTTON_WORKING_STATE_COMB_JUST_PRESSED;
// os_timer_start(&button_state_timer, BUTTON_SHORT_DURING*10, false);
// button_send_event(BUTTON_COMB_PRESSED, current_pressed_button, pressed_cnt);
// }
//}
//
//static void button_just_pressed(uint8_t event)
//{
// if(event == BUTTON_WORKING_EVENT_RELEASED)
// {
// current_state = BUTTON_WORKING_STATE_IDLE;
// os_timer_stop(&button_state_timer);
// button_send_event(BUTTON_RELEASED, last_saved_button, pressed_cnt);
// }
// else if(event == BUTTON_WORKING_EVENT_COMB_PRESSED)
// {
// current_state = BUTTON_WORKING_STATE_COMB_JUST_PRESSED;
// os_timer_start(&button_state_timer, BUTTON_SHORT_DURING*10, false);
// button_send_event(BUTTON_COMB_PRESSED, current_pressed_button, pressed_cnt);
// }
// else if(event == BUTTON_WORKING_EVENT_TIME_OUT)
// {
// current_state = BUTTON_WORKING_STATE_PRESSED;
// os_timer_start(&button_state_timer, (BUTTON_LONG_DURING*10-BUTTON_SHORT_DURING)*10, false);
// }
//}
//
//static void button_pressed(uint8_t event)
//{
// if(event == BUTTON_WORKING_EVENT_RELEASED)
// {
// if(0/*__jump_table.button_disable_multi_click*/ & last_saved_button)
// {
// current_state = BUTTON_WORKING_STATE_IDLE;
// button_send_event(BUTTON_SHORT_PRESSED, last_saved_button, 0);
// }
// else
// {
// //TBD<42><44><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// current_state = BUTTON_WORKING_STATE_WAIT_MULTI;
// button_to_be_send = last_saved_button;
// pressed_cnt++;
// os_timer_start(&button_state_timer, BUTTON_MULTI_INTERVAL*10, false);
// }
// }
// else if(event == BUTTON_WORKING_EVENT_COMB_PRESSED)
// {
// current_state = BUTTON_WORKING_STATE_COMB_JUST_PRESSED;
// os_timer_start(&button_state_timer, BUTTON_SHORT_DURING*10, false);
// button_send_event(BUTTON_COMB_PRESSED, current_pressed_button, pressed_cnt);
// }
// else if(event == BUTTON_WORKING_EVENT_TIME_OUT)
// {
// current_state = BUTTON_WORKING_STATE_LONG_PRESSED;
// os_timer_start(&button_state_timer, ((BUTTON_LONG_LONG_DURING-BUTTON_LONG_DURING)*10)*10, false);
// os_timer_start(&button_pressing_timer, BUTTON_LONG_PRESSING_INTERVAL*10, false);
// button_send_event(BUTTON_LONG_PRESSED, current_pressed_button, pressed_cnt);
// }
//}
//
//static void button_wait_multi(uint8_t event)
//{
// if(event == BUTTON_WORKING_EVENT_SINGLE_PRESSED)
// {
// if(current_pressed_button != button_to_be_send)
// {
// if(pressed_cnt > 1)
// {
// button_send_event(BUTTON_MULTI_PRESSED, button_to_be_send, pressed_cnt);
// }
// else
// {
// button_send_event(BUTTON_SHORT_PRESSED, button_to_be_send, pressed_cnt);
// }
// button_send_event(BUTTON_PRESSED, current_pressed_button, pressed_cnt);
// }
// current_state = BUTTON_WORKING_STATE_JUST_PRESSED;
// os_timer_start(&button_state_timer, BUTTON_SHORT_DURING*10, false);
// }
// else if(event == BUTTON_WORKING_EVENT_COMB_PRESSED)
// {
// current_state = BUTTON_WORKING_STATE_COMB_JUST_PRESSED;
// os_timer_start(&button_state_timer, BUTTON_SHORT_DURING*10, false);
// button_send_event(BUTTON_COMB_PRESSED, current_pressed_button, pressed_cnt);
// button_send_event(BUTTON_SHORT_PRESSED, button_to_be_send, pressed_cnt);
// }
// else if(event == BUTTON_WORKING_EVENT_TIME_OUT)
// {
// current_state = BUTTON_WORKING_STATE_IDLE;
// if(pressed_cnt > 1)
// {
// button_send_event(BUTTON_MULTI_PRESSED, button_to_be_send, pressed_cnt);
// }
// else
// {
// button_send_event(BUTTON_SHORT_PRESSED, button_to_be_send, pressed_cnt);
// }
// }
//}
//
//static void button_long_pressed(uint8_t event)
//{
// if(event == BUTTON_WORKING_EVENT_RELEASED)
// {
// current_state = BUTTON_WORKING_STATE_IDLE;
// os_timer_stop(&button_state_timer);
// os_timer_stop(&button_pressing_timer);
// button_send_event(BUTTON_LONG_RELEASED, last_saved_button, pressed_cnt);
// }
// else if(event == BUTTON_WORKING_EVENT_COMB_PRESSED)
// {
// current_state = BUTTON_WORKING_STATE_COMB_JUST_PRESSED;
// os_timer_start(&button_state_timer, BUTTON_SHORT_DURING*10, false);
// os_timer_stop(&button_pressing_timer);
// button_send_event(BUTTON_COMB_PRESSED, current_pressed_button, pressed_cnt);
// button_send_event(BUTTON_LONG_RELEASED, last_saved_button, pressed_cnt);
// }
// else if(event == BUTTON_WORKING_EVENT_TIME_OUT)
// {
// current_state = BUTTON_WORKING_STATE_LONG_LONG_PRESSED;
// button_send_event(BUTTON_LONG_LONG_PRESSED, current_pressed_button, pressed_cnt);
// }
//}
//
//static void button_long_long_pressed(uint8_t event)
//{
// if(event == BUTTON_WORKING_EVENT_RELEASED)
// {
// os_timer_stop(&button_pressing_timer);
// current_state = BUTTON_WORKING_STATE_IDLE;
// button_send_event(BUTTON_LONG_LONG_RELEASED, last_saved_button, pressed_cnt);
// }
// else if(event == BUTTON_WORKING_EVENT_COMB_PRESSED)
// {
// current_state = BUTTON_WORKING_STATE_COMB_JUST_PRESSED;
// os_timer_start(&button_state_timer, BUTTON_SHORT_DURING*10, false);
// os_timer_stop(&button_pressing_timer);
// button_send_event(BUTTON_COMB_PRESSED, current_pressed_button, pressed_cnt);
// button_send_event(BUTTON_LONG_LONG_RELEASED, last_saved_button, pressed_cnt);
// }
//}
//
//static void button_comb_just_pressed(uint8_t event)
//{
// if(event == BUTTON_WORKING_EVENT_RELEASED)
// {
// current_state = BUTTON_WORKING_STATE_IDLE;
// os_timer_stop(&button_state_timer);
// button_send_event(BUTTON_COMB_RELEASED, last_saved_button, pressed_cnt);
// }
// else if(event == BUTTON_WORKING_EVENT_SINGLE_PRESSED)
// {
// current_state = BUTTON_WORKING_STATE_JUST_PRESSED;
// os_timer_start(&button_state_timer, BUTTON_SHORT_DURING*10, false);
// button_send_event(BUTTON_COMB_RELEASED, last_saved_button, pressed_cnt);
// button_send_event(BUTTON_PRESSED, current_pressed_button, pressed_cnt);
// }
// else if(event == BUTTON_WORKING_EVENT_COMB_PRESSED)
// {
// current_state = BUTTON_WORKING_STATE_JUST_PRESSED;
// os_timer_start(&button_state_timer, BUTTON_SHORT_DURING*10, false);
// button_send_event(BUTTON_COMB_PRESSED, current_pressed_button, pressed_cnt);
// }
// else if(event == BUTTON_WORKING_EVENT_TIME_OUT)
// {
// current_state = BUTTON_WORKING_STATE_COMB_PRESSED;
// os_timer_start(&button_state_timer, (BUTTON_LONG_DURING*10-BUTTON_SHORT_DURING)*10, false);
// }
//}
//
//static void button_comb_pressed(uint8_t event)
//{
// if(event == BUTTON_WORKING_EVENT_RELEASED)
// {
// current_state = BUTTON_WORKING_STATE_IDLE;
// os_timer_stop(&button_state_timer);
// button_send_event(BUTTON_COMB_SHORT_PRESSED, last_saved_button, pressed_cnt);
// }
// else if(event == BUTTON_WORKING_EVENT_SINGLE_PRESSED)
// {
// current_state = BUTTON_WORKING_STATE_JUST_PRESSED;
// os_timer_start(&button_state_timer, BUTTON_SHORT_DURING*10, false);
// button_send_event(BUTTON_COMB_SHORT_PRESSED, last_saved_button, pressed_cnt);
// button_send_event(BUTTON_PRESSED, current_pressed_button, pressed_cnt);
// }
// else if(event == BUTTON_WORKING_EVENT_COMB_PRESSED)
// {
// current_state = BUTTON_WORKING_STATE_COMB_JUST_PRESSED;
// os_timer_start(&button_state_timer, BUTTON_SHORT_DURING*10, false);
// button_send_event(BUTTON_COMB_SHORT_PRESSED, last_saved_button, pressed_cnt);
// button_send_event(BUTTON_COMB_PRESSED, current_pressed_button, pressed_cnt);
// }
// else if(event == BUTTON_WORKING_EVENT_TIME_OUT)
// {
// current_state = BUTTON_WORKING_STATE_COMB_LONG_PRESSED;
// os_timer_start(&button_state_timer, ((BUTTON_LONG_LONG_DURING-BUTTON_LONG_DURING)*10)*10, false);
// os_timer_start(&button_pressing_timer, BUTTON_LONG_PRESSING_INTERVAL*10, false);
// button_send_event(BUTTON_COMB_LONG_PRESSED, current_pressed_button, pressed_cnt);
// }
//}
//
//static void button_comb_long_pressed(uint8_t event)
//{
// if(event == BUTTON_WORKING_EVENT_RELEASED)
// {
// current_state = BUTTON_WORKING_STATE_IDLE;
// os_timer_stop(&button_state_timer);
// os_timer_stop(&button_pressing_timer);
// button_send_event(BUTTON_COMB_LONG_RELEASED, last_saved_button, pressed_cnt);
// }
// else if(event == BUTTON_WORKING_EVENT_SINGLE_PRESSED)
// {
// current_state = BUTTON_WORKING_STATE_JUST_PRESSED;
// os_timer_start(&button_state_timer, BUTTON_SHORT_DURING*10, false);
// os_timer_stop(&button_pressing_timer);
// button_send_event(BUTTON_COMB_LONG_RELEASED, last_saved_button, pressed_cnt);
// button_send_event(BUTTON_PRESSED, current_pressed_button, pressed_cnt);
// }
// else if(event == BUTTON_WORKING_EVENT_COMB_PRESSED)
// {
// current_state = BUTTON_WORKING_STATE_COMB_JUST_PRESSED;
// os_timer_start(&button_state_timer, BUTTON_SHORT_DURING*10, false);
// os_timer_stop(&button_pressing_timer);
// button_send_event(BUTTON_COMB_LONG_RELEASED, last_saved_button, pressed_cnt);
// button_send_event(BUTTON_COMB_PRESSED, current_pressed_button, pressed_cnt);
// }
// else if(event == BUTTON_WORKING_EVENT_TIME_OUT)
// {
// current_state = BUTTON_WORKING_STATE_COMB_LONG_LONG_PRESSED;
// button_send_event(BUTTON_COMB_LONG_LONG_PRESSED, current_pressed_button, pressed_cnt);
// }
//}
//
//static void button_comb_long_long_pressed(uint8_t event)
//{
// if(event == BUTTON_WORKING_EVENT_RELEASED)
// {
// current_state = BUTTON_WORKING_STATE_IDLE;
// os_timer_stop(&button_pressing_timer);
// button_send_event(BUTTON_COMB_LONG_LONG_RELEASED, last_saved_button, pressed_cnt);
// }
// else if(event == BUTTON_WORKING_EVENT_SINGLE_PRESSED)
// {
// current_state = BUTTON_WORKING_STATE_JUST_PRESSED;
// os_timer_start(&button_state_timer, BUTTON_SHORT_DURING*10, false);
// os_timer_stop(&button_pressing_timer);
// button_send_event(BUTTON_COMB_LONG_LONG_RELEASED, last_saved_button, pressed_cnt);
// button_send_event(BUTTON_PRESSED, current_pressed_button, pressed_cnt);
// }
// else if(event == BUTTON_WORKING_EVENT_COMB_PRESSED)
// {
// current_state = BUTTON_WORKING_STATE_COMB_JUST_PRESSED;
// os_timer_start(&button_state_timer, BUTTON_SHORT_DURING*10, false);
// os_timer_stop(&button_pressing_timer);
// button_send_event(BUTTON_COMB_LONG_LONG_RELEASED, last_saved_button, pressed_cnt);
// button_send_event(BUTTON_COMB_PRESSED, current_pressed_button, pressed_cnt);
// }
//}
//
//void (*const button_statemachines[BUTTON_WORKING_STATE_MAX])(uint8_t) =
//{
// button_idle,
// button_just_pressed,
// button_pressed,
// button_wait_multi,
// button_long_pressed,
// button_long_long_pressed,
// button_comb_just_pressed,
// button_comb_pressed,
// button_comb_long_pressed,
// button_comb_long_long_pressed,
//};
//
////one or more button is released or pressed
//static int button_toggle_handler(uint32_t curr_button)
//{
// enum button_working_event_t event;
//
// current_pressed_button = curr_button;
//
// if(last_saved_button != current_pressed_button)
// {
// if(current_pressed_button == 0)
// {
// event = BUTTON_WORKING_EVENT_RELEASED;
// }
// else
// {
// if((current_pressed_button & (current_pressed_button-1)) == 0)
// {
// event = BUTTON_WORKING_EVENT_SINGLE_PRESSED;
// }
// else
// {
// event = BUTTON_WORKING_EVENT_COMB_PRESSED;
// }
// }
//
// button_statemachines[current_state](event);
//
// last_saved_button = current_pressed_button;
// }
//
// return EVT_CONSUMED;
//}
//
//static void button_timeout_handler(void *param)
//{
// button_statemachines[current_state](BUTTON_WORKING_EVENT_TIME_OUT);
//}
//
//static void button_pressing_timeout_handler(void *param)
//{
// enum button_type_t event;
// if((current_pressed_button & (current_pressed_button - 1)) == 0)
// {
// event = BUTTON_LONG_PRESSING;
// }
// else
// {
// event = BUTTON_COMB_LONG_PRESSING;
// }
//
// button_send_event(event, current_pressed_button, pressed_cnt);
//
// os_timer_start(&button_pressing_timer, BUTTON_LONG_PRESSING_INTERVAL*10, false);
//}
//
//static void button_anti_shake_timeout_handler(void *param)
//{
// uint32_t curr_button;
// os_event_t toggle_event;
//
// //milo modify curr_button = ool_read32(PMU_REG_PORTA_V);
// curr_button = ool_read32(PMU_REG_PORTA_LAST_STATUS);
// curr_button &= button_io_mask;
//
// if(curr_button == curr_button_before_anti_shake)
// {
// curr_button ^= button_io_mask;
// toggle_event.event_id = BUTTON_TOGGLE;
// toggle_event.param = (void *)&curr_button;
// toggle_event.param_len = sizeof(uint32_t);
// os_msg_post(button_task_id, &toggle_event);
// }
//}
//
//static int button_task_func(os_event_t *event)
//{
// switch(event->event_id)
// {
// case BUTTON_TOGGLE:
// button_toggle_handler(*(uint32_t *)event->param);
// break;
// }
//
// return EVT_CONSUMED;
//}
//
//void button_init(uint32_t enable_io)
//{
// button_io_mask = enable_io;
//
// button_task_id = os_task_create(button_task_func);
// os_timer_init(&button_anti_shake_timer, button_anti_shake_timeout_handler, NULL);
// os_timer_init(&button_pressing_timer, button_pressing_timeout_handler, NULL);
// os_timer_init(&button_state_timer, button_timeout_handler, NULL);
//}

View File

@ -4,7 +4,7 @@
typedef void (*btn_event_func)(lv_obj_t *obj);
#define LV_KEY_Q 113
#define LV_KEY_W 119
#define LV_KEY_W 10
//liulin 2024.3.5 用于发电机项目切换各个界面