#include "include.h" #include "func.h" #include "app_variable.h" #include "common/func_lowpwr.h" #define TRACE_EN 0 #if TRACE_EN #define TRACE(...) printf(__VA_ARGS__) #else #define TRACE(...) #endif #define TEST_EN 0 #if TEST_EN static u16 test_value = 0; #define BAT_PERCENT_VALUE test_value // 电量百分比数值 #else #define BAT_PERCENT_VALUE bsp_vbat_percent_get() // 电量百分比数值 #endif #define LAMP_ANIM_CNT 5 // 天气类型数量 #define LAMP_TIME_CNT 11 // 天气类型数量 #define LAMP_DATE_CNT 10 // 天气类型数量 #define LAMP_WEEK_CNT 14 // 天气类型数量 #define LOWPWR_PERCENT 25 // 低电百分比阈值 #define NUM_PERCENT_MARGIN 6 // 数字和百分号间距 #define GUI_CHARGE_SCREEN_Y (GUI_SCREEN_HEIGHT / 2) const uint32_t anim_image[]={ UI_BUF_BEDLAMP_BAT_DT_01_BIN, UI_BUF_BEDLAMP_BAT_DT_02_BIN, UI_BUF_BEDLAMP_BAT_DT_03_BIN, UI_BUF_BEDLAMP_BAT_DT_04_BIN, UI_BUF_BEDLAMP_BAT_DT_05_BIN, }; const uint32_t week_image[]={ UI_BUF_BEDLAMP_WEEK_CH_07_BIN, UI_BUF_BEDLAMP_WEEK_CH_01_BIN, UI_BUF_BEDLAMP_WEEK_CH_02_BIN, UI_BUF_BEDLAMP_WEEK_CH_03_BIN, UI_BUF_BEDLAMP_WEEK_CH_04_BIN, UI_BUF_BEDLAMP_WEEK_CH_05_BIN, UI_BUF_BEDLAMP_WEEK_CH_06_BIN, UI_BUF_BEDLAMP_WEEK_EN_14_BIN, UI_BUF_BEDLAMP_WEEK_EN_08_BIN, UI_BUF_BEDLAMP_WEEK_EN_09_BIN, UI_BUF_BEDLAMP_WEEK_EN_10_BIN, UI_BUF_BEDLAMP_WEEK_EN_11_BIN, UI_BUF_BEDLAMP_WEEK_EN_12_BIN, UI_BUF_BEDLAMP_WEEK_EN_13_BIN, }; const uint32_t date_image[]={ UI_BUF_BEDLAMP_DATE_NUM_01_BIN, UI_BUF_BEDLAMP_DATE_NUM_02_BIN, UI_BUF_BEDLAMP_DATE_NUM_03_BIN, UI_BUF_BEDLAMP_DATE_NUM_04_BIN, UI_BUF_BEDLAMP_DATE_NUM_05_BIN, UI_BUF_BEDLAMP_DATE_NUM_06_BIN, UI_BUF_BEDLAMP_DATE_NUM_07_BIN, UI_BUF_BEDLAMP_DATE_NUM_08_BIN, UI_BUF_BEDLAMP_DATE_NUM_09_BIN, UI_BUF_BEDLAMP_DATE_NUM_10_BIN, }; const uint32_t time_image[]={ UI_BUF_BEDLAMP_TIME_NUM_01_BIN, UI_BUF_BEDLAMP_TIME_NUM_02_BIN, UI_BUF_BEDLAMP_TIME_NUM_03_BIN, UI_BUF_BEDLAMP_TIME_NUM_04_BIN, UI_BUF_BEDLAMP_TIME_NUM_05_BIN, UI_BUF_BEDLAMP_TIME_NUM_06_BIN, UI_BUF_BEDLAMP_TIME_NUM_07_BIN, UI_BUF_BEDLAMP_TIME_NUM_08_BIN, UI_BUF_BEDLAMP_TIME_NUM_09_BIN, UI_BUF_BEDLAMP_TIME_NUM_10_BIN, }; enum { /* 图像id */ COMPO_ID_PIC_LOWPWR = 1, // 红色底图 COMPO_ID_PIC_LOWPWR1, // 20%红圈 COMPO_ID_PIC_LOWPWR2, // 1/10红圈 COMPO_ID_PIC_QUARTER, // 绿色底图 COMPO_ID_PIC_QUARTER1, // 50%部分 COMPO_ID_PIC_QUARTER2, // 75%部分 COMPO_ID_PIC_QUARTER3, // 1/4绿圈 /* 数字 */ COMPO_ID_BED_LAMP_ANIM, COMPO_ID_BED_LAMP_HOUR_H, COMPO_ID_BED_LAMP_HOUR_L, COMPO_ID_BED_LAMP_MIN_H, COMPO_ID_BED_LAMP_MIN_L, COMPO_ID_BED_LAMP_MIN_COLON, COMPO_ID_BED_LAMP_DATE_H, COMPO_ID_BED_LAMP_DATE_L, COMPO_ID_BED_LAMP_WEEK, }; typedef struct f_charge_t_ { u8 first_entry; u8 bed_lamp_idx; u8 charge_anim_index; bool charge_full_flag; u32 charge_anim_tick; u32 charge_sleep_temp; u8 charge_level_temp; u8 last_gensor_dir; u16 anim_x; u16 anim_y; u16 week_x; u16 week_y; u16 hour_h_x; u16 hour_h_y; u16 hour_l_x; u16 hour_l_y; u16 colon_x; u16 colon_y; u16 min_h_x; u16 min_h_y; u16 min_l_x; u16 min_l_y; u16 date_h_x; u16 date_h_y; u16 date_l_x; u16 date_l_y; } f_charge_t; //根据百分比计算四分之一圈旋转的角度(0-2700) static u16 func_charge_percent_to_deg(u16 percent) { percent = MIN(100, MAX(25, percent)); return (2700 * (percent - 25) / (100 - 25)); } static u16 func_low_power_percent_to_deg(u16 percent) { percent = MIN(100, MAX(10, percent)); return (3240 * (percent - 10) / (100 - 10)); } // 创建充电窗体,创建窗体中不要使用功能结构体 func_cb.f_cb compo_form_t *func_charge_form_create(void) { // 新建窗体和背景 compo_form_t *frm = compo_form_create(true); // 新建图像 #ifdef TJD_GUI_CHARING_WATCH_SHOW if (SysVariable.charingWatchSwitch == 1) { int value = 0; compo_picturebox_t *pic = compo_picturebox_create(frm, UI_BUF_BEDLAMP_BAT_DT_01_BIN); compo_setid(pic, COMPO_ID_BED_LAMP_ANIM); value = get_autoformat_hour(SysVariable.Rtc.hour) / 10; // pic = compo_picturebox_create(frm, time_image[value]); compo_setid(pic, COMPO_ID_BED_LAMP_HOUR_H); value = get_autoformat_hour(SysVariable.Rtc.hour) % 10; pic = compo_picturebox_create(frm, time_image[value]); compo_setid(pic, COMPO_ID_BED_LAMP_HOUR_L); value = (SysVariable.Rtc.min) / 10; pic = compo_picturebox_create(frm, time_image[value]); compo_setid(pic, COMPO_ID_BED_LAMP_MIN_H); value = (SysVariable.Rtc.min) % 10; pic = compo_picturebox_create(frm, time_image[value]); compo_setid(pic, COMPO_ID_BED_LAMP_MIN_L); pic = compo_picturebox_create(frm, UI_BUF_BEDLAMP_TIME_NUM_11_BIN); compo_setid(pic, COMPO_ID_BED_LAMP_MIN_COLON); value = (SysVariable.Rtc.day) / 10; pic = compo_picturebox_create(frm, date_image[value]); compo_setid(pic, COMPO_ID_BED_LAMP_DATE_H); value = (SysVariable.Rtc.day) % 10; pic = compo_picturebox_create(frm, date_image[value]); compo_setid(pic, COMPO_ID_BED_LAMP_DATE_L); value = (SysVariable.Rtc.weekday) % 10; u8 ind = SysVariable.deviceInfo.language == LANGUAGE_TYPE_Chinese ? 0 : 7; printf("ind = %d, value = %d\n", ind, value); pic = compo_picturebox_create(frm, week_image[ind + value]); compo_setid(pic, COMPO_ID_BED_LAMP_WEEK); } else #endif { /* 低电红色动画 */ s16 center_x = 0; s16 center_y = 6; compo_picturebox_t *pic = NULL; pic = compo_picturebox_create(frm, UI_BUF_CHARGE_BJ_LOW_BATTERY_BIN); compo_setid(pic, COMPO_ID_PIC_LOWPWR); compo_picturebox_set_pos(pic, GUI_SCREEN_CENTER_X, GUI_CHARGE_SCREEN_Y); compo_picturebox_set_visible(pic, BAT_PERCENT_VALUE <= LOWPWR_PERCENT); center_x = gui_image_get_size(UI_BUF_CHARGE_LOW_BATTERY_BIN).wid - 6; pic = compo_picturebox_create(frm, UI_BUF_CHARGE_LOW_BATTERY_BIN); compo_setid(pic, COMPO_ID_PIC_LOWPWR1); compo_picturebox_set_rotation_center(pic, center_x, center_y); compo_picturebox_set_rotation(pic, 360); compo_picturebox_set_pos(pic, GUI_SCREEN_CENTER_X, GUI_CHARGE_SCREEN_Y); compo_picturebox_set_visible(pic, BAT_PERCENT_VALUE > 20); pic = compo_picturebox_create(frm, UI_BUF_CHARGE_LOW_BATTERY_BIN); compo_setid(pic, COMPO_ID_PIC_LOWPWR2); compo_picturebox_set_rotation_center(pic, center_x, center_y); compo_picturebox_set_rotation(pic, func_low_power_percent_to_deg(BAT_PERCENT_VALUE)); compo_picturebox_set_pos(pic, GUI_SCREEN_CENTER_X, GUI_CHARGE_SCREEN_Y); compo_picturebox_set_visible(pic, FALSE); /* 电量大于25%绿色动画 */ pic = compo_picturebox_create(frm, UI_BUF_CHARGE_BJ_BATTERY_BIN); compo_setid(pic, COMPO_ID_PIC_QUARTER); compo_picturebox_set_pos(pic, GUI_SCREEN_CENTER_X, GUI_CHARGE_SCREEN_Y); compo_picturebox_set_visible(pic, BAT_PERCENT_VALUE > LOWPWR_PERCENT); center_x = gui_image_get_size(UI_BUF_CHARGE_CHARGING_BIN).wid - 6; pic = compo_picturebox_create(frm, UI_BUF_CHARGE_CHARGING_BIN); compo_setid(pic, COMPO_ID_PIC_QUARTER1); compo_picturebox_set_rotation_center(pic, center_x, center_y); compo_picturebox_set_rotation(pic, 900); compo_picturebox_set_pos(pic, GUI_SCREEN_CENTER_X, GUI_CHARGE_SCREEN_Y); compo_picturebox_set_visible(pic, BAT_PERCENT_VALUE > 50); pic = compo_picturebox_create(frm, UI_BUF_CHARGE_CHARGING_BIN); compo_setid(pic, COMPO_ID_PIC_QUARTER2); compo_picturebox_set_rotation_center(pic, center_x, center_y); compo_picturebox_set_rotation(pic, 1800); compo_picturebox_set_pos(pic, GUI_SCREEN_CENTER_X, GUI_CHARGE_SCREEN_Y); compo_picturebox_set_visible(pic, BAT_PERCENT_VALUE > 75); pic = compo_picturebox_create(frm, UI_BUF_CHARGE_CHARGING_BIN); compo_setid(pic, COMPO_ID_PIC_QUARTER3); compo_picturebox_set_rotation_center(pic, center_x, center_y); compo_picturebox_set_rotation(pic, func_charge_percent_to_deg(BAT_PERCENT_VALUE)); compo_picturebox_set_pos(pic, GUI_SCREEN_CENTER_X, GUI_CHARGE_SCREEN_Y); compo_picturebox_set_visible(pic, BAT_PERCENT_VALUE > LOWPWR_PERCENT); } return frm; } // 充电功能事件处理 static void func_charge_process(void) { f_charge_t *f_charge = (f_charge_t *)func_cb.f_cb; compo_picturebox_t *pic; // compo_textbox_t *txt; // char str_buff[8]; static bool colon_show = false; /* 防止移除充电器后界面未退出问题 */ if (!bsp_charge_sta_get()) { if (func_cb.sta == FUNC_CHARGE) { func_directly_back_to(); } return; } #if TEST_EN static u32 tick = 0; if (tick_check_expire(func_cb.enter_tick, 3000) && tick_check_expire(tick, 300)) { tick = tick_get(); test_value += test_value >= 100 ? 0 : 1; } #endif // TEST_EN #ifdef TJD_GUI_CHARING_WATCH_SHOW if (SysVariable.charingWatchSwitch == 1) { reset_sleep_delay(); reset_pwroff_delay(); if(f_charge->last_gensor_dir != bsp_sensor_step_dir()) { f_charge->last_gensor_dir = bsp_sensor_step_dir(); printf("last_gensor_dir = %d\n",f_charge->last_gensor_dir); switch(f_charge->last_gensor_dir ) { case 0: printf("case 0\n"); f_charge->anim_x = 30; f_charge->anim_y = 75; f_charge->hour_h_x = 136; f_charge->hour_h_y = 95; f_charge->hour_l_x = 199; f_charge->hour_l_y = 95; f_charge->colon_x = 76; f_charge->colon_y = 222; f_charge->min_h_x = 136; f_charge->min_h_y = 222; f_charge->min_l_x = 199; f_charge->min_l_y = 222; f_charge->date_h_x = 143; f_charge->date_h_y = 23; f_charge->date_l_x = 155; f_charge->date_l_y = 23; f_charge->week_x = 203; f_charge->week_y = 24; break; case 1: printf("case 1\n"); f_charge->anim_x = 198; f_charge->anim_y = 148; f_charge->hour_h_x = 106; f_charge->hour_h_y = 37; f_charge->hour_l_x = 106; f_charge->hour_l_y = 100; f_charge->colon_x = 106; f_charge->colon_y = 148; f_charge->min_h_x = 106; f_charge->min_h_y = 193; f_charge->min_l_x = 106; f_charge->min_l_y = 258; f_charge->date_h_x = 28; f_charge->date_h_y = 164; f_charge->date_l_x = 28; f_charge->date_l_y = 174; f_charge->week_x = 28; f_charge->week_y = 123; break; case 2: printf("case 2\n"); f_charge->anim_x = 204; f_charge->anim_y = 211; f_charge->hour_h_x = 100; f_charge->hour_h_y = 192; f_charge->hour_l_x = 36; f_charge->hour_l_y = 192; f_charge->colon_x = 152; f_charge->colon_y = 66; f_charge->min_h_x = 100; f_charge->min_h_y = 66; f_charge->min_l_x = 36; f_charge->min_l_y = 66; f_charge->date_h_x = 96; f_charge->date_h_y = 265; f_charge->date_l_x = 84; f_charge->date_l_y = 265; f_charge->week_x = 42; f_charge->week_y = 265; break; case 3: printf("case 3\n"); f_charge->anim_x = 42; f_charge->anim_y = 148; f_charge->hour_h_x = 131; f_charge->hour_h_y = 254; f_charge->hour_l_x = 131; f_charge->hour_l_y = 191; f_charge->colon_x = 131; f_charge->colon_y = 148; f_charge->min_h_x = 131; f_charge->min_h_y = 103; f_charge->min_l_x = 131; f_charge->min_l_y = 39; f_charge->date_h_x = 203; f_charge->date_h_y = 140; f_charge->date_l_x = 203; f_charge->date_l_y = 128; f_charge->week_x = 203; f_charge->week_y = 179; break; } } if (tick_check_expire(func_cb.enter_tick, 1000) || f_charge->first_entry) { int value = 0; pic = compo_getobj_byid(COMPO_ID_BED_LAMP_HOUR_H); compo_picturebox_set_pos(pic,f_charge->hour_h_x,f_charge->hour_h_y); value = get_autoformat_hour(SysVariable.Rtc.hour) / 10; // compo_picturebox_set(pic,time_image[value]); compo_picturebox_set_rotation(pic,900*f_charge->last_gensor_dir); pic = compo_getobj_byid(COMPO_ID_BED_LAMP_HOUR_L); compo_picturebox_set_pos(pic,f_charge->hour_l_x,f_charge->hour_l_y); value = get_autoformat_hour(SysVariable.Rtc.hour) % 10; compo_picturebox_set(pic,time_image[value]); compo_picturebox_set_rotation(pic,900*f_charge->last_gensor_dir); pic = compo_getobj_byid(COMPO_ID_BED_LAMP_MIN_H); compo_picturebox_set_pos(pic,f_charge->min_h_x,f_charge->min_h_y); value = (SysVariable.Rtc.min) / 10; compo_picturebox_set(pic,time_image[value]); compo_picturebox_set_rotation(pic,900*f_charge->last_gensor_dir); pic = compo_getobj_byid(COMPO_ID_BED_LAMP_MIN_L); compo_picturebox_set_pos(pic,f_charge->min_l_x,f_charge->min_l_y); value = (SysVariable.Rtc.min) % 10; compo_picturebox_set(pic,time_image[value]); compo_picturebox_set_rotation(pic,900*f_charge->last_gensor_dir); pic = compo_getobj_byid(COMPO_ID_BED_LAMP_DATE_H); compo_picturebox_set_pos(pic,f_charge->date_h_x,f_charge->date_h_y); value = (SysVariable.Rtc.day) / 10; compo_picturebox_set(pic,date_image[value]); compo_picturebox_set_rotation(pic,900*f_charge->last_gensor_dir); pic = compo_getobj_byid(COMPO_ID_BED_LAMP_DATE_L); compo_picturebox_set_pos(pic,f_charge->date_l_x,f_charge->date_l_y); value = (SysVariable.Rtc.day) % 10; compo_picturebox_set(pic,date_image[value]); compo_picturebox_set_rotation(pic,900*f_charge->last_gensor_dir); pic = compo_getobj_byid(COMPO_ID_BED_LAMP_WEEK); compo_picturebox_set_pos(pic,f_charge->week_x,f_charge->week_y); value = (SysVariable.Rtc.weekday); u8 ind = SysVariable.deviceInfo.language == LANGUAGE_TYPE_Chinese ? 0 : 7; printf(" func_charge_process ind = %d, value = %d\n", ind, value); compo_picturebox_set(pic, week_image[ind + value]); compo_picturebox_set_rotation(pic,900*f_charge->last_gensor_dir); func_cb.enter_tick = tick_get(); f_charge->bed_lamp_idx++; if (f_charge->bed_lamp_idx >= LAMP_ANIM_CNT) f_charge->bed_lamp_idx = 0; if (BAT_PERCENT_VALUE >= 100) f_charge->bed_lamp_idx = LAMP_ANIM_CNT - 1; pic = compo_getobj_byid(COMPO_ID_BED_LAMP_ANIM); compo_picturebox_set(pic, anim_image[f_charge->bed_lamp_idx]); compo_picturebox_set_pos(pic,f_charge->anim_x,f_charge->anim_y); compo_picturebox_set_rotation(pic,900*f_charge->last_gensor_dir); colon_show = colon_show ? false : true; pic = compo_getobj_byid(COMPO_ID_BED_LAMP_MIN_COLON); compo_picturebox_set_pos(pic,f_charge->colon_x,f_charge->colon_y); compo_picturebox_set_rotation(pic,900*f_charge->last_gensor_dir); compo_picturebox_set_visible(pic, colon_show); f_charge->first_entry = false; } } else #endif { if (BAT_PERCENT_VALUE >= 100) { if (!f_charge->charge_full_flag) { pic = compo_getobj_byid(COMPO_ID_PIC_LOWPWR); compo_picturebox_set_visible(pic, FALSE); pic = compo_getobj_byid(COMPO_ID_PIC_LOWPWR1); compo_picturebox_set_visible(pic, FALSE); pic = compo_getobj_byid(COMPO_ID_PIC_LOWPWR2); compo_picturebox_set_visible(pic, FALSE); /* 满电停止动画 */ pic = compo_getobj_byid(COMPO_ID_PIC_QUARTER); compo_picturebox_set_visible(pic, TRUE); pic = compo_getobj_byid(COMPO_ID_PIC_QUARTER1); compo_picturebox_set_visible(pic, TRUE); pic = compo_getobj_byid(COMPO_ID_PIC_QUARTER2); compo_picturebox_set_visible(pic, TRUE); pic = compo_getobj_byid(COMPO_ID_PIC_QUARTER3); compo_picturebox_set_rotation(pic, func_charge_percent_to_deg(BAT_PERCENT_VALUE)); compo_picturebox_set_visible(pic, TRUE); f_charge->charge_full_flag = TRUE; } } else { /* 充电过程循环动画 */ if (tick_check_expire(f_charge->charge_anim_tick, (BAT_PERCENT_VALUE > LOWPWR_PERCENT ? 100 : 150))) // 低电红色动画周期150ms,绿色周期100ms { if (f_charge->charge_anim_index < (BAT_PERCENT_VALUE > LOWPWR_PERCENT ? 100 : LOWPWR_PERCENT)) f_charge->charge_anim_index++; else f_charge->charge_anim_index = BAT_PERCENT_VALUE; if (BAT_PERCENT_VALUE > LOWPWR_PERCENT) { pic = compo_getobj_byid(COMPO_ID_PIC_LOWPWR); compo_picturebox_set_visible(pic, FALSE); pic = compo_getobj_byid(COMPO_ID_PIC_LOWPWR1); compo_picturebox_set_visible(pic, FALSE); pic = compo_getobj_byid(COMPO_ID_PIC_LOWPWR2); compo_picturebox_set_visible(pic, FALSE); pic = compo_getobj_byid(COMPO_ID_PIC_QUARTER); compo_picturebox_set_visible(pic, TRUE); pic = compo_getobj_byid(COMPO_ID_PIC_QUARTER1); compo_picturebox_set_visible(pic, f_charge->charge_anim_index > 50); pic = compo_getobj_byid(COMPO_ID_PIC_QUARTER2); compo_picturebox_set_visible(pic, f_charge->charge_anim_index > 75); pic = compo_getobj_byid(COMPO_ID_PIC_QUARTER3); compo_picturebox_set_rotation(pic, func_charge_percent_to_deg(f_charge->charge_anim_index)); compo_picturebox_set_visible(pic, f_charge->charge_anim_index > LOWPWR_PERCENT); } else { pic = compo_getobj_byid(COMPO_ID_PIC_QUARTER); compo_picturebox_set_visible(pic, FALSE); pic = compo_getobj_byid(COMPO_ID_PIC_QUARTER1); compo_picturebox_set_visible(pic, FALSE); pic = compo_getobj_byid(COMPO_ID_PIC_QUARTER2); compo_picturebox_set_visible(pic, FALSE); pic = compo_getobj_byid(COMPO_ID_PIC_QUARTER3); compo_picturebox_set_visible(pic, FALSE); pic = compo_getobj_byid(COMPO_ID_PIC_LOWPWR); compo_picturebox_set_visible(pic, TRUE); pic = compo_getobj_byid(COMPO_ID_PIC_LOWPWR1); compo_picturebox_set_visible(pic, f_charge->charge_anim_index > 20); pic = compo_getobj_byid(COMPO_ID_PIC_LOWPWR2); compo_picturebox_set_rotation(pic, func_low_power_percent_to_deg(f_charge->charge_anim_index)); compo_picturebox_set_visible(pic, TRUE); } f_charge->charge_anim_tick = tick_get(); } } } func_process(); } // 充电功能消息处理 static void func_charge_message(size_msg_t msg) { static u32 res_tick = 0; switch (msg) { #if TEST_EN case MSG_CTP_CLICK: test_value = 0; TRACE("test_value:%d\n", test_value); break; #endif // TEST_EN case MSG_CTP_SHORT_UP: case MSG_CTP_SHORT_DOWN: case MSG_CTP_SHORT_LEFT: // case MSG_CTP_SHORT_RIGHT: case MSG_CTP_LONG: break; case MSG_QDEC_FORWARD: case MSG_QDEC_BACKWARD: break; /* 不响应处理触摸滑动事件 */ case MSG_CTP_SHORT_RIGHT: break; case KU_BACK: #ifdef TJD_GUI_CHARING_WATCH_SHOW if (!SysVariable.charingWatchSwitch) #endif { /* 充电界面内按键息屏休眠 */ SysVariable.sleep_delay = 1; } break; /* 不响应按键事件 */ case KU_RIGHT: case KU_LEFT: break; /* 8s长按强制重启 */ case K_BACK: res_tick = tick_get(); break; case KL_BACK: case KH_BACK: case KLH_BACK: if (tick_check_expire(res_tick, 8000)) { user_cfg_info_write(); WDT_RST(); } break; default: func_message(msg); break; } } // 进入充电功能 static void func_charge_enter(void) { func_cb.f_cb = func_zalloc(sizeof(f_charge_t)); func_cb.frm_main = func_charge_form_create(); f_charge_t *f_charge = (f_charge_t *)func_cb.f_cb; f_charge->charge_anim_tick = tick_get(); f_charge->charge_full_flag = FALSE; f_charge->charge_anim_index = BAT_PERCENT_VALUE; f_charge->bed_lamp_idx = 0; f_charge->last_gensor_dir = 0xff; f_charge->first_entry = true; #ifndef TJD_NO_CHANGE_THE_BED_LIGHT_AND_SCREEN_TIME if(SysVariable.charingWatchSwitch == 1) { f_charge->charge_sleep_temp = SysVariable.sleep_time; f_charge->charge_level_temp = SysVariable.light_level; SysVariable.light_level = 5; SysVariable.sleep_time = -1; SysVariable.sleep_delay = SysVariable.sleep_time; SysVariable.guioff_delay = SysVariable.sleep_time; tft_bglight_set_level(SysVariable.light_level, true); } #endif func_cb.enter_tick = tick_get(); } // 退出充电功能 static void func_charge_exit(void) { func_cb.last = FUNC_CHARGE; f_charge_t *f_charge = (f_charge_t *)func_cb.f_cb; #ifndef TJD_NO_CHANGE_THE_BED_LIGHT_AND_SCREEN_TIME if(SysVariable.charingWatchSwitch == 1) { SysVariable.sleep_time = f_charge->charge_sleep_temp; SysVariable.guioff_delay = SysVariable.sleep_time; SysVariable.sleep_delay = SysVariable.sleep_time; SysVariable.light_level = f_charge->charge_level_temp; tft_bglight_set_level(SysVariable.light_level, false); } #endif } // 充电功能 void func_charge(void) { printf("%s\n", __func__); func_charge_enter(); while (func_cb.sta == FUNC_CHARGE) { func_charge_process(); func_charge_message(msg_dequeue()); } func_charge_exit(); }