增加了全局结构体,将UI定时器函数中全局变量替换成结构体变量
This commit is contained in:
@ -151,7 +151,8 @@ static void test_win1_handle(lv_event_t* e)
|
||||
//close_ui_refresh_timer();
|
||||
close_all_win();
|
||||
|
||||
if(pTime_refresh_timer!=NULL){
|
||||
if(pTime_refresh_timer!=NULL)
|
||||
{
|
||||
lv_timer_del(pTime_refresh_timer);
|
||||
pTime_refresh_timer = NULL;
|
||||
}
|
||||
@ -187,7 +188,8 @@ static void test_win2_handle(lv_event_t* e)
|
||||
//close_ui_refresh_timer();
|
||||
close_all_win();
|
||||
|
||||
if(pTime_refresh_timer!=NULL){
|
||||
if(pTime_refresh_timer!=NULL)
|
||||
{
|
||||
lv_timer_del(pTime_refresh_timer);
|
||||
pTime_refresh_timer = NULL;
|
||||
}
|
||||
@ -201,7 +203,8 @@ static void test_win2_handle(lv_event_t* e)
|
||||
}
|
||||
|
||||
|
||||
/******************3.定时器******************/
|
||||
/******************3.定时器****************/
|
||||
#if 0
|
||||
void refresh_MainUItimer_cb(lv_timer_t* pTimer)
|
||||
{
|
||||
static uint16_t arc_num=60,speed=0,voltage=0,current=0,power=0;//转速 电压 电流 功率
|
||||
@ -246,51 +249,55 @@ void refresh_MainUItimer_cb(lv_timer_t* pTimer)
|
||||
//油量
|
||||
lv_bar_set_value(pOilColor, oil_quantity, LV_ANIM_OFF);
|
||||
|
||||
lv_label_set_text_fmt(pRunTime, "%d", time_num);
|
||||
lv_label_set_text_fmt(pLeftTime, "%d", time_num);
|
||||
lv_label_set_text_fmt(pTotalTime, "%d", time_num);
|
||||
lv_label_set_text_fmt(pRunTime, "%d", time_num);
|
||||
lv_label_set_text_fmt(pLeftTime, "%d", time_num);
|
||||
lv_label_set_text_fmt(pTotalTime, "%d", time_num);
|
||||
|
||||
lv_label_set_text_fmt(pFreqNum, "%d", load_num);
|
||||
lv_label_set_text_fmt(pPercentNum, "%d", frequency_num);
|
||||
lv_label_set_text_fmt(pPowerNum, "%d", power);
|
||||
lv_label_set_text_fmt(pFreqNum, "%d", load_num);
|
||||
lv_label_set_text_fmt(pPercentNum, "%d", frequency_num);
|
||||
lv_label_set_text_fmt(pPowerNum, "%d", power);
|
||||
|
||||
if((time_num/10)%2==0){
|
||||
lv_obj_clear_flag(img_bt,LV_OBJ_FLAG_HIDDEN);
|
||||
lv_obj_clear_flag(img_power,LV_OBJ_FLAG_HIDDEN);
|
||||
lv_obj_clear_flag(img_error,LV_OBJ_FLAG_HIDDEN);
|
||||
}else{
|
||||
lv_obj_add_flag(img_bt,LV_OBJ_FLAG_HIDDEN);
|
||||
lv_obj_add_flag(img_power,LV_OBJ_FLAG_HIDDEN);
|
||||
lv_obj_add_flag(img_error,LV_OBJ_FLAG_HIDDEN);
|
||||
}
|
||||
if((time_num/10)%2==0)
|
||||
{
|
||||
lv_obj_clear_flag(img_bt,LV_OBJ_FLAG_HIDDEN);
|
||||
lv_obj_clear_flag(img_power,LV_OBJ_FLAG_HIDDEN);
|
||||
lv_obj_clear_flag(img_error,LV_OBJ_FLAG_HIDDEN);
|
||||
}
|
||||
else
|
||||
{
|
||||
lv_obj_add_flag(img_bt,LV_OBJ_FLAG_HIDDEN);
|
||||
lv_obj_add_flag(img_power,LV_OBJ_FLAG_HIDDEN);
|
||||
lv_obj_add_flag(img_error,LV_OBJ_FLAG_HIDDEN);
|
||||
}
|
||||
|
||||
|
||||
speed+=100;
|
||||
if(speed >=10000)
|
||||
speed =0;
|
||||
if(speed >=10000)
|
||||
speed =0;
|
||||
|
||||
power+=100;
|
||||
if(power >=60000)
|
||||
power =0;
|
||||
power+=100;
|
||||
if(power >=60000)
|
||||
power =0;
|
||||
|
||||
voltage++;
|
||||
if(voltage>=1000)
|
||||
voltage=0;
|
||||
voltage++;
|
||||
if(voltage>=1000)
|
||||
voltage=0;
|
||||
|
||||
current++;
|
||||
if(current>=100)
|
||||
current=0;
|
||||
current++;
|
||||
if(current>=100)
|
||||
current=0;
|
||||
|
||||
time_num++;
|
||||
if(time_num>=100)
|
||||
time_num=0;
|
||||
if(time_num>=100)
|
||||
time_num=0;
|
||||
|
||||
load_num++;
|
||||
if(time_num>=100)
|
||||
time_num=0;
|
||||
if(time_num>=100)
|
||||
time_num=0;
|
||||
|
||||
frequency_num++;
|
||||
if(time_num>=100)
|
||||
time_num=0;
|
||||
if(time_num>=100)
|
||||
time_num=0;
|
||||
|
||||
if(oil_flag%2==0)
|
||||
oil_quantity++;
|
||||
@ -312,10 +319,97 @@ void refresh_MainUItimer_cb(lv_timer_t* pTimer)
|
||||
|
||||
if(oil_quantity>=95)
|
||||
oil_flag++;
|
||||
}
|
||||
#else
|
||||
void refresh_MainUItimer_cb(lv_timer_t* pTimer)
|
||||
{
|
||||
static uint16_t arc_num=60;//转速 电压 电流 功率
|
||||
static uint8_t oil_quantity=0,time_num=0;//油量 时间 负载 频率
|
||||
static uint8_t arc_flag=0,oil_flag=0;
|
||||
//检查定时器指针合法性
|
||||
lv_obj_t *parent = pTimer->user_data;
|
||||
if(!lv_obj_is_valid(parent))
|
||||
{
|
||||
printf("parent lv_obj_is_valid() fail.\n");
|
||||
return;
|
||||
}
|
||||
if(NULL == parent)
|
||||
{
|
||||
printf("parent NULL\n");
|
||||
return;
|
||||
}
|
||||
|
||||
//获取MainUI创建的各子对象的指针
|
||||
//转速数据
|
||||
lv_obj_t* arc1 = lv_obj_get_child(parent, 1);
|
||||
lv_obj_t* arc2 = lv_obj_get_child(parent, 2);
|
||||
lv_obj_t* pRotrateNum = lv_obj_get_child(parent, 4);
|
||||
lv_obj_t* pVoltageNum = lv_obj_get_child(parent, 5);
|
||||
lv_obj_t* pCurrentNum = lv_obj_get_child(parent, 6);
|
||||
lv_obj_t* img_bt = lv_obj_get_child(parent, 7);
|
||||
lv_obj_t* img_power = lv_obj_get_child(parent, 8);
|
||||
lv_obj_t* img_error = lv_obj_get_child(parent, 9);
|
||||
lv_obj_t* pOilColor = lv_obj_get_child(parent, 10);
|
||||
lv_obj_t* pRunTime = lv_obj_get_child(parent, 11);
|
||||
lv_obj_t* pLeftTime = lv_obj_get_child(parent, 12);
|
||||
lv_obj_t* pTotalTime = lv_obj_get_child(parent, 13);
|
||||
lv_obj_t* pFreqNum = lv_obj_get_child(parent, 14);
|
||||
lv_obj_t* pPercentNum = lv_obj_get_child(parent, 15);
|
||||
lv_obj_t* pPowerNum = lv_obj_get_child(parent, 17);
|
||||
|
||||
lv_arc_set_value(arc1, arc_num);
|
||||
lv_arc_set_value(arc2, arc_num);
|
||||
lv_label_set_text_fmt(pRotrateNum, "%d", g_UserData.uiData.mEngineSpeed);
|
||||
lv_label_set_text_fmt(pVoltageNum, "%d", g_UserData.uiData.mVoltValue);
|
||||
lv_label_set_text_fmt(pCurrentNum, "%d", g_UserData.uiData.mCurrentValue);
|
||||
//油量
|
||||
lv_bar_set_value(pOilColor, g_UserData.uiData.mOilValue, LV_ANIM_OFF);
|
||||
|
||||
lv_label_set_text_fmt(pRunTime, "%d", g_UserData.uiData.mRunTime);
|
||||
lv_label_set_text_fmt(pLeftTime, "%d", g_UserData.uiData.mLeftTime);
|
||||
lv_label_set_text_fmt(pTotalTime, "%d", g_UserData.uiData.mTotalTime);
|
||||
|
||||
lv_label_set_text_fmt(pFreqNum, "%d", g_UserData.uiData.mFreqValue);
|
||||
lv_label_set_text_fmt(pPercentNum, "%d", g_UserData.uiData.mPercentValue);
|
||||
lv_label_set_text_fmt(pPowerNum, "%d", g_UserData.uiData.mPowerValue);
|
||||
|
||||
if((time_num/10)%2==0)
|
||||
{
|
||||
lv_obj_clear_flag(img_bt,LV_OBJ_FLAG_HIDDEN);
|
||||
lv_obj_clear_flag(img_power,LV_OBJ_FLAG_HIDDEN);
|
||||
lv_obj_clear_flag(img_error,LV_OBJ_FLAG_HIDDEN);
|
||||
}
|
||||
else
|
||||
{
|
||||
lv_obj_add_flag(img_bt,LV_OBJ_FLAG_HIDDEN);
|
||||
lv_obj_add_flag(img_power,LV_OBJ_FLAG_HIDDEN);
|
||||
lv_obj_add_flag(img_error,LV_OBJ_FLAG_HIDDEN);
|
||||
}
|
||||
|
||||
|
||||
if(oil_flag%2==0)
|
||||
oil_quantity++;
|
||||
else
|
||||
oil_quantity--;
|
||||
|
||||
if(arc_flag%2==0)
|
||||
arc_num++;
|
||||
else
|
||||
arc_num--;
|
||||
|
||||
if(arc_flag%2==0)
|
||||
arc_num++;
|
||||
else
|
||||
arc_num--;
|
||||
//模拟器跑60-76 板子跑20-37
|
||||
if(arc_num>77 || arc_num<=60)
|
||||
arc_flag++;
|
||||
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
void refresh_TWOUItimer_cb(lv_timer_t* pTimer)
|
||||
{
|
||||
static uint16_t temp=0,voltage=0,count=0;//温度 电压 次数
|
||||
@ -362,17 +456,53 @@ void refresh_TWOUItimer_cb(lv_timer_t* pTimer)
|
||||
count--;
|
||||
if(count>=50 || count==0)
|
||||
count_flag++;
|
||||
}
|
||||
#else
|
||||
void refresh_TWOUItimer_cb(lv_timer_t* pTimer)
|
||||
{
|
||||
static uint16_t temp=0,voltage=0,count=0;//温度 电压 次数
|
||||
static uint8_t temp_flag=0,voltage_flag=0,count_flag=0;
|
||||
//检查定时器指针合法性
|
||||
lv_obj_t *parent = pTimer->user_data;
|
||||
if(!lv_obj_is_valid(parent))
|
||||
return;
|
||||
if(NULL == parent)
|
||||
return;
|
||||
|
||||
//获取MainUI创建的各子对象的指针
|
||||
lv_obj_t* IGBTtemp_label1 = lv_obj_get_child(parent, 16);
|
||||
lv_obj_t* voltage_label = lv_obj_get_child(parent, 17);
|
||||
lv_obj_t* MCUtemp_label2 = lv_obj_get_child(parent, 18);
|
||||
lv_obj_t* Cylindertemp_label3 = lv_obj_get_child(parent, 19);
|
||||
lv_obj_t* reversal_times = lv_obj_get_child(parent, 20);
|
||||
|
||||
//lv_label_set_text_fmt(temp_label1, "%d°C", temp);
|
||||
//lv_label_set_text_fmt(temp_label2, "%d°C", temp);
|
||||
//lv_label_set_text_fmt(temp_label3, "%d°C", temp);
|
||||
//lv_label_set_text_fmt(voltage_label, "%d V", voltage);
|
||||
//lv_label_set_text_fmt(reversal_times, "%d", count);
|
||||
|
||||
lv_label_set_text_fmt(IGBTtemp_label1, "%d°C", g_UserData.inverterData.IGBTTemper);
|
||||
lv_label_set_text_fmt(MCUtemp_label2, "%d°C", g_UserData.inverterData.MCUTemper);
|
||||
lv_label_set_text_fmt(Cylindertemp_label3, "%d°C", g_UserData.upLoadData.mCylinderTemp);
|
||||
lv_label_set_text_fmt(voltage_label, "%d V", g_UserData.inverterData.BusVolt);
|
||||
lv_label_set_text_fmt(reversal_times, "%d", g_UserData.upLoadData.mRevDragStartUP);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/******************4.界面入口******************/
|
||||
//获取主屏幕
|
||||
void Generator_src_win(lv_obj_t * scr_parent_main)
|
||||
{
|
||||
// lv_obj_t * scr_parent_main = get_root_win();
|
||||
|
||||
lv_obj_t * MainUI_win = lv_obj_create(scr_parent_main);
|
||||
//liulin 2024.3.18
|
||||
//先初始化全局结构体
|
||||
SystemDataInit();
|
||||
|
||||
lv_obj_t* MainUI_win = lv_obj_create(scr_parent_main);
|
||||
lv_obj_set_scrollbar_mode(MainUI_win, LV_SCROLLBAR_MODE_OFF); //关闭滑轮功能
|
||||
lv_obj_set_size(MainUI_win, LV_PCT(100), LV_PCT(100)); //设置主界面100%显示
|
||||
lv_obj_set_style_pad_all(MainUI_win, 0, 0); //
|
||||
@ -382,10 +512,10 @@ void Generator_src_win(lv_obj_t * scr_parent_main)
|
||||
lv_obj_set_style_bg_color(MainUI_win, lv_color_black(), 0); //设置背景为全黑
|
||||
lv_obj_clear_flag(MainUI_win, LV_OBJ_FLAG_SCROLLABLE);
|
||||
//异形进度条弧 0
|
||||
lv_obj_t* arc_img = lv_img_big_create(MainUI_win,arc_src,52,60,3,0);
|
||||
lv_obj_t* arc_img = lv_img_big_create(MainUI_win, arc_src, 52, 60, 3, 0);
|
||||
// 1
|
||||
lv_obj_t *ui_Arc1 = lv_arc_create(MainUI_win);
|
||||
lv_obj_set_size(ui_Arc1,2400,2400);
|
||||
lv_obj_set_size(ui_Arc1, 2400, 2400);
|
||||
lv_obj_set_pos(ui_Arc1, -816, 373);
|
||||
lv_obj_set_align( ui_Arc1, LV_ALIGN_CENTER );
|
||||
lv_arc_set_value(ui_Arc1, 60);
|
||||
@ -415,6 +545,7 @@ void Generator_src_win(lv_obj_t * scr_parent_main)
|
||||
lv_obj_set_style_arc_rounded(ui_Arc2, false, LV_PART_INDICATOR| LV_STATE_DEFAULT);
|
||||
lv_obj_set_style_bg_color(ui_Arc2, lv_color_hex(0xFFFFFF), LV_PART_KNOB | LV_STATE_DEFAULT );
|
||||
lv_obj_set_style_bg_opa(ui_Arc2, 0, LV_PART_KNOB| LV_STATE_DEFAULT);
|
||||
|
||||
//3
|
||||
lv_obj_t* demo_bg = lv_img_big_create(MainUI_win,demo_bg_src,0,0,9,0);
|
||||
|
||||
@ -807,8 +938,6 @@ void Generator_SubUI_Gtor_src_win(lv_obj_t * scr_parent_main)
|
||||
lv_label_set_text(pLabel_hardwareData, "ICMX-2.57");
|
||||
lv_obj_align(pLabel_hardwareData, LV_ALIGN_TOP_LEFT, 30, 273);
|
||||
|
||||
|
||||
|
||||
//IGBT温度数据 16
|
||||
lv_obj_t* pLabel_IGBTTempData = lv_label_create(pSubUI_Gtor_win);
|
||||
lv_obj_set_style_text_font(pLabel_IGBTTempData, LV_FONT_MXC_MSYAHEI_CT_18PX, LV_STATE_DEFAULT);
|
||||
@ -822,7 +951,6 @@ void Generator_SubUI_Gtor_src_win(lv_obj_t * scr_parent_main)
|
||||
lv_label_set_text(pLabel_VoltageData, "220V");
|
||||
lv_obj_align(pLabel_VoltageData, LV_ALIGN_TOP_LEFT, 228, 188);
|
||||
|
||||
|
||||
//内部温度数据 18
|
||||
lv_obj_t* pLabel_TemperatureData = lv_label_create(pSubUI_Gtor_win);
|
||||
lv_obj_set_style_text_font(pLabel_TemperatureData, LV_FONT_MXC_MSYAHEI_CT_18PX, LV_STATE_DEFAULT);
|
||||
@ -891,12 +1019,10 @@ void Generator_SubUI_ERROR_src_win(lv_obj_t * scr_parent_main)
|
||||
|
||||
lv_obj_add_event_cb(pSubUI_ERROR_win, WinKey_event_ErrToMain_handle, LV_EVENT_KEY, NULL);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void roller1_refresh(lv_timer_t *t){
|
||||
void roller1_refresh(lv_timer_t *t)
|
||||
{
|
||||
lv_obj_t *parent = t->user_data;
|
||||
if(!lv_obj_is_valid(parent)){
|
||||
printf("parent lv_obj_is_valid fail.\n");
|
||||
@ -923,7 +1049,8 @@ void roller1_refresh(lv_timer_t *t){
|
||||
|
||||
}
|
||||
|
||||
void roller2_refresh(lv_timer_t *t){
|
||||
void roller2_refresh(lv_timer_t *t)
|
||||
{
|
||||
lv_obj_t *parent = t->user_data;
|
||||
if(!lv_obj_is_valid(parent)){
|
||||
printf("parent lv_obj_is_valid fail.\n");
|
||||
@ -1076,7 +1203,7 @@ void Generator_test1_src_win(lv_obj_t * scr_parent_main)
|
||||
lv_obj_center(roller2);
|
||||
lv_roller_set_selected(roller2, 1, LV_ANIM_OFF);
|
||||
|
||||
pTime_refresh_timer = lv_timer_create(roller1_refresh,2000,pSubUI_ERROR_win);
|
||||
pTime_refresh_timer = lv_timer_create(roller1_refresh, 2000, pSubUI_ERROR_win);
|
||||
|
||||
|
||||
//将GtorUI放到按键编组中,相应按钮时间,切换到Err界面
|
||||
@ -1222,9 +1349,6 @@ void Generator_test2_src_win(lv_obj_t * scr_parent_main)
|
||||
|
||||
lv_obj_add_event_cb(pSubUI_ERROR_win, test_win2_handle, LV_EVENT_KEY, NULL);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user