/*********************************************************************************
|
* Copyright: (C) 2021 LingYun IoT System Studio
|
* All rights reserved.
|
*
|
* Filename: lvgl_demo.c
|
* Description: This file is LVGL demo program.
|
*
|
* Version: 1.0.0(2021年09月27日)
|
* Author: Guo Wenxue <guowenxue@gmail.com>
|
* ChangeLog: 1, Release initial version on "2021年09月27日 22时16分52秒"
|
*
|
********************************************************************************/
|
|
#include <stdio.h>
|
#include <unistd.h>
|
#include <pthread.h>
|
#include <time.h>
|
#include <sys/time.h>
|
|
#include "lvgl/lvgl.h"
|
#include "lv_drivers/display/fbdev.h"
|
#include "lv_drivers/indev/evdev.h"
|
#include "lv_demos/lv_demo.h"
|
|
#define DISP_BUF_SIZE (128 * 1024)
|
|
|
int main(void)
|
{
|
lv_disp_drv_t disp_drv;
|
lv_indev_drv_t indev_drv;
|
static lv_color_t buf[DISP_BUF_SIZE]; /* buffer for LVGL to draw the screen's content */
|
static lv_disp_draw_buf_t disp_buf; /* Initialize a descriptor for the buffer */
|
|
/* LVGL context init */
|
lv_init();
|
|
/* Linux frame buffer device init */
|
fbdev_init();
|
|
/* linux touchscreen device init */
|
lv_indev_drv_init(&indev_drv);
|
indev_drv.type =LV_INDEV_TYPE_POINTER;
|
indev_drv.read_cb =evdev_read;
|
lv_indev_drv_register(&indev_drv);
|
|
/* Initialize and register a display driver */
|
lv_disp_draw_buf_init(&disp_buf, buf, NULL, DISP_BUF_SIZE);
|
lv_disp_drv_init(&disp_drv);
|
disp_drv.draw_buf = &disp_buf;
|
disp_drv.flush_cb = fbdev_flush;
|
disp_drv.hor_res = 800;
|
disp_drv.ver_res = 480;
|
lv_disp_drv_register(&disp_drv);
|
|
/* Create a Demo */
|
//lv_demo_widgets();
|
lv_demo_music();
|
//lv_demo_keypad_encoder();
|
//lv_demo_stress();
|
|
/* 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 millis(void)
|
{
|
static uint64_t start_ms = 0;
|
struct timeval tv_start;
|
struct timeval tv_now;
|
uint64_t now_ms;
|
uint32_t time_ms;
|
|
if(start_ms == 0)
|
{
|
gettimeofday(&tv_start, NULL);
|
start_ms = (tv_start.tv_sec * 1000000 + tv_start.tv_usec) / 1000;
|
}
|
|
gettimeofday(&tv_now, NULL);
|
now_ms = (tv_now.tv_sec * 1000000 + tv_now.tv_usec) / 1000;
|
|
time_ms = now_ms - start_ms;
|
return time_ms;
|
}
|