1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-14 06:42:58 +08:00

Merge pull request #384 from Krastanov/external_ticks

Add a system time callback to be used without `lv_tick_inc`.
This commit is contained in:
Gabor Kiss-Vamosi 2018-08-31 07:24:10 +02:00 committed by GitHub
commit a50b6f56d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View File

@ -24,6 +24,11 @@
#define LV_MEM_CUSTOM_ALLOC malloc /*Wrapper to malloc*/
#define LV_MEM_CUSTOM_FREE free /*Wrapper to free*/
#endif /*LV_MEM_CUSTOM*/
#define LV_TICK_CUSTOM 0 /*1: use a custom tick source (removing the need to manually update the tick with `lv_tick_inc`) */
#if LV_TICK_CUSTOM == 1
#define LV_TICK_CUSTOM_INCLUDE "Arduino.h" /*Header for the sys time function*/
#define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current systime in ms*/
#endif /*LV_TICK_CUSTOM*/
/*===================
Graphical settings

View File

@ -15,6 +15,10 @@
#include "lv_hal_tick.h"
#include <stddef.h>
#if LV_TICK_CUSTOM == 1
#include LV_TICK_CUSTOM_INCLUDE
#endif
/*********************
* DEFINES
*********************/
@ -57,6 +61,7 @@ LV_ATTRIBUTE_TICK_INC void lv_tick_inc(uint32_t tick_period)
*/
uint32_t lv_tick_get(void)
{
#if LV_TICK_CUSTOM == 0
uint32_t result;
do {
tick_irq_flag = 1;
@ -64,6 +69,9 @@ uint32_t lv_tick_get(void)
} while(!tick_irq_flag); /*'lv_tick_inc()' clears this flag which can be in an interrupt. Continue until make a non interrupted cycle */
return result;
#else
return LV_TICK_CUSTOM_SYS_TIME_EXPR;
#endif
}
/**