feat(sdl): handle the tick internally and automatically
This commit is contained in:
@@ -23,7 +23,7 @@
|
|||||||
COLOR SETTINGS
|
COLOR SETTINGS
|
||||||
*====================*/
|
*====================*/
|
||||||
|
|
||||||
/*Color depth: 1 (1 byte per pixel), 8 (RGB332), 16 (RGB565), 32 (ARGB8888)*/
|
/*Color depth: 1 (1 byte per pixel), 8 (RGB332), 16 (RGB565), 24 (RGB888), 32 (ARGB8888)*/
|
||||||
#define LV_COLOR_DEPTH 16
|
#define LV_COLOR_DEPTH 16
|
||||||
|
|
||||||
#define LV_COLOR_CHROMA_KEY lv_color_hex(0x00ff00)
|
#define LV_COLOR_CHROMA_KEY lv_color_hex(0x00ff00)
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
#define LV_USE_BUILTIN_MALLOC 1
|
#define LV_USE_BUILTIN_MALLOC 1
|
||||||
#if LV_USE_BUILTIN_MALLOC
|
#if LV_USE_BUILTIN_MALLOC
|
||||||
/*Size of the memory available for `lv_malloc()` in bytes (>= 2kB)*/
|
/*Size of the memory available for `lv_malloc()` in bytes (>= 2kB)*/
|
||||||
#define LV_MEM_SIZE (128U * 1024U) /*[bytes]*/
|
#define LV_MEM_SIZE (48U * 1024U) /*[bytes]*/
|
||||||
|
|
||||||
/*Size of the memory expand for `lv_malloc()` in bytes*/
|
/*Size of the memory expand for `lv_malloc()` in bytes*/
|
||||||
#define LV_MEM_POOL_EXPAND_SIZE 0
|
#define LV_MEM_POOL_EXPAND_SIZE 0
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include "../../core/lv_refr.h"
|
#include "../../core/lv_refr.h"
|
||||||
|
|
||||||
|
#define SDL_MAIN_HANDLED /*To fix SDL's "undefined reference to WinMain" issue*/
|
||||||
#include LV_SDL_INCLUDE_PATH
|
#include LV_SDL_INCLUDE_PATH
|
||||||
|
|
||||||
/*********************
|
/*********************
|
||||||
@@ -47,6 +48,7 @@ void _lv_sdl_mouse_handler(SDL_Event * event);
|
|||||||
void _lv_sdl_mousewheel_handler(SDL_Event * event);
|
void _lv_sdl_mousewheel_handler(SDL_Event * event);
|
||||||
void _lv_sdl_keyboard_handler(SDL_Event * event);
|
void _lv_sdl_keyboard_handler(SDL_Event * event);
|
||||||
static void res_chg_event_cb(lv_event_t * e);
|
static void res_chg_event_cb(lv_event_t * e);
|
||||||
|
static int tick_thread(void * ptr);
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* STATIC VARIABLES
|
* STATIC VARIABLES
|
||||||
@@ -68,6 +70,8 @@ lv_disp_t * lv_sdl_window_create(lv_coord_t hor_res, lv_coord_t ver_res)
|
|||||||
SDL_Init(SDL_INIT_VIDEO);
|
SDL_Init(SDL_INIT_VIDEO);
|
||||||
SDL_StartTextInput();
|
SDL_StartTextInput();
|
||||||
event_handler_timer = lv_timer_create(sdl_event_handler, 5, NULL);
|
event_handler_timer = lv_timer_create(sdl_event_handler, 5, NULL);
|
||||||
|
|
||||||
|
SDL_CreateThread(tick_thread, "LVGL thread", NULL);
|
||||||
inited = true;
|
inited = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -295,4 +299,19 @@ static void res_chg_event_cb(lv_event_t * e)
|
|||||||
texture_resize(disp);
|
texture_resize(disp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int tick_thread(void * ptr)
|
||||||
|
{
|
||||||
|
LV_UNUSED(ptr);
|
||||||
|
static uint32_t tick_prev = 0;
|
||||||
|
|
||||||
|
while(1) {
|
||||||
|
uint32_t tick_now = SDL_GetTicks();
|
||||||
|
lv_tick_inc(tick_now - tick_prev);
|
||||||
|
tick_prev = tick_now;
|
||||||
|
SDL_Delay(5);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /*LV_USE_SDL*/
|
#endif /*LV_USE_SDL*/
|
||||||
|
|||||||
@@ -61,7 +61,7 @@
|
|||||||
COLOR SETTINGS
|
COLOR SETTINGS
|
||||||
*====================*/
|
*====================*/
|
||||||
|
|
||||||
/*Color depth: 1 (1 byte per pixel), 8 (RGB332), 16 (RGB565), 32 (ARGB8888)*/
|
/*Color depth: 1 (1 byte per pixel), 8 (RGB332), 16 (RGB565), 24 (RGB888), 32 (ARGB8888)*/
|
||||||
#ifndef LV_COLOR_DEPTH
|
#ifndef LV_COLOR_DEPTH
|
||||||
#ifdef CONFIG_LV_COLOR_DEPTH
|
#ifdef CONFIG_LV_COLOR_DEPTH
|
||||||
#define LV_COLOR_DEPTH CONFIG_LV_COLOR_DEPTH
|
#define LV_COLOR_DEPTH CONFIG_LV_COLOR_DEPTH
|
||||||
@@ -100,7 +100,7 @@
|
|||||||
#ifdef CONFIG_LV_MEM_SIZE
|
#ifdef CONFIG_LV_MEM_SIZE
|
||||||
#define LV_MEM_SIZE CONFIG_LV_MEM_SIZE
|
#define LV_MEM_SIZE CONFIG_LV_MEM_SIZE
|
||||||
#else
|
#else
|
||||||
#define LV_MEM_SIZE (128U * 1024U) /*[bytes]*/
|
#define LV_MEM_SIZE (48U * 1024U) /*[bytes]*/
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user