Change to custom tick

What do you want to achieve?

I have a working SLS project and have just created a new one but now find that LV_TICK_CUSTOM
has changed in lv_conf.h

It used to be:

uint32_t custom_tick_get(void);
#define LV_TICK_CUSTOM 1
#if LV_TICK_CUSTOM
#define LV_TICK_CUSTOM_INCLUDE <stdint.h> /Header for the system time function/
#define LV_TICK_CUSTOM_SYS_TIME_EXPR (custom_tick_get()) /Expression evaluating to current system time in ms/

Now it is:

#define LV_TICK_CUSTOM 1

#if LV_TICK_CUSTOM

#define LV_TICK_CUSTOM_INCLUDE "Arduino.h"         /*Header for the system time function*/

#define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis())    /*Expression evaluating to current system time in ms*/

#endif /LV_TICK_CUSTOM/

Why has this changed ?
In my original code (which the new project code is based on), I have:

/**

  • A callback function that LVGL uses for timing.

  • See LV_TICK_CUSTOM_SYS_TIME_EXPR in lv_conf.h.

  • @return The tick value.

*/

uint32_t custom_tick_get(void)

{

static uint64_t start_ms = 0;

if( start_ms == 0 )

{

    struct timeval tv_start;

    gettimeofday( &tv_start, NULL );

    start_ms = ( tv_start.tv_sec * 1000000 + tv_start.tv_usec ) / 1000;

}

struct timeval tv_now;

gettimeofday( &tv_now, NULL );

uint64_t now_ms;

now_ms = ( tv_now.tv_sec * 1000000 + tv_now.tv_usec ) / 1000;

uint32_t time_ms = now_ms - start_ms;

return time_ms;

}

But now when I run the project I get the following messages appear every second.

[Warn] (0.000, +0) lv_timer_handler: It seems lv_tick_inc() is not called. (in lv_timer.c line #94)

What have you tried so far?

N/A

Screenshot or video

N/A

Others

  • SquareLine Studio version:
    1.0.5
  • Operating system:
    Windows 10 x64
  • Target hardware:
    Raspberry Pi 4

Andy

Okay, so I now call lv_tick_inc(10); in a thread and I no longer get the warnings.
Is this standard practice with LVGL?

Andy

It’s strange because "Arduino.h" is the default header and millis() is the default expr. Custom tick is not enabled by default and we didn’t change it in the exported lv_conf.h. I think you have change it manually.

Your custom_tick_get looks good without lv_tick_inc, you just need to enable it in lv_conf.h. :slightly_smiling_face:

I did enable custom tick in lv_conf.h when I got the “It seems lv_tick_inc() is not called.” message.
I did not notice that the custom tick macro had changed and that it now tries to include “Arduino.h” :frowning:

So what is the correct way to keep LVGL happy?
At present, calling lv_tick_inc in my thread works and I have removed the custom_tick_get function.
Is this the correct way?

Andy

There are 2 options:

  1. Call lv_tick_inc() from a thread or interrupt. Calling it from the main loop also works but it it will result in bad timing as the loop’s period depends on the execution time of lv_timer_handler.
  2. Use a custom function which tells LVGL the elapsed time. It can be configured in lv_conf.h. In this case you don’t need to call lv_tick_inc().

I don’t know what happened with the default config. Do you know in which SLS version you saw custom_tick_get()) as the default value?

I can’t remember when it was - it was before SLS was released and I cloned LVGL from Github.
So how to I do option 2 - I cant set LV_TICK_CUSTOM to 1 in lv_conf.h as that will try and include Arduino.h - what do I need to do in lv_conf.h to allow me to use a custom function such as uint32_t custom_tick_get(void) that I used in my previous project?

Andy