Tick interface

The LittlevGL needs a system tick to know the elapsed time for animation and other tasks.

You need to call the lv_tick_inc(tick_period) function periodically and tell the call period in milliseconds. For example, lv_tick_inc(1) for calling in every millisecond.

lv_tick_inc should be called in a higher priority routine than lv_task_handler() (e.g. in an interrupt) to precisely know the elapsed milliseconds even if the execution of lv_task_handler takes longer time.

With FreeRTOS lv_tick_inc can be called in vApplicationTickHook.

On Linux based operating system (e.g. on Raspberry Pi) lv_tick_inc can be called in a thread as below:

void * tick_thread (void *args)
{
      while(1) {
        usleep(5*1000);   /*Sleep for 5 millisecond*/
        lv_tick_inc(5);      /*Tell LittlevGL that 5 milliseconds were elapsed*/
    }
}

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

Return

the elapsed milliseconds

uint32_t lv_tick_elaps(uint32_t prev_tick)

Get the elapsed milliseconds since a previous time stamp

Return

the elapsed milliseconds since ‘prev_tick’

Parameters
  • prev_tick: a previous time stamp (return value of systick_get() )