linuxOS_D21X/source/artinchip/test-lvgl/main.c
2024-11-29 16:13:46 +08:00

56 lines
1.1 KiB
C

#include <unistd.h>
#include <pthread.h>
#include <time.h>
#include <stdio.h>
#include <sys/time.h>
#include <sched.h>
#include <assert.h>
#include "lvgl/lvgl.h"
#include "lv_port_disp.h"
#include "lv_port_indev.h"
#include "aic_ui.h"
#include "aic_dec.h"
int main(void)
{
/*LittlevGL init*/
lv_init();
lv_img_cache_set_size(IMG_CACHE_NUM);
aic_dec_create();
lv_port_disp_init();
lv_port_indev_init();
/*Create a Demo*/
//lv_demo_widgets();
aic_ui_init();
/*Handle LitlevGL tasks (tickless mode)*/
while (1) {
lv_timer_handler();
usleep(1000);
}
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;
}