Tick 接口

LVGL 需要一个系统 tick 来了解动画和其他任务的经过时间。

您需要周期性地调用 lv_tick_inc(tick_period) 函数,并以毫秒为单位提供调用周期。例如,每毫秒调用一次时使用 lv_tick_inc(1)

lv_tick_inc 应在比 lv_task_handler() 更高优先级的例程中调用(例如,在中断中),以便即使 lv_task_handler 的执行时间较长,也能精确地知道经过的毫秒数。

在 FreeRTOS 中,可以在 vApplicationTickHook 中调用 lv_tick_inc

在基于 Linux 的操作系统(例如 Raspberry Pi)上,可以在一个线程中调用 lv_tick_inc,如下所示:

void * tick_thread (void *args)
{
      while(1) {
        usleep(5*1000);   /*休眠 5 毫秒*/
        lv_tick_inc(5);      /*告知 LVGL 已经过了 5 毫秒*/
    }
}

API

Provide access to the system tick with 1 millisecond resolution

Functions

uint32_t lv_tick_get(void)

Get the elapsed milliseconds since start up

Returns

the elapsed milliseconds

uint32_t lv_tick_elaps(uint32_t prev_tick)

Get the elapsed milliseconds since a previous time stamp

Parameters

prev_tick -- a previous time stamp (return value of lv_tick_get() )

Returns

the elapsed milliseconds since 'prev_tick'