链接:https://pan.baidu.com/s/1sdbCoQqsPKs6uw_Qe0t52A
提取码:jzdk
链接:https://pan.baidu.com/s/1N6htoH59f_bdI19dhQP8CQ
提取码:15s7
#include
#define SDL_MAIN_HANDLED
#include
int main()
{
if (SDL_Init(SDL_INIT_VIDEO) != 0)
{
std::cout << "SDL_Init Error: " << SDL_GetError() << std::endl;
return 1;
}
SDL_Quit();
return 0;
}
将lvgl_similator_vs2019\lvgl_similator\lv_drivers目录下的lv_drv_conf_template.h文件复制到上一级目录,并重命名为
lv_drv_conf.h,将lvgl_similator_vs2019\lvgl_similator\lv_examples目录下的lv_ex_conf_template.h文件复制上一级目录,
并重命名为lv_ex_conf.h,将lvgl_similator_vs2019\lvgl_similator\lvgl目录下的lv_conf_template.h文件复制到上一级目录,
并重命名为lv_conf.h
/**
* @file main
*
*/
/*********************
* INCLUDES
*********************/
#include
#include
#include
#include "lvgl/lvgl.h"
#include "lv_drivers/display/monitor.h"
#include "lv_drivers/indev/mouse.h"
#include "lv_drivers/indev/keyboard.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
static void hal_init(void);
static int tick_thread(void* data);
/**********************
* STATIC VARIABLES
**********************/
static lv_indev_t* kb_indev;
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
void btn_event_cb(lv_obj_t* btn, lv_event_t event)
{
if (event == LV_EVENT_CLICKED) {
// printf("Clicked\n");
}
}
int main(int argc, char** argv)
{
/*Initialize LittlevGL*/
lv_init();
/*Initialize the HAL for LittlevGL*/
hal_init();
lv_obj_t* btn = lv_btn_create(lv_scr_act(), NULL); /*Add a button to the current screen*/
lv_obj_set_pos(btn, 100, 100); /*Set its position*/
lv_obj_set_size(btn, 100, 50); /*Set its size*/
lv_obj_set_event_cb(btn, btn_event_cb); /*Assign a callback to the button*/
lv_obj_t* label = lv_label_create(btn, NULL); /*Add a label to the button*/
lv_label_set_text(label, "Button"); /*Set the labels text*/
while (1) {
/* Periodically call the lv_task handler.
* It could be done in a timer interrupt or an OS task too.*/
lv_task_handler();
Sleep(10); /*Just to let the system breathe */
}
return 0;
}
/**********************
* STATIC FUNCTIONS
**********************/
/**
* Initialize the Hardware Abstraction Layer (HAL) for the Littlev graphics library
*/
static void hal_init(void)
{
/* Add a display
* Use the 'monitor' driver which creates window on PC's monitor to simulate a display*/
monitor_init();
lv_disp_drv_t disp_drv;
lv_disp_drv_init(&disp_drv); /*Basic initialization*/
static lv_disp_buf_t disp_buf1;
static lv_color_t buf1_1[LV_HOR_RES_MAX * LV_VER_RES_MAX];
lv_disp_buf_init(&disp_buf1, buf1_1, NULL, LV_HOR_RES_MAX * LV_VER_RES_MAX);
disp_drv.buffer = &disp_buf1;
disp_drv.flush_cb = monitor_flush;
lv_disp_drv_register(&disp_drv);
/* Add the mouse (or touchpad) as input device
* Use the 'mouse' driver which reads the PC's mouse*/
mouse_init();
lv_indev_drv_t indev_drv;
lv_indev_drv_init(&indev_drv); /*Basic initialization*/
indev_drv.type = LV_INDEV_TYPE_POINTER;
indev_drv.read_cb = mouse_read; /*This function will be called periodically (by the library) to get the mouse position and state*/
lv_indev_drv_register(&indev_drv);
/* If the PC keyboard driver is enabled in`lv_drv_conf.h`
* add this as an input device. It might be used in some examples. */
#if USE_KEYBOARD
lv_indev_drv_t kb_drv;
lv_indev_drv_init(&kb_drv);
kb_drv.type = LV_INDEV_TYPE_KEYPAD;
kb_drv.read_cb = keyboard_read;
kb_indev = lv_indev_drv_register(&kb_drv);
#endif
/* Tick init.
* You have to call 'lv_tick_inc()' in every milliseconds
* Create an SDL thread to do this*/
SDL_CreateThread(tick_thread, "tick", NULL);
}
/**
* A task to measure the elapsed time for LittlevGL
* @param data unused
* @return never return
*/
static int tick_thread(void* data)
{
while (1) {
lv_tick_inc(5);
SDL_Delay(5); /*Sleep for 1 millisecond*/
}
return 0;
}
$(ProjectDir)\lvgl\src\src\lv_widgets
$(ProjectDir)\lvgl\src\src\lv_themes
$(ProjectDir)\lvgl\src\src\lv_misc
$(ProjectDir)\lvgl\src\src\lv_hal
$(ProjectDir)\lvgl\src\lv_gpu
$(ProjectDir)\lvgl\src\lv_font
$(ProjectDir)\lvgl\src\lv_draw
$(ProjectDir)\lvgl\src\lv_core
_MBCS
%(PreprocessorDefinitions)
_CRT_SECURE_NO_WARNINGS
2.在lvgl_similator.cpp中加入lv_demo_benchmark.h头文件
#include "lv_demo_benchmark.h"
3.在 lvgl_similator.cpp主函数main中调用lv_demo_benchmark函数
链接:https://pan.baidu.com/s/1Kq-bds2xt1UMpHFHw7njOw
提取码:bnbc