彩屏仓功耗优化
📎 原始文档:https://www.kdocs.cn/l/cc7tp3W77U33 彩屏仓功耗优化
- 息屏和连接耳机逻辑
- 目前息屏逻辑改为40s没有操作进入idle直接进入软关机状态下,点击屏幕以及开关盖会被唤醒,立马去回链耳机的BLE
- 注释掉等待rtos初始化,并且将tp初始化在第一帧刷新后
static u8 tp_init = false;
static void lvgl_task(void *p)
{
printf("++++++++++++++++++++++++lvgl_task++++++++++++++++++++++++++++++++");
// extern int fifo_main() ;
// fifo_main() ;
#if 0//TCFG_SD0_ENABLE
extern void sd_test();
sd_test();
#endif
int msg[32];
int ret;
#if LV_USE_LOG && LV_LOG_PRINTF
lv_log_register_print_cb(lv_rt_log);
#endif
lv_init();
lv_port_disp_init(p);
// 等待模式任务启动再启动LVGL
// while(!app_get_curr_task()){
// printf("checks");
// os_time_dly(10);
// }
lcd_sleep_ctrl(0);
lcd_get_hdl()->backlight_ctrl(0);
// lcd_draw_area(0, rot_buf, 0, 0, 0, 172, 0); //旋转
lv_port_indev_init();
// sys_s_hi_timer_add(NULL, lvgl_test_tick, 2);
lv_port_fs_init();
#if LV_USE_DEMO_WIDGETS
lv_demo_widgets();
#endif /* #if LV_USE_DEMO_WIDGETS */
#if LV_USE_DEMO_STRESS
lv_demo_stress();
#endif /* #if LV_USE_DEMO_STRESS */
#if LV_USE_DEMO_MUSIC
// lv_demo_music();
#endif /* #if LV_USE_DEMO_MUSIC */
extern volatile u8 usr_wait_te;
usr_wait_te = 0;//0;
// 用户动态控制是否推psram刷屏
extern volatile u8 usr_full_screen;
usr_full_screen = 0;//0;
static int last_time = 0;
int time_till_next = 0; // 距离下一次执行时间,此时间与待机低功耗相关
/*Set a cursor for the mouse*/
LV_IMG_DECLARE(mouse_cursor_icon); /*Declare the image file.*/
extern lv_indev_t *indev_touchpad;
cursor_obj = lv_img_create(lv_scr_act()); /*Create an image object for the cursor */
lv_img_set_src(cursor_obj, &ID_ic_xia); /*Set the image source*/
lv_indev_set_cursor(indev_touchpad, cursor_obj); /*Connect the image object to the driver*/
lv_obj_add_flag(cursor_obj, LV_OBJ_FLAG_HIDDEN);
// static u8 bufout[10000*4];
// static u8 bufin[10000*3];
// int j;
// int a = jiffies_half_msec();
// int key = 0;
// for(j=0;j<1000 ;j++){
// int i;
// for(i=0;i<10000;i++){
// memcpy(bufout[i*4], bufin[i*3], 3);
// key = 1;
// }
// // putchar('2');
// }
// int b = jiffies_half_msec();
// printf(">>>>10000 %d 1/2 %d=",b-a,key);
// // // // /*Create a GUI-Guider app */
void setup_ui(lv_ui *ui);
setup_ui(&guider_ui);
events_init(&guider_ui);
custom_init(&guider_ui);
// // // // lv_example_btn_11();
// // // // extern void lv_demo_music(void);
// // // // lv_demo_music();
// extern void usr_ui_deal();
// usr_ui_deal();
// void lv_example_label_4(void);
// lv_example_label_4();
// lv_example_canvas_1();
// lv_creat_oj()
// lv_example_img_1();
// lv_demo_keypad_encoder();
// lv_example_imgfont_1();
//避免开机白屏,延时亮背光
// delay_2ms(200);
hw_sleep_ctrl();
int next=0;
extern const int IDLE_AUTO_SLEEP;
extern const int FULL_FLASH;
// r_printf("start timer:%d\n",jiffies_msec());
while (1) {
int next=50;
/* 全屏刷测试 */
// if(FULL_FLASH && !lcd_sleep_status())
// lv_obj_invalidate(lv_scr_act());
if(IDLE_AUTO_SLEEP || !lcd_sleep_status()){
next = lv_task_handler() / 10;
}
if(next<50) {
if(next) os_time_dly(next);
else if(!lcd_sleep_status()) wdt_clear();
ret = os_taskq_accept(ARRAY_SIZE(msg), msg);
} else {
ret = os_taskq_pend(NULL, msg, ARRAY_SIZE(msg));
}
/* 处理消息 */
lv_os_event_handle((ret == OS_TASKQ)?msg:NULL);
#if TCFG_TP_CST816D_ENABLE
// 标准原理图使用ldo给tp供电(pin_en)。需要提前拉一下io口,否则cst816可能升级失败
if(!tp_init)
{
tp_init = TRUE;
extern void cst816d_init();
cst816d_init();
}
#endif
}
}
3、lv_screen_refresh_start函数中先调用screen_refresh_timer_cb,主要是为了快速刷新页面
void lv_screen_refresh_start()
{
if (!screen_refresh_timer) {
screen_refresh_timer_cb();
screen_refresh_timer = lv_timer_create(screen_refresh_timer_cb, SCREEN_REFRESH_INTERVAL, NULL);
}
}
4、添加检测芯片是否处于idle模式,是的话直接进入软关机
static int app_is_sleep = 0;
void app_sleep_check()
{
int value;
struct lp_target *p;
list_for_each_lp_target(p){
value = 1 & (p->is_idle());
putchar('*');
}
if(value){
++app_is_sleep;
putchar('o');
if(app_is_sleep>400){
putchar('P');
power_event_to_user(POWER_EVENT_POWER_LOW);
usr_timer_del(app_sleep_check_timer);
}
}
else{
putchar('@');
app_is_sleep = 0;
}
}





ac701n_watch_release_v2.2.0_lvgl.zip 参考工程