fix(example): LVGL_Arduino.ino millis() as tick source (#5999)

This commit is contained in:
Klaus Musch
2024-04-05 10:23:43 +02:00
committed by GitHub
parent a3d20a78dd
commit c9a6b25885
2 changed files with 8 additions and 2 deletions

View File

@@ -12,7 +12,7 @@ There are two ways to provide the tick to LVGL:
1. Call ``lv_tick_set_cb(my_get_milliseconds_function);``: `my_get_milliseconds_function` needs to tell how many milliseconds have elapsed since start up. Most of the platforms have built-in functions that can be used as they are. For example 1. Call ``lv_tick_set_cb(my_get_milliseconds_function);``: `my_get_milliseconds_function` needs to tell how many milliseconds have elapsed since start up. Most of the platforms have built-in functions that can be used as they are. For example
- SDL: ``lv_tick_set_cb(SDL_GetTicks);`` - SDL: ``lv_tick_set_cb(SDL_GetTicks);``
- Arduino: ``lv_tick_set_cb(millis);`` - Arduino: ``lv_tick_set_cb(my_tick_get_cb);``, where ``my_tick_get_cb`` is: ``static uint32_t my_tick_get_cb(void) { return millis(); }``
- FreeRTOS: ``lv_tick_set_cb(xTaskGetTickCount);`` - FreeRTOS: ``lv_tick_set_cb(xTaskGetTickCount);``
- STM32: ``lv_tick_set_cb(HAL_GetTick);`` - STM32: ``lv_tick_set_cb(HAL_GetTick);``
- ESP32: ``lv_tick_set_cb(my_tick_get_cb);``, where ``my_tick_get_cb`` is a wrapper for ``esp_timer_get_time() / 1000;`` - ESP32: ``lv_tick_set_cb(my_tick_get_cb);``, where ``my_tick_get_cb`` is a wrapper for ``esp_timer_get_time() / 1000;``

View File

@@ -67,6 +67,12 @@ void my_touchpad_read( lv_indev_t * indev, lv_indev_data_t * data )
*/ */
} }
/*use Arduinos millis() as tick source*/
static uint32_t my_tick(void)
{
return millis();
}
void setup() void setup()
{ {
String LVGL_Arduino = "Hello Arduino! "; String LVGL_Arduino = "Hello Arduino! ";
@@ -78,7 +84,7 @@ void setup()
lv_init(); lv_init();
/*Set a tick source so that LVGL will know how much time elapsed. */ /*Set a tick source so that LVGL will know how much time elapsed. */
lv_tick_set_cb(millis); lv_tick_set_cb(my_tick);
/* register print function for debugging */ /* register print function for debugging */
#if LV_USE_LOG != 0 #if LV_USE_LOG != 0