[200~A36新界面以及全部修改后的界面代码和数据结构体,界面有动画效果

This commit is contained in:
liulin
2024-04-18 09:50:14 +08:00
parent 3401b91efc
commit dd46bd3fa1
25 changed files with 68920 additions and 86 deletions

View File

@ -59,7 +59,8 @@ void creatRootObj(void);
void Enter_screen_id(lv_obj_t *parent_main);
void win_init(void){
void win_init(void)
{
uint8_t ui_mode = 0;
// creatRootObj();
@ -92,7 +93,9 @@ void win_init(void){
}
void Enter_screen_id(lv_obj_t *parent_main){
//界面入口函数
void Enter_screen_id(lv_obj_t *parent_main)
{
daily_data_t *local_data = daily_get_UiData();
Set_UI_page_id(get_top_history_win());
@ -109,20 +112,154 @@ void Enter_screen_id(lv_obj_t *parent_main){
}
}
//定时刷新函数
static int espeed_counter = 0;
static int water_counter = 0;
static int oil_counter = 0;
void refresh_timer_cb(lv_timer_t *t){
lv_obj_t *parent = t->user_data;
if(!lv_obj_is_valid(parent)){
void refresh_timer_cb(lv_timer_t *t)
{
printf("enter refresh_timer_cb()...\n");
lv_obj_t* parent = t->user_data;
if(!lv_obj_is_valid(parent))
{
printf("parent lv_obj_is_valid fail.\n");
return;
}
if(parent ==NULL){
if(parent == NULL)
{
printf("parent ==NULL\n");
return;
}
if(Get_sys_power_on_self_test() ==0)
return;
//printf("AAA...\n");
//if(Get_sys_power_on_self_test() == 0) //单板需要,模拟器需注释
//return;
//printf("BBB...\n");
#if 1
static int GearValue = 0, SpeedValue = 0;
static float VoltValue = 0.0;
static int espeedFlag = 0, espeed = 0;
static int espeedangle = 0; //espeedpointFlag = 0
static int waterFlag = 0, waterspeed = 0;
static int waterangle = 0;
static int oilFlag = 0, oilspeed = 0;
static int oilangle = 0;
//获取主界面子对象
lv_obj_t* pSpeed = lv_obj_get_child(parent, 15); //获取档位信息
lv_obj_t* pGear = lv_obj_get_child(parent, 17); //获取速度信息
lv_obj_t* pTimelabel = lv_obj_get_child(parent, 18); //获取当前时间
lv_obj_t* pVoltage = lv_obj_get_child(parent, 19); //获取电瓶电压
lv_obj_t* pEspeedArc = lv_obj_get_child(parent, 20); //转速圆弧 //lv_obj_t* pEspeedImg = lv_obj_get_child(parent, 21);//转速颜色条
lv_obj_t* pEspeedPoint = lv_obj_get_child(parent, 26); //转速指针
lv_obj_t* pWaterArc = lv_obj_get_child(parent, 22); //水箱圆弧
lv_obj_t* pWaterPoint = lv_obj_get_child(parent, 27); //水箱指针
lv_obj_t* pOilArc = lv_obj_get_child(parent, 23); //油箱圆弧
lv_obj_t* pOilPoint = lv_obj_get_child(parent, 28); //油箱指针
//档位数据
lv_label_set_text_fmt(pGear, "%d", GearValue+2);
//速度数据
lv_label_set_text_fmt(pSpeed, "%d", SpeedValue+20);
//当前时间,时间更新
lv_label_set_text(pTimelabel, GetCurTimeString()); //获取当前时间
//电瓶电压
lv_label_set_text_fmt(pVoltage, "%0.1fV", VoltValue+10.0);
//档位数据
GearValue++;
if(GearValue == 8)
{
GearValue = 0;
}
//速度数据
SpeedValue += 10;
if(SpeedValue == 350)
{
SpeedValue = 0;
}
//电压数据
VoltValue += 0.2;
if(VoltValue <= 14.0)
{
SpeedValue = 0.0;
}
//转速圆弧
lv_arc_set_value(pEspeedArc, espeed); //设置圆弧值范围 (0~120),实际转速值缩小100倍
//转速指针
lv_img_set_angle(pEspeedPoint, espeedangle + 600); //圆弧指针角度范围 (60~300),分12份20度
printf("espeedangle = %d\n", espeedangle);
if(espeedFlag%2 == 0)
{
espeed += 10;
espeedangle += 200;
}
else
{
espeed -= 10;
espeedangle -= 200;
}
espeed_counter++;
espeedFlag = espeed_counter/12;
//水箱圆弧
lv_arc_set_value(pWaterArc, waterspeed); //水温范围值(0~100),圆弧值范围 (0~100)
//水箱指针
lv_img_set_angle(pWaterPoint, waterangle + 2200); //圆弧指针角度范围 (220~340)
printf("waterangle = %d\n", waterangle);
if(waterFlag%2 == 0)
{
waterspeed = waterspeed + 10;
waterangle = waterangle + 100;
}
else
{
waterspeed = waterspeed - 10;
waterangle = waterangle - 100;
}
water_counter++;
waterFlag = water_counter/10;
//水箱圆弧
lv_arc_set_value(pOilArc, oilspeed); //水温范围值(0~100),圆弧值范围 (0~100)
//水箱指针
lv_img_set_angle(pOilPoint, oilangle + 2200); //圆弧指针角度范围 (220~340)
printf("oilangle = %d\n", oilangle);
if(oilFlag%2 == 0)
{
oilspeed = oilspeed + 10;
oilangle = oilangle + 100;
}
else
{
oilspeed = oilspeed - 10;
oilangle = oilangle - 100;
}
oil_counter++;
oilFlag = oil_counter/10;
/*printf("-------\n");
if(num%2==0)
speed_angle+=20;
else
speed_angle-=20;
if(speed_angle >= 3000|| speed_angle == 0)
num++;
printf("num = %d\n", num);
printf("speed_angle = %d\n", speed_angle);
*/
#else if
static int num=0,bar_num=0,peed_num=0,gear_num=0,mileage=0;
uint8_t scale_num;
//指针刷新
@ -139,17 +276,20 @@ void refresh_timer_cb(lv_timer_t *t){
lv_obj_t * trip_mileage = lv_obj_get_child(parent,14);
lv_obj_t * odo_mileage = lv_obj_get_child(parent,15);
lv_img_set_angle(hand_img,speed_angle);
lv_img_set_angle(hand_img, speed_angle);
lv_arc_set_value(ui_Arc1, (speed_angle/25));
//lv_arc_set_value(ui_Arc1, (speed_angle/25));
lv_label_set_text_fmt(speed, "%d",speed_value);
lv_label_set_text_fmt(speed, "%d", speed_value);
lv_label_set_text_fmt(gear, "%d",gear_value);
if(gear_value !=7){
if(gear_value !=7)
{
lv_obj_clear_flag(gear,LV_OBJ_FLAG_HIDDEN);
lv_obj_add_flag(gear_null,LV_OBJ_FLAG_HIDDEN );
}else{
}
else
{
lv_obj_clear_flag(gear_null,LV_OBJ_FLAG_HIDDEN );
lv_obj_add_flag(gear,LV_OBJ_FLAG_HIDDEN );
}
@ -165,32 +305,40 @@ void refresh_timer_cb(lv_timer_t *t){
lv_meter_set_indicator_end_value(meter, indic1, speed_angle/20);
if(bar_value <60){
if(bar_value <60)
{
lv_meter_set_indicator_end_value(oil_meter, oil_indic1, bar_value);
lv_meter_set_indicator_end_value(oil_meter, oil_indic2, 60);
}else{
}
else
{
lv_meter_set_indicator_end_value(oil_meter, oil_indic1, 60);
lv_meter_set_indicator_end_value(oil_meter, oil_indic2, bar_value);
}
if(bar_value<210){
if(bar_value<210)
{
lv_meter_set_indicator_end_value(temp_meter, temp_indic1, bar_value);
lv_meter_set_indicator_end_value(temp_meter, temp_indic2, 210);
}else{
}
else
{
lv_meter_set_indicator_end_value(temp_meter, temp_indic1, 210);
lv_meter_set_indicator_end_value(temp_meter, temp_indic2, bar_value);
}
//转速指针
if(num%2==0)
speed_angle+=20;
else
speed_angle-=20;
if(speed_angle>=3000|| speed_angle ==0)
if(speed_angle >= 3000|| speed_angle == 0)
num++;
printf("num = %d\n", num);
printf("speed_angle = %d\n", speed_angle);
//速度
if(peed_num%2==0)
speed_value+=1;
@ -206,11 +354,11 @@ void refresh_timer_cb(lv_timer_t *t){
else
gear_value-=1;
if(gear_value>=7 || gear_value ==0){
if(gear_value>=7 || gear_value ==0)
{
gear_num++;
}
//温度油量
if(bar_num%2 ==0)
bar_value+=2;
@ -223,6 +371,7 @@ void refresh_timer_cb(lv_timer_t *t){
mileage++;
if(mileage>=888888)
mileage=0;
#endif
}
@ -264,7 +413,8 @@ static void demo_win_event_handle(lv_event_t *e)
}
void lv_demo(lv_obj_t *parent, lv_point_t *top){
void lv_demo(lv_obj_t *parent, lv_point_t *top)
{
// start_angle = atan2(center_y - 143, 199 - center_x) * 180 / M_PI;
// end_angle = atan2(center_y - 143, 284 - center_x) * 180 / M_PI;
// if(!lv_obj_is_valid(parent))
@ -281,20 +431,238 @@ void lv_demo(lv_obj_t *parent, lv_point_t *top){
lv_obj_set_size(win2_screen,LV_PCT(100),LV_PCT(100));
lv_obj_set_style_radius(win2_screen, 0, 0);
lv_obj_set_style_bg_color(win2_screen, lv_color_black(), NULL);
//
# if 1
lv_obj_clear_flag(win2_screen, LV_OBJ_FLAG_SCROLLABLE);
//背景 0
lv_obj_t* panel_bg_img = lv_img_big_create(win2_screen, panel_blackgroud_src, 106, 15, 6, 0);
//加载左转向 1
lv_obj_t* pTurnLeft = lv_img_create(win2_screen);
lv_obj_align(pTurnLeft, LV_ALIGN_TOP_LEFT, 12, 7);
lv_img_set_src(pTurnLeft, IMG_A36_LEFT_ICO);
//加载右转向 2
lv_obj_t* pTurnRight = lv_img_create(win2_screen);
lv_obj_align(pTurnRight, LV_ALIGN_TOP_LEFT, 446, 7);
lv_img_set_src(pTurnRight, IMG_A36_RIGHT_ICO);
//加载绿灯A 3
lv_obj_t* pGreenLightA = lv_img_create(win2_screen);
lv_obj_align(pGreenLightA, LV_ALIGN_TOP_LEFT, 52, 10);
lv_img_set_src(pGreenLightA, IMG_A36_GREENALIGHT_ICO);
//加载绿灯 4
lv_obj_t* pGreenLight = lv_img_create(win2_screen);
lv_obj_align(pGreenLight, LV_ALIGN_TOP_LEFT, 86, 10);
lv_img_set_src(pGreenLight, IMG_A36_GREENLIGHT_ICO);
//加载蓝灯 5
lv_obj_t* pBlueLight = lv_img_create(win2_screen);
lv_obj_align(pBlueLight, LV_ALIGN_TOP_LEFT, 119, 10);
lv_img_set_src(pBlueLight, IMG_A36_BLUELIGHT_ICO);
//加载蓝牙 6
lv_obj_t* pBlueTooth = lv_img_create(win2_screen);
lv_obj_align(pBlueTooth, LV_ALIGN_TOP_LEFT, 422, 10);
lv_img_set_src(pBlueTooth, IMG_A36_BLUETOOTH_ICO);
//加载右黄色图标1 7
lv_obj_t* pRightYellow1 = lv_img_create(win2_screen);
lv_obj_align(pRightYellow1, LV_ALIGN_TOP_LEFT, 425.8, 249.3);
lv_img_set_src(pRightYellow1, IMG_A36_RIGHTYELLOW1_ICO);
//加载右黄色图标2 8
lv_obj_t* pRightYellow2 = lv_img_create(win2_screen);
lv_obj_align(pRightYellow2, LV_ALIGN_TOP_LEFT, 395, 249);
lv_img_set_src(pRightYellow2, IMG_A36_RIGHTYELLOW2_ICO);
//加载右黄色图标3 9
lv_obj_t* pRightYellow3 = lv_img_create(win2_screen);
lv_obj_align(pRightYellow3, LV_ALIGN_TOP_LEFT, 352, 248.9);
lv_img_set_src(pRightYellow3, IMG_A36_RIGHTYELLOW3_ICO);
//加载左红色图标1 10
lv_obj_t* pLeftRed1 = lv_img_create(win2_screen);
lv_obj_align(pLeftRed1, LV_ALIGN_TOP_LEFT, 14, 250.67);
lv_img_set_src(pLeftRed1, IMG_A36_LEFTRED1_ICO);
//加载左红色图标2 11
lv_obj_t* pLeftRed2 = lv_img_create(win2_screen);
lv_obj_align(pLeftRed2, LV_ALIGN_TOP_LEFT, 107.7, 251.57);
lv_img_set_src(pLeftRed2, IMG_A36_LEFTRED2_ICO);
//加载水箱图标 12
lv_obj_t* pWaterTank = lv_img_create(win2_screen);
lv_obj_align(pWaterTank, LV_ALIGN_TOP_LEFT, 397, 71.6);
lv_img_set_src(pWaterTank, IMG_A36_WATER_ICO);
//加载水箱图标 13
lv_obj_t* pOilTank = lv_img_create(win2_screen);
lv_obj_align(pOilTank, LV_ALIGN_TOP_LEFT, 397, 175.7);
lv_img_set_src(pOilTank, IMG_A36_OIL_ICO);
//加载转速单位 14
lv_obj_t* pLabel_ESpeedUnit = lv_label_create(win2_screen);
lv_obj_set_style_text_font(pLabel_ESpeedUnit, LV_FONT_MXC_MSYAHEI_CT_10PX, LV_STATE_DEFAULT);
lv_label_set_text(pLabel_ESpeedUnit, "x1000r/min"); //实际使用需要换成一个变量
lv_obj_align(pLabel_ESpeedUnit, LV_ALIGN_TOP_LEFT, 209, 89);
//加载速度数据 15
lv_obj_t* pLabel_Speed = lv_label_create(win2_screen);
lv_obj_set_style_text_font(pLabel_Speed, LV_FONT_MXC_MSYAHEI_CT_48PX, LV_STATE_DEFAULT);
lv_label_set_text(pLabel_Speed, "135"); //实际使用需要换成一个变量
lv_obj_align(pLabel_Speed, LV_ALIGN_TOP_LEFT, 194, 107);
//加载速度单位 16
lv_obj_t* pLabel_SpeedUnit = lv_label_create(win2_screen);
lv_obj_set_style_text_font(pLabel_SpeedUnit, LV_FONT_MXC_MSYAHEI_CT_14PX, LV_STATE_DEFAULT);
lv_label_set_text(pLabel_SpeedUnit, "km/h");
lv_obj_align(pLabel_SpeedUnit, LV_ALIGN_TOP_LEFT, 221, 169);
//加载档位数据 17
lv_obj_t* pLabel_GearPos = lv_label_create(win2_screen);
lv_obj_set_style_text_font(pLabel_GearPos, LV_FONT_MXC_MSYAHEI_CT_36PX, LV_STATE_DEFAULT);
lv_label_set_text(pLabel_GearPos, "6");
lv_obj_align(pLabel_GearPos, LV_ALIGN_TOP_LEFT, 227, 187);
//加载当前时间数据 18
lv_obj_t* pLabel_TimeValue = lv_label_create(win2_screen);
lv_obj_set_style_text_font(pLabel_TimeValue, LV_FONT_MXC_MSYAHEI_CT_21PX, LV_STATE_DEFAULT);
lv_label_set_text(pLabel_TimeValue, "15:36");
lv_obj_align(pLabel_TimeValue, LV_ALIGN_TOP_LEFT, 210, 252);
//加载电瓶电压 19
lv_obj_t* pLabel_Valtage = lv_label_create(win2_screen);
lv_obj_set_style_text_font(pLabel_Valtage, LV_FONT_MXC_MSYAHEI_CT_14PX, LV_STATE_DEFAULT);
lv_label_set_text(pLabel_Valtage, "12.2V");
lv_obj_align(pLabel_Valtage, LV_ALIGN_TOP_LEFT, 44, 250);
//加载转速颜色圆弧 20
lv_obj_t* ui_Arc2 = lv_arc_create(win2_screen);
lv_obj_set_width(ui_Arc2, 300);
lv_obj_set_height(ui_Arc2, 300);
lv_obj_set_x(ui_Arc2, -1); //修改调整圆弧图片坐标(-1,-15)
lv_obj_set_y(ui_Arc2, -15);
lv_obj_set_align(ui_Arc2, LV_ALIGN_CENTER);
lv_arc_set_range(ui_Arc2, 0, 120); //设置圆弧值的范围(转速值缩小100倍)
lv_arc_set_value(ui_Arc2, 110); //设置圆弧的实际大小
lv_obj_set_style_arc_color(ui_Arc2, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_arc_opa(ui_Arc2, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_arc_width(ui_Arc2, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_arc_width(ui_Arc2, 100, LV_PART_INDICATOR | LV_STATE_DEFAULT);
lv_obj_set_style_arc_rounded(ui_Arc2, false, LV_PART_INDICATOR | LV_STATE_DEFAULT);
//lv_obj_set_style_arc_img_src(ui_Arc2, &ui_img_a36_colorbar_png, LV_PART_INDICATOR | LV_STATE_DEFAULT);
lv_obj_set_style_arc_img_src(ui_Arc2, &A36_colorbar_cfile, 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);
/* //图片21
// lv_obj_t* ui_Image2 = lv_img_create(win2_screen);
// //lv_img_set_src(ui_Image2, &A36_colorbar_cfile);
// lv_obj_set_style_arc_img_src(ui_Arc2, &A36_colorbar_cfile, LV_PART_INDICATOR | LV_STATE_DEFAULT);
// lv_obj_set_width(ui_Image2, LV_SIZE_CONTENT); /// 269
// lv_obj_set_height(ui_Image2, LV_SIZE_CONTENT); /// 218
// lv_obj_set_x(ui_Image2, 230);
// lv_obj_set_y(ui_Image2, -32);
// lv_obj_set_align(ui_Image2, LV_ALIGN_CENTER);
// lv_obj_add_flag(ui_Image2, LV_OBJ_FLAG_ADV_HITTEST); /// Flags
// lv_obj_clear_flag(ui_Image2, LV_OBJ_FLAG_SCROLLABLE); /// Flags
*/
//加载转速数字和刻度 21
lv_obj_t* panel_numscale_img = lv_img_big_create(win2_screen, panel_numscale_src, 114, 22, 3, 0);
//加载水箱颜色 22
lv_obj_t* ui_ArcWaterbar1 = lv_arc_create(win2_screen);
lv_obj_set_width(ui_ArcWaterbar1, 80);
lv_obj_set_height(ui_ArcWaterbar1, 80);
lv_obj_set_x(ui_ArcWaterbar1, 182); //重新调整的坐标位置
lv_obj_set_y(ui_ArcWaterbar1, -49);
lv_obj_set_align(ui_ArcWaterbar1, LV_ALIGN_CENTER);
lv_arc_set_bg_angles(ui_ArcWaterbar1, 300, 60);
lv_obj_set_style_arc_color(ui_ArcWaterbar1, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_arc_opa(ui_ArcWaterbar1, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_arc_width(ui_ArcWaterbar1, 30, LV_PART_INDICATOR | LV_STATE_DEFAULT);
lv_obj_set_style_arc_rounded(ui_ArcWaterbar1, false, LV_PART_INDICATOR | LV_STATE_DEFAULT);
lv_obj_set_style_arc_img_src(ui_ArcWaterbar1, &A36_waterbar1_cfile, LV_PART_INDICATOR | LV_STATE_DEFAULT);
lv_obj_set_style_bg_color(ui_ArcWaterbar1, lv_color_hex(0xFFFFFF), LV_PART_KNOB | LV_STATE_DEFAULT);
lv_obj_set_style_bg_opa(ui_ArcWaterbar1, 0, LV_PART_KNOB | LV_STATE_DEFAULT);
lv_arc_set_range(ui_ArcWaterbar1, 0, 100); //设置圆弧值的范围(转速值缩小100倍)
lv_arc_set_value(ui_ArcWaterbar1, 100);
//加载油箱颜色 23
lv_obj_t* ui_ArcOilbar1 = lv_arc_create(win2_screen);
lv_obj_set_width(ui_ArcOilbar1, 80);
lv_obj_set_height(ui_ArcOilbar1, 80);
lv_obj_set_x(ui_ArcOilbar1, 182); //重新调整的坐标位置
lv_obj_set_y(ui_ArcOilbar1, 55);
lv_obj_set_align(ui_ArcOilbar1, LV_ALIGN_CENTER);
lv_arc_set_bg_angles(ui_ArcOilbar1, 300, 60);
lv_obj_set_style_arc_color(ui_ArcOilbar1, lv_color_hex(0xFFFFFF), LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_arc_opa(ui_ArcOilbar1, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_arc_width(ui_ArcOilbar1, 30, LV_PART_INDICATOR | LV_STATE_DEFAULT);
lv_obj_set_style_arc_rounded(ui_ArcOilbar1, false, LV_PART_INDICATOR | LV_STATE_DEFAULT);
lv_obj_set_style_arc_img_src(ui_ArcOilbar1, &A36_oilbar1_cfile, LV_PART_INDICATOR | LV_STATE_DEFAULT);
lv_obj_set_style_bg_color(ui_ArcOilbar1, lv_color_hex(0xFFFFFF), LV_PART_KNOB | LV_STATE_DEFAULT);
lv_obj_set_style_bg_opa(ui_ArcOilbar1, 0, LV_PART_KNOB | LV_STATE_DEFAULT);
lv_arc_set_range(ui_ArcOilbar1, 0, 100); //范围(转速值缩小100倍)
lv_arc_set_value(ui_ArcOilbar1, 100);
//加载水箱和邮箱刻度图标 24 25
lv_obj_t* pWatersScale = lv_img_create(win2_screen);
lv_obj_align(pWatersScale, LV_ALIGN_TOP_LEFT, 433, 54);
lv_img_set_src(pWatersScale, IMG_A36_WATERSCALE_ICO);
lv_obj_t* pOilScale = lv_img_create(win2_screen);
lv_obj_align(pOilScale, LV_ALIGN_TOP_LEFT, 433, 158);
lv_img_set_src(pOilScale, IMG_A36_OILSCALE_ICO);
//转速指针 26
lv_obj_t* pESpeedPoint_img = lv_img_create(win2_screen);
lv_img_set_src(pESpeedPoint_img, IMG_A36_ESPEEDPOINT_ICO);
lv_obj_update_layout(pESpeedPoint_img); //更新图片布局信息
lv_obj_align(pESpeedPoint_img, LV_ALIGN_TOP_LEFT, 190, 193); //原始计算坐标(194,183),修正坐标(190,193) x-4,y+10
lv_img_set_pivot(pESpeedPoint_img, 46, -45); //原始计算坐标(45, -45),修正坐标 (46,-45)
lv_img_set_angle(pESpeedPoint_img, 3000);
//水箱指针 27 (图形失真)
lv_obj_t* pWaterpoint_img = lv_img_create(win2_screen);
lv_img_set_src(pWaterpoint_img, IMG_A36_WATERPOINT_ICO);
lv_obj_update_layout(pWaterpoint_img); //更新图片布局信息
lv_obj_align(pWaterpoint_img, LV_ALIGN_TOP_LEFT, 369, 37); //原始计算坐标(366,41),修正坐标(369,37) x+3,y-4
lv_img_set_pivot(pWaterpoint_img, 44, 48); //原始计算坐标(44, 44),修正坐标(44,48)
lv_img_set_angle(pWaterpoint_img, -900);
//油箱指针 28 (图形失真)
lv_obj_t* pOilpoint_img = lv_img_create(win2_screen);
lv_img_set_src(pOilpoint_img, IMG_A36_OILPOINT_ICO);
lv_obj_update_layout(pOilpoint_img); //更新图片布局信息
lv_obj_align(pOilpoint_img, LV_ALIGN_TOP_LEFT, 369, 142); //原始计算坐标(366,146),修正坐标(369,142) x+3,y-4
lv_img_set_pivot(pOilpoint_img, 44, 48); //原始计算坐标(44, 44),修正坐标(44,48)
lv_img_set_angle(pOilpoint_img, -900);
lv_obj_t* demo_group = get_key_group();
lv_group_add_obj(demo_group, win2_screen);
lv_obj_add_event_cb(win2_screen, demo_win_event_handle, LV_EVENT_KEY, NULL);
// lv_timer_t * ui_refresh_timer = get_ui_refresh_timer();
time_refresh_timer = lv_timer_create(refresh_timer_cb, 1000, win2_screen);
#else if
// UI_PARENT_INIT(win2_screen);
lv_obj_clear_flag(win2_screen, LV_OBJ_FLAG_SCROLLABLE );
lv_obj_clear_flag(win2_screen, LV_OBJ_FLAG_SCROLLABLE);
//背景
lv_obj_t* panel_bg_img1 = lv_img_big_create(win2_screen,panel_demo1_src,176,2,5,0);
lv_obj_t* panel_bg_img1 = lv_img_big_create(win2_screen, panel_demo1_src, 176, 2, 5, 0);
//arc外边框
lv_obj_t* panel_bg_img2 = lv_img_big_create(win2_screen,panel_bg2_src,15,17,3,0);//0
lv_obj_t* panel_bg_img2 = lv_img_big_create(win2_screen, panel_bg2_src, 15, 17 ,3 , 0);//0
// //刻度
// lv_obj_t* panel_bg_img3 = lv_img_big_create(parent,panel_bg3_src,25,25,3,0);//0
// bar
meter = lv_meter_create(win2_screen);
lv_obj_remove_style(meter, NULL, LV_PART_INDICATOR); //meterԲ<72>IJ<EFBFBD><C4B2><EFBFBD>ʾ
@ -367,7 +735,7 @@ void lv_demo(lv_obj_t *parent, lv_point_t *top){
lv_arc_set_value(ui_Arc1, 0);
lv_arc_set_bg_angles(ui_Arc1, 0, 300);
lv_arc_set_rotation(ui_Arc1, 90);
lv_obj_set_style_arc_opa(ui_Arc1, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_arc_opa(ui_Arc1, 0, LV_PART_MAIN|LV_STATE_DEFAULT);
lv_obj_set_style_arc_color(ui_Arc1, lv_color_hex(0x9393FF), LV_PART_INDICATOR | LV_STATE_DEFAULT);
lv_obj_set_style_arc_opa(ui_Arc1, 255, LV_PART_INDICATOR | LV_STATE_DEFAULT);
@ -378,8 +746,6 @@ void lv_demo(lv_obj_t *parent, lv_point_t *top){
lv_obj_remove_style(ui_Arc1, NULL, LV_PART_KNOB); /*Be sure the knob is not displayed*/
lv_obj_clear_flag(ui_Arc1, LV_OBJ_FLAG_CLICKABLE); /*To not allow adjusting by click*/
//指针
lv_obj_t *hand_img = lv_img_create(win2_screen);//4
lv_img_set_src(hand_img,IMG_POINTER2);
@ -391,7 +757,7 @@ void lv_demo(lv_obj_t *parent, lv_point_t *top){
lv_obj_set_style_text_align(speed, LV_TEXT_ALIGN_CENTER, 0);
lv_obj_center(speed);
lv_obj_set_pos(speed,-105,-10);
lv_obj_set_style_text_font(speed,LV_FONT_MXC_WRYH_CT_72PX,0);
lv_obj_set_style_text_font(speed, LV_FONT_MXC_WRYH_CT_72PX, 0);
lv_label_set_text_fmt(speed, "%d",speed_value);
lv_obj_t * gear = lv_label_create(win2_screen);
@ -514,6 +880,9 @@ void lv_demo(lv_obj_t *parent, lv_point_t *top){
// lv_timer_t * ui_refresh_timer = get_ui_refresh_timer();
time_refresh_timer = lv_timer_create(refresh_timer_cb,50,win2_screen);
#endif
}

View File

@ -0,0 +1,519 @@
#include "lvgl.h"
#include "img_def.h"
#include "demo.h"
//#include "lv_common_function.h"
#include "img_basic.h"
#include "spde_ipc.h"
#include "mxc_meter.h"
static uint8_t background_style = 0;
#define M_PI 3.14
static int center_x = 242, center_y = 119;
static int radius = 51;
static double start_angle = 0;
static double end_angle = 0;
static float progress =0.0;
#define TEST_FUN 0
#define HOME_KEY_BIT 0x08
#define ENTER_KEY_BIT 0x10
#define UP_KEY_BIT 0x20
#define DOWN_KEY_BIT 0x40
#define END_KEY_BIT 0x80
#define SHORT_KEY_BIT 0x01
#define MULTI_KEY_BIT 0x02
#define LONG_KEY_BIT 0x04
#define KEY_CODE_HOME HOME_KEY_BIT|SHORT_KEY_BIT //0000 1001 0x09
#define KEY_CODE_ENTER ENTER_KEY_BIT|SHORT_KEY_BIT //0001 0001 0x11
static const char show_scale_x[13]={22,-18,-53,-74,-75,-60,-25,18 ,62 ,99,120,126,118};
static const char show_scale_y[13]={120,110,81,40, -3 ,-44,-76,-88,-81,-61,-22,20,60};
extern lv_timer_t * time_refresh_timer;
lv_obj_t *meter;
lv_meter_indicator_t * indic;
lv_meter_indicator_t * indic1;
lv_obj_t * oil_meter;
lv_meter_indicator_t *oil_indic1;
lv_meter_indicator_t *oil_indic2;
lv_obj_t * temp_meter;
lv_meter_indicator_t *temp_indic1;
lv_meter_indicator_t *temp_indic2;
static int speed_angle = 0;
static int speed_value = 0;
static int bar_value = 0;
static int gear_value = 0;
#define CANVAS_WIDTH 200
#define CANVAS_HEIGHT 200
void creatRootObj(void);
void Enter_screen_id(lv_obj_t *parent_main);
void win_init(void){
uint8_t ui_mode = 0;
// creatRootObj();
lv_group_t * scr_key_group =get_key_group();
lv_win32_add_all_input_devices_to_group(scr_key_group);
system_date_init();
ui_mode = spde_ipc_get_ui_mode();
switch (ui_mode)
{
case UI_MODE_NORMAL:
Enter_screen_id(get_root_win());
break;
case UI_MODE_CHARGE:
break;
case UI_MODE_OTA:
break;
case UI_MODE_POWER_OFF:
break;
case UI_MODE_POWER_ON:
break;
case UI_MODE_CHARGE_FULL:
break;
default:
Enter_screen_id(get_root_win());
break;
}
}
void Enter_screen_id(lv_obj_t *parent_main){
daily_data_t *local_data = daily_get_UiData();
Set_UI_page_id(get_top_history_win());
if(local_data->ui_page_id == IDLE_CONTROL_WIN_ID)
{
printf("enter_demo . \n");
lv_demo(parent_main,NULL);
// enter_control_main_win(parent_main);
}
else if(local_data->ui_page_id == PAGE_MAINMENU_WIN_ID)
{
printf("enter_list . \n");
// enter_mainmenu_win(parent_main);
}
}
void refresh_timer_cb(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");
return;
}
if(parent ==NULL){
printf("parent ==NULL\n");
return;
}
if(Get_sys_power_on_self_test() ==0)
return;
static int num=0,bar_num=0,peed_num=0,gear_num=0,mileage=0;
uint8_t scale_num;
//指针刷新
lv_obj_t * ui_Arc1 = lv_obj_get_child(parent,5);
lv_obj_t * hand_img = lv_obj_get_child(parent,6);
lv_obj_t * speed = lv_obj_get_child(parent,7);
lv_obj_t * gear = lv_obj_get_child(parent,8);
lv_obj_t * gear_null = lv_obj_get_child(parent,9);
lv_obj_t * tcs = lv_obj_get_child(parent,10);
lv_obj_t * time_label = lv_obj_get_child(parent,11);
lv_obj_t * max_speed = lv_obj_get_child(parent,12);
lv_obj_t * avg_speed = lv_obj_get_child(parent,13);
lv_obj_t * trip_mileage = lv_obj_get_child(parent,14);
lv_obj_t * odo_mileage = lv_obj_get_child(parent,15);
lv_img_set_angle(hand_img,speed_angle);
lv_arc_set_value(ui_Arc1, (speed_angle/25));
//lv_arc_set_value(ui_Arc1, (speed_angle/25));
lv_label_set_text_fmt(speed, "%d",speed_value);
lv_label_set_text_fmt(gear, "%d",gear_value);
if(gear_value !=7){
lv_obj_clear_flag(gear,LV_OBJ_FLAG_HIDDEN);
lv_obj_add_flag(gear_null,LV_OBJ_FLAG_HIDDEN );
}else{
lv_obj_clear_flag(gear_null,LV_OBJ_FLAG_HIDDEN );
lv_obj_add_flag(gear,LV_OBJ_FLAG_HIDDEN );
}
lv_label_set_text(time_label, GetCurTimeString());
lv_label_set_text_fmt(max_speed, "%d",speed_value);
lv_label_set_text_fmt(avg_speed, "%d",speed_value);
lv_label_set_text_fmt(trip_mileage, "%d",speed_value);
lv_label_set_text_fmt(odo_mileage, "%d",speed_value);
scale_num = (speed_angle/250) ;
lv_meter_set_indicator_end_value(meter, indic1, speed_angle/20);
if(bar_value <60){
lv_meter_set_indicator_end_value(oil_meter, oil_indic1, bar_value);
lv_meter_set_indicator_end_value(oil_meter, oil_indic2, 60);
}else{
lv_meter_set_indicator_end_value(oil_meter, oil_indic1, 60);
lv_meter_set_indicator_end_value(oil_meter, oil_indic2, bar_value);
}
if(bar_value<210){
lv_meter_set_indicator_end_value(temp_meter, temp_indic1, bar_value);
lv_meter_set_indicator_end_value(temp_meter, temp_indic2, 210);
}else{
lv_meter_set_indicator_end_value(temp_meter, temp_indic1, 210);
lv_meter_set_indicator_end_value(temp_meter, temp_indic2, bar_value);
}
//转速指针
if(num%2==0)
speed_angle+=20;
else
speed_angle-=20;
if(speed_angle>=3000|| speed_angle ==0)
num++;
//速度
if(peed_num%2==0)
speed_value+=1;
else
speed_value-=1;
if(speed_value>=255 || speed_value ==0)
peed_num++;
//档位
if(gear_num%2==0)
gear_value+=1;
else
gear_value-=1;
if(gear_value>=7 || gear_value ==0){
gear_num++;
}
//温度油量
if(bar_num%2 ==0)
bar_value+=2;
else
bar_value-=2;
if(bar_value>=270 || bar_value==0)
bar_num++;
mileage++;
if(mileage>=888888)
mileage=0;
}
static void demo_win_event_handle(lv_event_t *e)
{
lv_event_code_t code = lv_event_get_code(e);
uint8_t key_code = 0;
uint32_t *key = lv_event_get_param(e);
key_code = (uint8_t)*key;
printf("demo_win_event_handle==========.\n");
if (code == LV_EVENT_KEY)
{
uint32_t *key = lv_event_get_param(e);
key_code = (uint8_t)*key;
printf("key_code = %d . code = 0x%02d \n",key_code,code);
switch (key_code)
{
case LV_KEY_W:
close_ui_refresh_timer();
close_all_win();
if (time_refresh_timer != NULL)
{
lv_timer_del(time_refresh_timer);
time_refresh_timer = NULL;
}
enter_mainmenu_win(get_root_win());
break;
default:
break;
}
}
}
void lv_demo(lv_obj_t *parent, lv_point_t *top){
// start_angle = atan2(center_y - 143, 199 - center_x) * 180 / M_PI;
// end_angle = atan2(center_y - 143, 284 - center_x) * 180 / M_PI;
// if(!lv_obj_is_valid(parent))
// return;
lv_obj_t *win2_screen = lv_obj_create(parent);
lv_obj_set_style_pad_all(win2_screen, 0, 0);
lv_obj_set_style_border_width(win2_screen, 0, 0);
lv_obj_set_style_opa(win2_screen, LV_OPA_100, 0);
lv_obj_set_scrollbar_mode(win2_screen, LV_SCROLLBAR_MODE_ACTIVE);
lv_obj_clear_flag(win2_screen, LV_OBJ_FLAG_SCROLL_ELASTIC);
lv_obj_clear_flag(win2_screen, LV_OBJ_FLAG_GESTURE_BUBBLE);
// lv_obj_set_size(win2_screen, 320, 170);
lv_obj_set_size(win2_screen,LV_PCT(100),LV_PCT(100));
lv_obj_set_style_radius(win2_screen, 0, 0);
lv_obj_set_style_bg_color(win2_screen, lv_color_black(), NULL);
//
// UI_PARENT_INIT(win2_screen);
lv_obj_clear_flag(win2_screen, LV_OBJ_FLAG_SCROLLABLE );
//背景
lv_obj_t* panel_bg_img1 = lv_img_big_create(win2_screen,panel_demo1_src,176,2,5,0);
//arc外边框
lv_obj_t* panel_bg_img2 = lv_img_big_create(win2_screen,panel_bg2_src,15,17,3,0);//0
// //刻度
// lv_obj_t* panel_bg_img3 = lv_img_big_create(parent,panel_bg3_src,25,25,3,0);//0
// bar
meter = lv_meter_create(win2_screen);
lv_obj_remove_style(meter, NULL, LV_PART_INDICATOR); //meterԲ<72>IJ<EFBFBD><C4B2><EFBFBD>ʾ
lv_obj_remove_style(meter, NULL, LV_PART_MAIN);
lv_obj_set_size(meter, 228, 228);
lv_obj_align(meter,LV_ALIGN_CENTER,-109,-3);
lv_meter_scale_t * scale = lv_meter_add_scale(meter);
lv_meter_set_scale_ticks(meter, scale, 0, 1, 5, lv_palette_main(LV_PALETTE_GREY));
lv_meter_set_scale_range(meter, scale, 0, 150, 300, 90);
indic1 = lv_meter_add_arc(meter, scale, 18, lv_color_hex(0x62d5f9), 0);
// indic = lv_meter_add_needle_line(meter, scale, 4, lv_palette_main(LV_PALETTE_GREY), -10);
//oil bar
oil_meter= lv_meter_create(win2_screen);
lv_obj_remove_style(oil_meter, NULL, LV_PART_MAIN);
lv_obj_remove_style(oil_meter, NULL, LV_PART_INDICATOR);
lv_meter_scale_t * oil_scale;
oil_scale = lv_meter_add_scale(oil_meter);
lv_meter_set_scale_range(oil_meter, oil_scale, 0, 270, 270, 90);
lv_meter_set_scale_ticks(oil_meter, oil_scale, 0, 3, 12, lv_color_white());
oil_indic1 = lv_meter_add_arc(oil_meter, oil_scale, 6, lv_color_hex(0xff0000), 0);
lv_meter_set_indicator_start_value(oil_meter, oil_indic1, 0);
// lv_meter_set_indicator_end_value(oil_meter, oil_indic1, 60);//设置范围
lv_meter_set_indicator_end_value(oil_meter, oil_indic1, 0);//设置范围
oil_indic2 = lv_meter_add_arc(oil_meter, oil_scale, 6, lv_color_hex(0x00ff00), 0);
lv_meter_set_indicator_start_value(oil_meter, oil_indic2, 60);
// lv_meter_set_indicator_end_value(oil_meter, oil_indic2, 270);
lv_meter_set_indicator_end_value(oil_meter, oil_indic2, 60);//初始值
lv_obj_update_layout(win2_screen);
lv_obj_set_size(oil_meter, 45, 45);
lv_obj_align(oil_meter,LV_ALIGN_TOP_LEFT,140,217);
//temp bar
temp_meter = lv_meter_create(win2_screen);
lv_obj_remove_style(temp_meter, NULL, LV_PART_MAIN);
lv_obj_remove_style(temp_meter, NULL, LV_PART_INDICATOR);
lv_meter_scale_t * temp_scale;
temp_scale = lv_meter_add_scale(temp_meter);
lv_meter_set_scale_range(temp_meter, temp_scale, 0, 270, 270, 90);
lv_meter_set_scale_ticks(temp_meter, temp_scale, 0, 3, 12, lv_color_white());
temp_indic1 = lv_meter_add_arc(temp_meter, temp_scale, 6, lv_color_hex(0x0070BB), 0);
lv_meter_set_indicator_start_value(temp_meter, temp_indic1, 0);
// lv_meter_set_indicator_end_value(temp_meter, temp_indic1, 210);
lv_meter_set_indicator_end_value(temp_meter, temp_indic1, 0);
temp_indic2 = lv_meter_add_arc(temp_meter, temp_scale, 6, lv_color_hex(0xff0000), 0);
lv_meter_set_indicator_start_value(temp_meter, temp_indic2, 210);
// lv_meter_set_indicator_end_value(temp_meter, temp_indic2, 270);
lv_meter_set_indicator_end_value(temp_meter, temp_indic2, 210);
lv_obj_update_layout(win2_screen);
lv_obj_set_size(temp_meter, 45, 45);
lv_obj_align(temp_meter,LV_ALIGN_TOP_LEFT,180,191);
lv_obj_t * ui_Arc1 = lv_arc_create(win2_screen);
lv_obj_set_width(ui_Arc1, 230);
lv_obj_set_height(ui_Arc1, 230);
lv_obj_set_x(ui_Arc1, 16);
lv_obj_set_y(ui_Arc1, 17);
lv_arc_set_range(ui_Arc1, 0, 120);
lv_arc_set_value(ui_Arc1, 0);
lv_arc_set_bg_angles(ui_Arc1, 0, 300);
lv_arc_set_rotation(ui_Arc1, 90);
lv_obj_set_style_arc_opa(ui_Arc1, 0, LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_arc_color(ui_Arc1, lv_color_hex(0x9393FF), LV_PART_INDICATOR | LV_STATE_DEFAULT);
lv_obj_set_style_arc_opa(ui_Arc1, 255, LV_PART_INDICATOR | LV_STATE_DEFAULT);
lv_obj_set_style_arc_width(ui_Arc1, 30, LV_PART_INDICATOR | LV_STATE_DEFAULT);
lv_obj_set_style_arc_rounded(ui_Arc1, false, LV_PART_INDICATOR | LV_STATE_DEFAULT);
lv_obj_set_style_arc_img_src(ui_Arc1, &speed_arc, LV_PART_INDICATOR | LV_STATE_DEFAULT);
lv_obj_set_style_bg_opa(ui_Arc1, 0, LV_PART_KNOB | LV_STATE_DEFAULT);
lv_obj_remove_style(ui_Arc1, NULL, LV_PART_KNOB); /*Be sure the knob is not displayed*/
lv_obj_clear_flag(ui_Arc1, LV_OBJ_FLAG_CLICKABLE); /*To not allow adjusting by click*/
//指针
lv_obj_t *hand_img = lv_img_create(win2_screen);//4
lv_img_set_src(hand_img,IMG_POINTER2);
lv_obj_align(hand_img,LV_ALIGN_CENTER,-108,93);
lv_img_set_pivot(hand_img, 3, -81);
lv_img_set_angle(hand_img, 0);
lv_obj_t * speed = lv_label_create(win2_screen);
lv_obj_set_style_text_align(speed, LV_TEXT_ALIGN_CENTER, 0);
lv_obj_center(speed);
lv_obj_set_pos(speed,-105,-10);
lv_obj_set_style_text_font(speed,LV_FONT_MXC_WRYH_CT_72PX,0);
lv_label_set_text_fmt(speed, "%d",speed_value);
lv_obj_t * gear = lv_label_create(win2_screen);
lv_obj_set_pos(gear, 120, 180);
// lv_obj_align_to(gear,panel_bg_img2,LV_ALIGN_CENTER,25,75);
lv_obj_set_style_text_font(gear,LV_FONT_MXC_WRYH_CT_30PX,0);
// lv_label_set_text_fmt(gear, "3",gear_value);
lv_obj_t * gear_null = lv_img_create(win2_screen);
lv_obj_set_pos(gear_null, 120, 183);
// lv_obj_align_to(gear_null,panel_bg_img2,LV_ALIGN_CENTER,-5,58);
lv_img_set_src(gear_null, IMG_DM1_NULL);
lv_obj_t * tcs = lv_img_create(win2_screen);
lv_obj_align(tcs,LV_ALIGN_BOTTOM_LEFT,10,-10);
lv_img_set_src(tcs, IMG_DM1_TCS);
lv_obj_t * time_label = lv_label_create(win2_screen);
lv_obj_set_pos(time_label, 10, 10);
lv_obj_set_style_text_font(time_label,LV_FONT_MXC_WRYH_CT_20PX,0);
lv_label_set_text(time_label, GetCurTimeString());
lv_obj_t * max_speed = lv_label_create(win2_screen);
lv_obj_set_pos(max_speed, -50, 20);
lv_obj_set_align(max_speed, LV_ALIGN_TOP_RIGHT);
lv_obj_set_style_text_font(max_speed,LV_FONT_MXC_WRYH_CT_30PX,0);
lv_label_set_text(max_speed,"255");
lv_obj_t * avg_speed = lv_label_create(win2_screen);
lv_obj_set_pos(avg_speed, -50, -35);
lv_obj_set_align(avg_speed, LV_ALIGN_RIGHT_MID);
lv_obj_set_style_text_font(avg_speed,LV_FONT_MXC_WRYH_CT_30PX,0);
lv_label_set_text(avg_speed, "254");
lv_obj_t * trip = lv_label_create(win2_screen);
lv_obj_set_pos(trip, -30, 40);
lv_obj_set_align(trip, LV_ALIGN_RIGHT_MID);
lv_obj_set_style_text_font(trip,LV_FONT_MXC_WRYH_CT_30PX,0);
lv_label_set_text(trip, "888888");
lv_obj_t * total = lv_label_create(win2_screen);
lv_obj_set_pos(total, -30, -20);
lv_obj_set_align(total, LV_ALIGN_BOTTOM_RIGHT);
lv_obj_set_style_text_font(total,LV_FONT_MXC_WRYH_CT_30PX,0);
lv_label_set_text(total, "888888");
lv_obj_t * img_oil = lv_img_create(win2_screen);
lv_obj_align_to(img_oil,oil_meter,LV_ALIGN_CENTER,-7,-7);
lv_img_set_src(img_oil, IMG_DM1_OIL);
lv_obj_t * img_temp = lv_img_create(win2_screen);
lv_obj_align_to(img_temp,temp_meter,LV_ALIGN_CENTER,-7,-7);
lv_img_set_src(img_temp, IMG_DM1_TEMP);
lv_obj_t * speed_uint = lv_label_create(win2_screen);
lv_obj_set_pos(speed_uint, 90, 64);
// lv_obj_align_to(speed_uint,panel_bg_img2,LV_ALIGN_CENTER,-10,-40);
lv_obj_set_style_text_font(speed_uint,LV_FONT_MXC_WRYH_CT_16PX,0);
lv_label_set_text(speed_uint, "1000r/min");
lv_obj_t * speed_uint2 = lv_label_create(win2_screen);
lv_obj_set_pos(speed_uint2, 110, 160);
//lv_obj_align_to(speed_uint2,panel_bg_img2,LV_ALIGN_CENTER,10,50);
lv_obj_set_style_text_font(speed_uint2,LV_FONT_MXC_WRYH_CT_16PX,0);
lv_label_set_text(speed_uint2, "km/h");
lv_obj_t * speed_uint3 = lv_label_create(win2_screen);
lv_obj_set_pos(speed_uint3, 435, 28);
lv_obj_set_style_text_font(speed_uint3,LV_FONT_MXC_WRYH_CT_16PX,0);
lv_label_set_text(speed_uint3, "km/h");
lv_obj_t * speed_uint4 = lv_label_create(win2_screen);
lv_obj_set_pos(speed_uint4, 435, 98);
lv_obj_set_style_text_font(speed_uint4,LV_FONT_MXC_WRYH_CT_16PX,0);
lv_label_set_text(speed_uint4, "km/h");
lv_obj_t * mileage_uint1 = lv_label_create(win2_screen);
lv_obj_set_pos(mileage_uint1, 450, 173);
lv_obj_set_style_text_font(mileage_uint1,LV_FONT_MXC_WRYH_CT_16PX,0);
lv_label_set_text(mileage_uint1, "km");
lv_obj_t * mileage_uint2 = lv_label_create(win2_screen);
lv_obj_set_pos(mileage_uint2, 450, 238);
lv_obj_set_style_text_font(mileage_uint2,LV_FONT_MXC_WRYH_CT_16PX,0);
lv_label_set_text(mileage_uint2, "km");
lv_obj_t * max_speed_label = lv_label_create(win2_screen);
lv_obj_set_pos(max_speed_label, 300, 25);
lv_obj_set_style_text_font(max_speed_label,LV_FONT_MXC_WRYH_CT_16PX,0);
lv_label_set_text(max_speed_label, "最高时速:");
lv_obj_t * avg_speed_label = lv_label_create(win2_screen);
lv_obj_set_pos(avg_speed_label, 300, 90);
// lv_obj_set_align(avg_speed_label, LV_ALIGN_RIGHT_MID);
lv_obj_set_style_text_font(avg_speed_label,LV_FONT_MXC_WRYH_CT_16PX,0);
lv_label_set_text(avg_speed_label, "平均时速:");
lv_obj_t * trip_label = lv_label_create(win2_screen);
lv_obj_set_pos(trip_label, 300, 140);
lv_obj_set_style_text_font(trip_label,LV_FONT_MXC_WRYH_CT_16PX,0);
lv_label_set_text(trip_label, "小计里程:");
lv_obj_t * total_label = lv_label_create(win2_screen);
lv_obj_set_pos(total_label, 299, 210);
lv_obj_set_style_text_font(total_label,LV_FONT_MXC_WRYH_CT_16PX,0);
lv_label_set_text(total_label, "总计里程:");
self_checking_animo(win2_screen);
lv_obj_t *demo_group = get_key_group();
lv_group_add_obj(demo_group, win2_screen);
// lv_obj_add_flag(win2_screen, LV_STATE_FOCUSED );
// lv_obj_add_flag(win2_screen, LV_STATE_FOCUS_KEY );
// lv_obj_add_state(win2_screen, LV_STATE_FOCUSED );
// lv_obj_add_state(win2_screen, LV_STATE_FOCUS_KEY );
lv_obj_add_event_cb(win2_screen, demo_win_event_handle, LV_EVENT_KEY, NULL);
// lv_timer_t * ui_refresh_timer = get_ui_refresh_timer();
time_refresh_timer = lv_timer_create(refresh_timer_cb,50,win2_screen);
}

View File

@ -0,0 +1,510 @@
#include <stdio.h>
#include <string.h>
#include "mx_store.h"
#include "mx_alternator_data.h"
extern Store_t UserData;
uint8_t getSoftMainVersion(void)
{
return UserData.mSoftMainVersion;
}
void setSoftMainVersion(uint8_t value)
{
if(value != UserData.mSoftMainVersion)
{
UserData.mSoftMainVersion = value;
}
}
uint8_t getSoftSubVersion(void)
{
return UserData.mSoftSubVersion;
}
void setSoftSubVersion(uint8_t value)
{
if(value != UserData.mSoftSubVersion)
{
UserData.mSoftSubVersion = value;
}
}
uint8_t getSetMode(void)
{
return UserData.mSetMode;
}
void setSetMode(uint8_t value)
{
if(value != UserData.mSetMode)
{
UserData.mSetMode = value;
}
}
uint16_t getSpeedData(void)
{
return UserData.mSpeed;
}
void setSpeedData(uint16_t value)
{
if(value != UserData.mSpeed)
{
UserData.mSpeed = value;
}
}
//档位信息
uint8_t getGearInfo(void)
{
return UserData.mGearInfo;
}
void setGearInfo(uint8_t value)
{
if(value != UserData.mGearInfo)
{
UserData.mGearInfo = value;
}
}
//总计里程
uint32_t getTotalMile(void)
{
return UserData.mTotalMile;
}
void setTotalMile(uint32_t value)
{
if(value != UserData.mTotalMile)
{
UserData.mTotalMile = value;
}
}
//单次行驶里程
uint32_t getTripMile(void)
{
return UserData.mTripMile;
}
void setTripMile(uint32_t value)
{
if(value != UserData.mTripMile)
{
UserData.mTripMile = value;
}
}
//里程清零
uint8_t getMileClearTags(void)
{
return UserData.mMileClearTags;
}
void setMileClearTags(uint8_t value)
{
if(value != UserData.mMileClearTags)
{
UserData.mMileClearTags = value;
}
}
//wifi
uint8_t getWifi(void)
{
return UserData.mWifi;
}
void setWifi(uint8_t value)
{
if(value != UserData.mWifi)
{
UserData.mWifi = value;
}
}
//蓝牙
uint8_t getBlueTooth(void)
{
return UserData.mBlueTooth;
}
void setBlueTooth(uint8_t value)
{
if(value != UserData.mBlueTooth)
{
UserData.mBlueTooth = value;
}
}
//转向
uint8_t getTurn(void)
{
return UserData.mTurn;
}
void setTurn(uint8_t value)
{
if(value != UserData.mTurn)
{
UserData.mTurn = value;
}
}
//转向提示
uint8_t getTurnPrompt(void)
{
return UserData.mTurnPrompt;
}
void setTurnPrompt(uint8_t value)
{
if(value != UserData.mTurnPrompt)
{
UserData.mTurnPrompt = value;
}
}
//转向灯
uint8_t getTurnLight(void)
{
return UserData.mTurnLight;
}
void setTurnLight(uint8_t value)
{
if(value != UserData.mTurnLight)
{
UserData.mTurnLight = value;
}
}
//远近光灯
uint8_t getBeamLight(void)
{
return UserData.mBeamLight;
}
void setBeamLight(uint8_t value)
{
if(value != UserData.mBeamLight)
{
UserData.mBeamLight = value;
}
}
//示宽灯
uint8_t getSideMarkerLight(void)
{
return UserData.mSideMarkerLight;
}
void setSideMarkerLight(uint8_t value)
{
if(value != UserData.mSideMarkerLight)
{
UserData.mSideMarkerLight = value;
}
}
//工作指示灯
uint8_t getFanLight(void)
{
return UserData.mFanLight;
}
void setFanLight(uint8_t value)
{
if(value != UserData.mFanLight)
{
UserData.mFanLight = value;
}
}
//abs灯
uint8_t getABSLight(void)
{
return UserData.mABSLight;
}
void setABSLight(uint8_t value)
{
if(value != UserData.mABSLight)
{
UserData.mABSLight = value;
}
}
//机油压力灯
uint8_t getOilPressLight(void)
{
return UserData.mOilPressLight;
}
void setOilPressLight(uint8_t value)
{
if(value != UserData.mOilPressLight)
{
UserData.mOilPressLight = value;
}
}
//
uint8_t getEngineLight(void)
{
return UserData.mEngineLight;
}
void setEngineLight(uint8_t value)
{
if(value != UserData.mEngineLight)
{
UserData.mEngineLight = value;
}
}
//清零标记
uint8_t getRefreshTags(void)
{
return UserData.mRefreshTags;
}
void setRefreshTags(uint8_t value)
{
if(value != UserData.mRefreshTags)
{
UserData.mRefreshTags = value;
}
}
//灯光值
uint8_t getLightValue(void)
{
return UserData.mLightValue;
}
void setLightValue(uint8_t value)
{
if(value != UserData.mLightValue)
{
UserData.mLightValue = value;
}
}
//自检
uint8_t getSelfCheck(void)
{
return UserData.mSelfCheck;
}
void setSelfCheck(uint8_t value)
{
if(value != UserData.mSelfCheck)
{
UserData.mSelfCheck = value;
}
}
//蓝牙继承数据
uint8_t getBTDataInherit(void)
{
return UserData.mBTData_Inherit;
}
void setBTDataInherit(uint8_t value)
{
if(value != UserData.mBTData_Inherit)
{
UserData.mBTData_Inherit = value;
}
}
//当前错误
uint16_t getCurrentFaultCode(void)
{
return UserData.mCurrentFaultCode;
}
void setCurrentFaultCode(uint16_t value)
{
if(value != UserData.mCurrentFaultCode)
{
UserData.mCurrentFaultCode = value;
}
}
//历史错误
uint8_t getStoreDCBusLow(void)
{
return UserData.mHistoryFaultCode;
}
void setStoreDCBusLow(uint8_t value)
{
if(value != UserData.mHistoryFaultCode)
{
UserData.mHistoryFaultCode = value;
}
}
//发动机告警信息
uint8_t getEngineErr(void)
{
return UserData.mErr.mEngine;
}
void setEngineErr(uint8_t value)
{
if(value != UserData.mErr.mEngine)
{
UserData.mErr.mEngine = value;
}
}
//机油告警信息
uint8_t getEngineOilErr(void)
{
return UserData.mErr.mEngineOil;
}
void setEngineOilErr(uint8_t value)
{
if(value != UserData.mErr.mEngineOil)
{
UserData.mErr.mEngineOil = value;
}
}
//abs告警
uint8_t getAbsErr(void)
{
return UserData.mErr.mAbs;
}
void setAbsErr(uint8_t value)
{
if(value != UserData.mErr.mAbs)
{
UserData.mErr.mAbs = value;
}
}
//输出过流
uint8_t getTCSErr(void)
{
return UserData.mErr.mTcs;
}
void setTCSErr(uint8_t value)
{
if(value != UserData.mErr.mTcs)
{
UserData.mErr.mTcs = value;
}
}
//风扇故障
uint8_t getFanErr(void)
{
return UserData.mErr.mFan;
}
void setFanErrs(uint8_t value)
{
if(value != UserData.mErr.mFan)
{
UserData.mErr.mFan = value;
}
}
//空挡故障
uint8_t getNeutralGearErr(void)
{
return UserData.mErr.mNeutralGear;
}
void setNeutralGearErr(uint8_t value)
{
if(value != UserData.mErr.mNeutralGear)
{
UserData.mErr.mNeutralGear = value;
}
}
//水温故障
uint8_t getWaterTemperErr(void)
{
return UserData.mErr.mWaterTemper;
}
void setWaterTemperErr(uint8_t value)
{
if(value != UserData.mErr.mWaterTemper)
{
UserData.mErr.mWaterTemper = value;
}
}
//刹车故障
uint8_t getBrakesFaultErr(void)
{
return UserData.mErr.mBrakesFault;
}
void setBrakesFaultErr(uint8_t value)
{
if(value != UserData.mErr.mBrakesFault)
{
UserData.mErr.mBrakesFault = value;
}
}
//电池电量占比
uint8_t getBatteryRatio(void)
{
return UserData.mBatteryRatio;
}
void setBatteryRatio(uint8_t value)
{
if(value != UserData.mBatteryRatio)
{
UserData.mBatteryRatio = value;
}
}
//电池电压
uint8_t getBatteryVoltage(void)
{
return UserData.mBatteryVoltage;
}
void setBatteryVoltage(uint8_t value)
{
if(value != UserData.mBatteryVoltage)
{
UserData.mBatteryVoltage = value;
}
}
//转速信息
uint16_t getEspeed(void)
{
return UserData.mEspeed;
}
void setEspeed(uint16_t value)
{
if(value != UserData.mEspeed)
{
UserData.mEspeed = value;
}
}
//油量信息
uint8_t getFuel(void)
{
return UserData.mFuel;
}
void setFuel(uint8_t value)
{
if(value != UserData.mFuel)
{
UserData.mFuel = value;
}
}
//水温信息
uint8_t getWaterTemper(void)
{
return UserData.mWaterTemper;
}
void setWaterTemper(uint8_t value)
{
if(value != UserData.mWaterTemper)
{
UserData.mWaterTemper = value;
}
}
//电瓶电压
uint8_t getAccumulatorVolt(void)
{
return UserData.mAccumulatorVolt;
}
void setAccumulatorVolt(uint8_t value)
{
if(value != UserData.mAccumulatorVolt)
{
UserData.mAccumulatorVolt = value;
}
}

View File

@ -0,0 +1,121 @@
#include <stdio.h>
#include <string.h>
#include "mx_store.h"
#include "mx_alternator_data.h"
Store_t UserData;
void store_init(void)
{
Storeinit(&UserData);
}
// 初始化Store_t结构体
void Storeinit(Store_t* store)
{
store->mSoftMainVersion = 0; //主版本号
store->mSoftSubVersion = 0; //次版本号
//uint8_t bt_name[BT_NAME_MAX_LEN];
store->mSetMode = 0; //高字节 SET 1 为短按 2为长按 低字节 MODE 1 为短按 2为长按
store->mSpeed = 0; //速度信息
store->mGearInfo = 0; //档位信息
store->mTotalMile = 0; //总计里程
store->mTripMile = 0; //单次行驶里程
store->mMileClearTags = 0; //小计里程清零标志
store->mWifi = 0; //WIFI
store->mBlueTooth = 0; //蓝牙
store->mTurn = 0; //转向 0-无 1-左转 2-右转
store->mTurnPrompt = 0; //转向提示 0无 1左 2右
store->mTurnLight = 0; //转向灯 0-无 1-左转向灯 2-右转向灯
store->mBeamLight = 0; //灯光 0-无灯光 1-远光 2-近光 3-自动大灯
store->mSideMarkerLight = 0; //示宽灯 0-无灯光 1-示宽灯
store->mFanLight = 0; //风扇灯 0-无灯光 1-灯亮
store->mABSLight = 0; //0-无灯光 1-灯亮
store->mOilPressLight = 0; //机油压力报警灯 0-无灯光 1-灯亮
store->mEngineLight = 0; //0-无灯光 1-灯亮
store->mRefreshTags = 0; //0-无刷新 1-油量/水温/电池电压刷新标志
store->mLightValue = 0; //灯光亮度,具体的light_value值
store->mSelfCheck = 0; //开机自检
store->mLightSensingVolt = 0; //光感电压值 暂定范围0-3300
//store->return_demo = 0; //????
memcpy(&store->mUuid, 0, 32*sizeof(char));
memcpy(&store->mBT_name, 0, 32*sizeof(char));
//UserData.mUuid[32] = {0};
//UserData.mBT_name[32] = {0};
store->mCurrentFaultCode = 0; //当前故障码
store->mHistoryFaultCode = 0; //历史故障码
store->mBTData_Inherit = 0; //继承的蓝牙数据(保留)
store->mTtrb = 0; //开机检测是否获取到时间的标志
store->mTtrb_Time = 0; //设施时间后检测是否正常设置时间的标志
store->mOdo_Reset = 0; //小计里程清零后检测是否正常设置时间的标志
store->mDemo_Position = 0; //是否在demo展示界面的标志
//告警错误
store->mErr.mEngine = 0;
store->mErr.mEngineOil = 0;
store->mErr.mAbs = 0;
store->mErr.mTcs = 0;
store->mErr.mFan = 0;
store->mErr.mNeutralGear = 0;
store->mErr.mWaterTemper = 0;
store->mErr.mBrakesFault = 0;
//保存数据
store->mSaveData.mFactorySet = 0; //出厂设置
store->mSaveData.mLanguage = 0; //语言
store->mSaveData.mDisplayUint = 0; //单位
store->mSaveData.mTheme = 0; //当前主题
store->mSaveData.mThemeState = 0; //主题状态
store->mSaveData.mLightValue = 0; //亮度
store->mSaveData.mBT_OnOff = 0; //蓝牙
store->mSaveData.mBT_State = 0; //状态
store->mSaveData.mGearPos = 0; //档位
store->mSaveData.mFuel = 0; //油量
store->mSaveData.mTotalMile = 0; //里程数
//时间变量
store->mTime.ucYear = 0;
store->mTime.ucMonth = 0;
store->mTime.ucDate = 0;
store->mTime.ucHour = 0;
store->mTime.ucMinute = 0;
store->mTime.ucSecond = 0;
store->mPlan = 0; //总进度标志
store->mPace = 0; //分进度标志
store->mUpGrade = 0; //内存拷贝标志
//电摩专用属性
store->mBatteryRatio = 0; //电池电量占比 1个字节eg100% 传输64
store->mBatteryVoltage = 0; //电池电压 eg3.3V 传输3300
//油摩专用属性
store->mEspeed = 0; //转速信息
store->mFuel = 0; //油量指示
store->mWaterTemper = 0; //水温指示
store->mAccumulatorVolt = 0; //电瓶电压
}
Store_t* store_get(void)
{
return &UserData;
}
void store_set(Store_t store)
{
UserData = store;
}
ErrorCode_t* error_code_get(void)
{
return &UserData.mErr;
}
void error_code_set(ErrorCode_t error)
{
UserData.mErr = error;
}

View File

@ -3,6 +3,9 @@
#include "mxc_meter.h"
#include "moto_list.h"
#define _EMOTO_ // 宏开关
#define _OMOTO_
Local_UiCommon_t local_UiCommon = {0};
daily_data_t custom_data;
@ -122,8 +125,217 @@ void app_menu_comm_entry(lv_obj_t * obj, ENUM_CONTROL_WIN_ID win_id, bool regis
// }
}
#if 0
SysData_t UserData;
void SystemDate_Init(void)
{
UserData.mSoftMainVersion = 0; //主版本号
UserData.mSoftSubVersion = 0; //次版本号
//uint8_t bt_name[BT_NAME_MAX_LEN];
UserData.mSetMode = 0; //高字节 SET 1 为短按 2为长按 低字节 MODE 1 为短按 2为长按
UserData.mSpeed = 0; //速度信息
UserData.mGearInfo = 0; //档位信息
UserData.mTotalMile = 0; //总计里程
UserData.mTripMile = 0; //单次行驶里程
UserData.mMileClearTags = 0; //小计里程清零标志
UserData.mWifi = 0; //WIFI
UserData.mBlueTooth = 0; //蓝牙
UserData.mTurn = 0; //转向 0-无 1-左转 2-右转
UserData.mTurnPrompt = 0; //转向提示 0无 1左 2右
UserData.mTurnLight = 0; //转向灯 0-无 1-左转向灯 2-右转向灯
UserData.mBeamLight = 0; //灯光 0-无灯光 1-远光 2-近光 3-自动大灯
UserData.mSideMarkerLight = 0; //示宽灯 0-无灯光 1-示宽灯
UserData.mFanLight = 0; //风扇灯 0-无灯光 1-灯亮
UserData.mABSLight = 0; //0-无灯光 1-灯亮
UserData.mOilPressLight = 0; //机油压力报警灯 0-无灯光 1-灯亮
UserData.mEngineLight = 0; //0-无灯光 1-灯亮
UserData.mRefreshTags = 0; //0-无刷新 1-油量/水温/电池电压刷新标志
UserData.mLightValue = 0; //灯光亮度,具体的light_value值
UserData.mSelfCheck = 0; //开机自检
UserData.mLightSensingVolt = 0; //光感电压值 暂定范围0-3300
UserData.return_demo = 0; //????
memcpy(&UserData.mUuid, 0, 32*sizeof(char));
memcpy(&UserData.mBT_name, 0, 32*sizeof(char));
//UserData.mUuid[32] = {0};
//UserData.mBT_name[32] = {0};
UserData.mCurrentFaultCode = 0; //当前故障码
UserData.mHistoryFaultCode = 0; //历史故障码
UserData.mBTData_Inherit = 0; //继承的蓝牙数据(保留)
UserData.mTtrb = 0; //开机检测是否获取到时间的标志
UserData.mTtrb_Time = 0; //设施时间后检测是否正常设置时间的标志
UserData.mOdo_Reset = 0; //小计里程清零后检测是否正常设置时间的标志
UserData.mDemo_Position = 0; //是否在demo展示界面的标志
//告警错误
UserData.mErr.mEngine = 0;
UserData.mErr.mEngineOil = 0;
UserData.mErr.mAbs = 0;
UserData.mErr.mTcs = 0;
UserData.mErr.mFan = 0;
UserData.mErr.mNeutralGear = 0;
UserData.mErr.mWaterTemper = 0;
UserData.mErr.mBrakesFault = 0;
//保存数据
UserData.mSaveData.mFactorySet = 0; //出厂设置
UserData.mSaveData.mLanguage = 0; //语言
UserData.mSaveData.mDisplayUint = 0; //单位
UserData.mSaveData.mTheme = 0; //当前主题
UserData.mSaveData.mThemeState = 0; //主题状态
UserData.mSaveData.mLightValue = 0; //亮度
UserData.mSaveData.mBT_OnOff = 0; //蓝牙
UserData.mSaveData.mBT_State = 0; //状态
UserData.mSaveData.mGearPos = 0; //档位
UserData.mSaveData.mFuel = 0; //油量
UserData.mSaveData.mTotalMile = 0; //里程数
//时间变量
UserData.mTime.ucYear = 0;
UserData.mTime.ucMonth = 0;
UserData.mTime.ucDate = 0;
UserData.mTime.ucHour = 0;
UserData.mTime.ucMinute = 0;
UserData.mTime.ucSecond = 0;
UserData.mPlan = 0; //总进度标志
UserData.mPace = 0; //分进度标志
UserData.mUpGrade = 0; //内存拷贝标志
//电摩专用属性
#ifdef _EMOTO_
UserData.mBatteryRatio = 0; //电池电量占比 1个字节eg100% 传输64
UserData.mBatteryVoltage = 0; //电池电压 eg3.3V 传输3300
#endif
//油摩专用属性
#ifdef _OMOTO_
UserData.mEspeed = 0; //转速信息
UserData.mFuel = 0; //油量指示
UserData.mWaterTemper = 0; //水温指示
UserData.mAccumulatorVolt = 0; //电瓶电压
#endif
}
void updateCurTime()
{
struct tm
{
int tm_sec;
int tm_min;
int tm_hour;
int tm_mday;
int tm_mon;
int tm_year;
int tm_wday;
int tm_yday;
int tm_isdst;
};
struct tm CurTime={0};
_getsystime(&CurTime);
/*
custom_data.time.ucDate = CurTime.tm_mday;
custom_data.time.ucYear = CurTime.tm_year;
custom_data.time.ucMonth = CurTime.tm_mon;
custom_data.time.ucHour = CurTime.tm_hour;
custom_data.time.ucMinute = CurTime.tm_min;
custom_data.time.ucSecond = CurTime.tm_sec;
*/
UserData.mTime.ucDate = CurTime.tm_mday;
UserData.mTime.ucYear = CurTime.tm_mday;
UserData.mTime.ucMonth = CurTime.tm_mday;
UserData.mTime.ucHour = CurTime.tm_mday;
UserData.mTime.ucMinute = CurTime.tm_mday;
UserData.mTime.ucSecond = CurTime.tm_mday;
}
STime_t* getCurrentTime1()
{
updateCurTime();
return &(UserData.mTime);
}
SysData_t* GetDailyData1(void)
{
return &UserData;
}
const char digitalArray[10] = "0123456789";
static char StrCurTime[6] = {0};
extern STime_t * getCurrentTime1();
char * GetCurTimeString()
{
updateCurTime();
StrCurTime[0] = digitalArray[UserData.mTime.ucHour/10];
StrCurTime[1] = digitalArray[UserData.mTime.ucHour%10];
StrCurTime[2] =':';
StrCurTime[3] = digitalArray[UserData.mTime.ucMinute/10];
StrCurTime[4] = digitalArray[UserData.mTime.ucMinute%10];
return StrCurTime;
}
#define DEF_DATE_YEAR 2024
#define DEF_DATE_MONTH 1
#define DEF_DATE_DAY 1
void InitSysDateTime(void)
{
GetSysDateTime(DEF_DATE_YEAR, DEF_DATE_MONTH, DEF_DATE_DAY);
}
void GetSysDateTime(uint16_t year, uint8_t month, uint8_t day)
{
UserData.mTime.ucYear = year;
UserData.mTime.ucMonth = month;
UserData.mTime.ucDate = day;
UserData.mTime.ucHour = 0;
UserData.mTime.ucMinute = 0;
UserData.mTime.ucSecond = 0;
}
void UpdateSysTime(void)
{
bool time_12_is_am=false;
if(++UserData.mTime.ucSecond>=60)
{
UserData.mTime.ucSecond = 0;
if(++UserData.mTime.ucMinute>=60)
{
UserData.mTime.ucMinute = 0;
if(++UserData.mTime.ucHour>=12)
{
if(time_12_is_am)
{
UserData.mTime.ucDate++;
time_12_is_am=0;
}else{
time_12_is_am=1;
}
UserData.mTime.ucHour = 0;
}
}
}
//UpdatePace();
printf("%04d-%d%d-%d%d %d%d:%d%d.%d%d\n",
UserData.mTime.ucYear, UserData.mTime.ucMonth/10, UserData.mTime.ucMonth%10,
UserData.mTime.ucDate/10, UserData.mTime.ucDate%10,
UserData.mTime.ucHour/10, UserData.mTime.ucHour%10,
UserData.mTime.ucMinute/10, UserData.mTime.ucMinute%10,
UserData.mTime.ucSecond/10, UserData.mTime.ucSecond%10);
}
#else if
//<2F><><EFBFBD>ݳ<EFBFBD>ʼ<EFBFBD><CABC>
void system_date_init(void){
void system_date_init(void)
{
custom_data.softwar_host = 0;
custom_data.softwar_order = 1;
@ -165,12 +377,9 @@ void system_date_init(void){
custom_data.warning.fan = 0;
custom_data.warning.null = 0;
custom_data.now_defect_code = 0x2255;
custom_data.his_defect_code = 0x400;
custom_data.ttrb = 0;
custom_data.ttrb_time = 10;
custom_data.odo_reset = 10;
@ -182,7 +391,8 @@ void system_date_init(void){
}
void updateCurTime(){
void updateCurTime()
{
struct tm {
int tm_sec;
int tm_min;
@ -205,7 +415,8 @@ void updateCurTime(){
custom_data.time.ucSecond = CurTime.tm_sec;
}
stTime_type * getCurrentTime(){
stTime_type * getCurrentTime()
{
updateCurTime();
return &(custom_data.time);
@ -219,7 +430,9 @@ daily_data_t* GetDailyData(void)
const char digitalArray[10] = "0123456789";
static char sCurTime[6] = {0};
extern stTime_type * getCurrentTime();
char * GetCurTimeString(){
char * GetCurTimeString()
{
updateCurTime();
sCurTime[0] = digitalArray[custom_data.time.ucHour/10];
sCurTime[1] = digitalArray[custom_data.time.ucHour%10];
@ -230,8 +443,8 @@ char * GetCurTimeString(){
}
#define DEF_DATE_YEAR 2024
#define DEF_DATE_MONTH 2
#define DEF_DATE_DAY 3
#define DEF_DATE_MONTH 2
#define DEF_DATE_DAY 3
void InitSysDateTime(void)
{
@ -280,5 +493,7 @@ void UpdateSysTime(void)
custom_data.time.ucSecond/10,custom_data.time.ucSecond%10);
}
#endif

View File

@ -0,0 +1,284 @@
#include "lvgl.h"
#include "img_def.h"
#include "mxc_meter.h"
#include "moto_list.h"
Local_UiCommon_t local_UiCommon = {0};
daily_data_t custom_data;
lv_coord_t child_id = 0;
daily_data_t *daily_get_UiData(void)
{
return &custom_data;
}
Local_UiCommon_t *local_get_UiCommon(void)
{
return &local_UiCommon;
}
ENUM_CONTROL_WIN_ID get_top_history_win(void) //get lastest win_id history record
{
// Local_UiCommon_t *local_common = local_get_UiCommon();
// for(uint8_t i=0; i<HISTORY_WIN_LEVEL;i++)
// {
// if(local_common->page_record[HISTORY_WIN_LEVEL-1-i].flag)
// {
// printf("get_top_history_win i: %d win_id %d \r\n",\
// HISTORY_WIN_LEVEL-1-i,local_common->page_record[HISTORY_WIN_LEVEL-1-i].win_id);
// return local_common->page_record[HISTORY_WIN_LEVEL-1-i].win_id;
// }
//
// }
return 0;
}
void Set_UI_page_id(ENUM_CONTROL_WIN_ID id)
{
printf("Set_UI_page_id: %d \r\n",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;
}
void set_child_id(lv_coord_t id)
{
child_id = id;
}
void set_win_history_record(ENUM_CONTROL_WIN_ID page_id, uint32_t id)
{
Local_UiCommon_t *local_common = local_get_UiCommon();
for(uint8_t i=0; i<HISTORY_WIN_LEVEL;i++)
{
if(false==local_common->page_record[i].flag)
{
local_common->page_record[i].flag=true;
local_common->page_record[i].win_id=page_id;
local_common->page_record[i].index=id;
return;
}
}
}
uint32_t get_win_history_record(ENUM_CONTROL_WIN_ID page_id)
{
Local_UiCommon_t *local_common = local_get_UiCommon();
uint32_t id=0xff;
for(uint8_t i=0; i<HISTORY_WIN_LEVEL;i++)
{
if(local_common->page_record[HISTORY_WIN_LEVEL-1-i].flag
&& (uint8_t)page_id== local_common->page_record[HISTORY_WIN_LEVEL-1-i].win_id)
{
id=local_common->page_record[HISTORY_WIN_LEVEL-1-i].index;
set_child_id(id);
return id;
}
}
set_child_id(id);
return id;
}
bool get_win_history_record_flag(ENUM_CONTROL_WIN_ID page_id)
{
Local_UiCommon_t *local_common = local_get_UiCommon();
bool flag=false;
uint8_t id=0;
for(uint8_t i=0; i<HISTORY_WIN_LEVEL;i++)
{
if((uint8_t)page_id== local_common->page_record[HISTORY_WIN_LEVEL-1-i].win_id)
{
flag=local_common->page_record[HISTORY_WIN_LEVEL-1-i].flag;
return flag;
}
}
return flag;
}
void app_menu_comm_entry(lv_obj_t * obj, ENUM_CONTROL_WIN_ID win_id, bool register_encode)
{
Set_UI_page_id(win_id); //set win id
if(get_win_history_record_flag(win_id))
{
set_child_id(get_win_history_record(win_id)); //get record
}
else {
set_win_history_record( win_id, 0);
set_child_id(0);
}
// if(register_encode){
// do_register_obj_encode_group(obj);
// }else{
// do_unregister_encode_group();
// }
}
//<2F><><EFBFBD>ݳ<EFBFBD>ʼ<EFBFBD><CABC>
void system_date_init(void){
custom_data.softwar_host = 0;
custom_data.softwar_order = 1;
custom_data.save_info.language = 0;
custom_data.save_info.display_uint = 0;
custom_data.save_info.theme = 0;
custom_data.save_info.theme_state = 1;
custom_data.save_info.light_value = 3;
custom_data.save_info.bt_on_off = 1;
custom_data.save_info.bt_state = 0;
custom_data.veer = 0;
custom_data.veer_hint = 0;
custom_data.lamplight = 0;
custom_data.power_on_self_test =0;
if(custom_data.light_perception_value == 0)
custom_data.light_perception_value=44;
custom_data.light = 5;
custom_data.return_demo = 0;
//<2F>ٶ<EFBFBD> ת<><D7AA>
custom_data.velocity = 0;
custom_data.veer_velocity = 0;
custom_data.grade = 0;
custom_data.oil = 0;
custom_data.temp = 0;
custom_data.trip_mileage = 0;
custom_data.total_mileage = 0;
custom_data.voltage =0;
custom_data.warning.engine = 0;
custom_data.warning.machine_oil = 0;
custom_data.warning.abs = 0;
custom_data.warning.tcs = 0;
custom_data.warning.fan = 0;
custom_data.warning.null = 0;
custom_data.now_defect_code = 0x2255;
custom_data.his_defect_code = 0x400;
custom_data.ttrb = 0;
custom_data.ttrb_time = 10;
custom_data.odo_reset = 10;
custom_data.demo_position = 0;
custom_data.plan = 0;
custom_data.pace = 0;
custom_data.upgrade = 0;
}
void updateCurTime(){
struct tm {
int tm_sec;
int tm_min;
int tm_hour;
int tm_mday;
int tm_mon;
int tm_year;
int tm_wday;
int tm_yday;
int tm_isdst;
};
struct tm CurTime={0};
_getsystime(&CurTime);
custom_data.time.ucDate = CurTime.tm_mday;
custom_data.time.ucYear = CurTime.tm_year;
custom_data.time.ucMonth = CurTime.tm_mon;
custom_data.time.ucHour = CurTime.tm_hour;
custom_data.time.ucMinute = CurTime.tm_min;
custom_data.time.ucSecond = CurTime.tm_sec;
}
stTime_type * getCurrentTime(){
updateCurTime();
return &(custom_data.time);
}
daily_data_t* GetDailyData(void)
{
return &custom_data;
}
const char digitalArray[10] = "0123456789";
static char sCurTime[6] = {0};
extern stTime_type * getCurrentTime();
char * GetCurTimeString(){
updateCurTime();
sCurTime[0] = digitalArray[custom_data.time.ucHour/10];
sCurTime[1] = digitalArray[custom_data.time.ucHour%10];
sCurTime[2] =':';
sCurTime[3] = digitalArray[custom_data.time.ucMinute/10];
sCurTime[4] = digitalArray[custom_data.time.ucMinute%10];
return sCurTime;
}
#define DEF_DATE_YEAR 2024
#define DEF_DATE_MONTH 2
#define DEF_DATE_DAY 3
void InitSysDateTime(void)
{
GetSysDateTime(DEF_DATE_YEAR, DEF_DATE_MONTH, DEF_DATE_DAY);
}
void GetSysDateTime(uint16_t year, uint8_t month, uint8_t day)
{
custom_data.time.ucYear = year;
custom_data.time.ucMonth = month;
custom_data.time.ucDate= day;
custom_data.time.ucHour=5;
custom_data.time.ucMinute=59;
custom_data.time.ucSecond=50 ;
}
void UpdateSysTime(void)
{
bool time_12_is_am=false;
if(++custom_data.time.ucSecond>=60)
{
custom_data.time.ucSecond = 0;
if(++custom_data.time.ucMinute>=60)
{
custom_data.time.ucMinute = 0;
if(++custom_data.time.ucHour>=12)
{
if(time_12_is_am)
{
custom_data.time.ucDate++;
time_12_is_am=0;
}else{
time_12_is_am=1;
}
custom_data.time.ucHour = 0;
}
}
}
//UpdatePace();
printf("%04d-%d%d-%d%d %d%d:%d%d.%d%d\n",
custom_data.time.ucYear,custom_data.time.ucMonth/10,custom_data.time.ucMonth%10,
custom_data.time.ucDate/10,custom_data.time.ucDate%10,
custom_data.time.ucHour/10,custom_data.time.ucHour%10,
custom_data.time.ucMinute/10,custom_data.time.ucMinute%10,
custom_data.time.ucSecond/10,custom_data.time.ucSecond%10);
}