mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-10-04 04:38:15 +00:00
lvgl: use malloc/free for memory handling and "tickless" tick interface
This makes LVGL use malloc/free to handle its memory (instead of their own memory handling) and supports a tick interface by which LVGL can ask NuttX the elapsed time, instead of having to periodically "tick" LVGL internal time in a thread.
This commit is contained in:
parent
305bd0e448
commit
5bcaeff541
5 changed files with 141 additions and 57 deletions
|
|
@ -89,54 +89,6 @@ void lv_demo_widgets(void);
|
|||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tick_func
|
||||
*
|
||||
* Description:
|
||||
* Calls lv_tick_inc(...) every 5ms.
|
||||
*
|
||||
* Input Parameters:
|
||||
* data
|
||||
*
|
||||
* Returned Value:
|
||||
* NULL
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static FAR void *tick_func(void *data)
|
||||
{
|
||||
static long last_ms;
|
||||
long ms;
|
||||
struct timespec spec;
|
||||
|
||||
while (1)
|
||||
{
|
||||
long diff;
|
||||
|
||||
/* Calculate how much time elapsed */
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &spec);
|
||||
ms = (long)spec.tv_nsec / 1000000;
|
||||
diff = ms - last_ms;
|
||||
|
||||
/* Handle overflow */
|
||||
|
||||
if (diff < 0)
|
||||
{
|
||||
diff = 1000 + diff;
|
||||
}
|
||||
|
||||
lv_tick_inc(diff);
|
||||
usleep(5000);
|
||||
|
||||
last_ms = ms;
|
||||
}
|
||||
|
||||
/* Never will reach here */
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
|
@ -157,7 +109,6 @@ static FAR void *tick_func(void *data)
|
|||
int main(int argc, FAR char *argv[])
|
||||
{
|
||||
lv_disp_drv_t disp_drv;
|
||||
pthread_t tick_thread;
|
||||
|
||||
lv_disp_buf_t disp_buf;
|
||||
static lv_color_t buf[DISPLAY_BUFFER_SIZE];
|
||||
|
|
@ -214,10 +165,6 @@ int main(int argc, FAR char *argv[])
|
|||
disp_drv.buffer = &disp_buf;
|
||||
lv_disp_drv_register(&disp_drv);
|
||||
|
||||
/* Tick interface initialization */
|
||||
|
||||
pthread_create(&tick_thread, NULL, tick_func, NULL);
|
||||
|
||||
/* Touchpad Initialization */
|
||||
|
||||
tp_init();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue