Files
HW_Lib/demo/lvgl/test.c
JiXieShi 040b9be6b9 feat(sim/oled): 移除未使用的头文件 "graphics.h" 和 "conio.h"
 feat(lib/CMakeLists.txt): 添加 LUI 库支持

 feat(lib/utils/inc/argpase.h): 引入 "stdbool.h" 以支持布尔类型

 feat(sim/display/sim_display.cpp): 重新引入 "graphics.h" 和 "conio.h" 以修复依赖

 feat(sim/lvgl/lv_port_indev.cpp): 移除未使用的头文件 "graphics.h" 和 "easyx.h"

 feat(main.c): 添加 LUI 库支持以增强功能

 feat(lib/lui/lame_ui.c): 新增 LUI 库实现以支持 UI 组件
2024-12-19 22:49:08 +08:00

56 lines
1.7 KiB
C

#include "stdio.h"
#include "lv_port_disp.h"
#include "lv_port_indev.h"
#include "lvgl.h"
#include "demos/lv_demos.h"
#include <windows.h>
//#include <widgets/lv_demo_widgets.h>
#include "t_lvgl.h"
#include "SDL3/SDL.h"
static void btn_event_cb(lv_event_t *e) {
lv_event_code_t code = lv_event_get_code(e);
lv_obj_t *btn = lv_event_get_target(e);
if (code == LV_EVENT_CLICKED) {
static uint8_t cnt = 0;
cnt++;
/*Get the first child of the button which is the label and change its text*/
lv_obj_t *label = lv_obj_get_child(btn, 0);
lv_label_set_text_fmt(label, "Button: %d", cnt);
}
}
/**
* Create a button with a label and react on click event.
*/
void lv_example_get_started_1(void) {
lv_obj_t *btn = lv_btn_create(lv_scr_act()); /*Add a button the current screen*/
lv_obj_set_pos(btn, 10, 10); /*Set its position*/
lv_obj_set_size(btn, 120, 50); /*Set its size*/
lv_obj_add_event_cb(btn, btn_event_cb, LV_EVENT_ALL, NULL); /*Assign a callback to the button*/
lv_obj_t *label = lv_label_create(btn); /*Add a label to the button*/
lv_label_set_text(label, "Button"); /*Set the labels text*/
lv_obj_center(label);
}
int Test_lvgl(void *pVoid) {
lv_init();
lv_port_disp_init();
// lv_port_indev_init();
// lv_example_get_started_1();
// lv_demo_widgets();
// printf("\nTEST Widgets\n");
while (1) {
/* Periodically call the lv_task handler.
* It could be done in a timer interrupt or an OS task too.*/
lv_timer_handler();
lv_tick_inc(5);
SDL_Delay(5);
}
return 0;
}