1 Star 0 Fork 9

lqwu675/linux-lvgl

forked from socbis/linux-lvgl 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
main.c 2.28 KB
一键复制 编辑 原始数据 按行查看 历史
#include "lvgl/lvgl.h"
#include "lv_drivers/display/fbdev.h"
#include "lv_examples/lv_examples.h"
#include "evdev.h"
#include <unistd.h>
#include <pthread.h>
#include <time.h>
#include <sys/time.h>
#include "gui_guider.h"
#include "events_init.h"
#include "ts_dev.h"
#define DISP_BUF_SIZE (80 * LV_HOR_RES_MAX)
lv_indev_t * indev_touchpad;
lv_ui guider_ui;
int my_demo(void)
{
lv_indev_drv_t indev_drv;
lv_disp_t * disp;
printf("NXP gui guider test \n");
/*LittlevGL init*/
lv_init();
/*初始化Linux frame buffer设备*/
fbdev_init();
/*A small buffer for LittlevGL to draw the screen's content*/
static lv_color_t buf[DISP_BUF_SIZE];
/*Initialize a descriptor for the buffer*/
static lv_disp_buf_t disp_buf;
lv_disp_buf_init(&disp_buf, buf, NULL, DISP_BUF_SIZE);
/*Initialize and register a display driver*/
lv_disp_drv_t disp_drv;
lv_disp_drv_init(&disp_drv);
disp_drv.buffer = &disp_buf;
disp_drv.flush_cb = fbdev_flush;
/* 注册显示设备 */
disp = lv_disp_drv_register(&disp_drv);
/* 触摸屏初始化 */
lv_indev_drv_init(&indev_drv); /*Basic initialization*/
/*Register a touchpad input device*/
tsdev_init();
indev_drv.type = LV_INDEV_TYPE_POINTER;
indev_drv.read_cb = tsdev_read;
/* 为触摸屏绑定显示设备 */
indev_drv.disp = disp;
/* 注册触摸屏设备 */
indev_touchpad = lv_indev_drv_register(&indev_drv);
/*Create a Demo*/
printf("Create ui: ");
setup_ui(&guider_ui);
events_init(&guider_ui);
printf("success \n");
printf("Enter Handle LitlevGL tasks loop ...\n");
/*Handle LitlevGL tasks (tickless mode)*/
while(1) {
lv_task_handler();
usleep(5000);
}
return 0;
}
/*Set in lv_conf.h as `LV_TICK_CUSTOM_SYS_TIME_EXPR`*/
uint32_t custom_tick_get(void)
{
static uint64_t start_ms = 0;
if(start_ms == 0) {
struct timeval tv_start;
gettimeofday(&tv_start, NULL);
start_ms = (tv_start.tv_sec * 1000000 + tv_start.tv_usec) / 1000;
}
struct timeval tv_now;
gettimeofday(&tv_now, NULL);
uint64_t now_ms;
now_ms = (tv_now.tv_sec * 1000000 + tv_now.tv_usec) / 1000;
uint32_t time_ms = now_ms - start_ms;
return time_ms;
}
int main(void)
{
my_demo();
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lqwu675/linux-lvgl.git
git@gitee.com:lqwu675/linux-lvgl.git
lqwu675
linux-lvgl
linux-lvgl
gui-guider

搜索帮助