lvgl配置时钟有两种方式:
-
lv_tick_inc(uint time);
比较简单一般用在mcu
-
lv_conf.h文件中定义 LV_TICK_CUSTOM为1
一般用在linux和RTOS。需要给LV_TICK_CUSTOM_SYS_TIME_EXPR提供一个函数
#define LV_TICK_CUSTOM 1 #if LV_TICK_CUSTOM #define LV_TICK_CUSTOM_INCLUDE <stdint.h> extern uint32_t custom_tick_get(void); #define LV_TICK_CUSTOM_SYS_TIME_EXPR (custom_tick_get()) #endiflinux
uint32_t custom_tick_get(void) { struct timeval tv; gettimeofday(&tv, NULL); static uint64_t start = 0; if (!start) start = tv.tv_sec*1000ULL + tv.tv_usec/1000; return (uint32_t)(tv.tv_sec*1000ULL + tv.tv_usec/1000 - start); }