Description
i have already compiled lvgl v9.2.2 using MINGW64 toolchain.
succeed build 4 .a static libraries.
so i created new SDL2 project, linked lvgl 4 static libraries successful.
test exe can execute independently, also can run 4 examples
lv_example_get_started_1()
lv_example_get_started_2()
lv_example_get_started_3()
lv_example_get_started_4()
but failed run lv_demos_create().
What MCU/Processor/Board and compiler are you using?
What do you want to achieve?
can u help me to fix it?
What have you tried so far?
1: check all configurations macro related with SDL2 in lv_conf.h
2: i analyzed that it might be related to lvgl initialization, pls help me.
Code to reproduce
Add the relevant code snippets here.
The code block(s) should be between ```c
and ```
tags:
#include "lvgl_test.h"
volatile sig_atomic_t bRunning = false;
void signal_handler(int interrupt)
{
printf("captured interrupt %d\r\n", interrupt);
if (interrupt == SIGINT)
{
bRunning = false;
}
}
void lvgl_test()
{
lv_init();
int screen_width = 640;
int screen_height = 480;
// 显示设备
lv_display_t *disp;
disp = lv_sdl_window_create(screen_width, screen_height);
// 设置窗口标题
lv_sdl_window_set_title(disp, "LVGL v9.2.2");
// 设置主题
lv_theme_t *theme = lv_theme_default_init(NULL, lv_palette_main(LV_PALETTE_BLUE), lv_palette_main(LV_PALETTE_RED), false, LV_FONT_DEFAULT);
lv_disp_set_theme(disp, theme);
// 输入设备
lv_indev_t *mouse = lv_sdl_mouse_create();
lv_indev_t *keyboard = lv_sdl_keyboard_create();
lv_indev_t *mousewheel = lv_sdl_mousewheel_create();
// 设置tick回调
lv_tick_set_cb(SDL_GetTicks);
// lv_example_get_started_1();
// lv_example_get_started_2();
// lv_example_get_started_3();
lv_example_get_started_4();
char *demo_names[] = {
"widgets",
};
int demo_size = sizeof(demo_names) / sizeof(demo_names[0]);
if(lv_demos_create(demo_names, demo_size) != true)
{
printf("failed lv_demos_create().\r\n");
}
// 注册signal回调
signal(SIGINT, signal_handler);
bRunning = true;
uint32_t last_tick = SDL_GetTicks();
while (bRunning)
{
uint32_t current_tick = SDL_GetTicks();
uint32_t elapsed = current_tick - last_tick;
last_tick = current_tick;
// task handler
// 已经包含对lv_timer_handler()的调用
lv_task_handler();
// 控制刷新帧率, 固定为60秒
uint32_t sleep_time = (1000 / 60) - elapsed;
if(sleep_time < 0)
{
usleep(sleep_time * 1000);
}
}
// 安全退出SDL2
lv_sdl_quit();
}
Screenshot and/or video
If possible, add screenshots and/or videos about the current state.