mirror of
https://github.com/No-Chicken/Power-Pico.git
synced 2026-04-03 13:02:36 +08:00
73 lines
1.4 KiB
C
73 lines
1.4 KiB
C
#include "lvgl/lvgl.h"
|
|
#include "lvgl/demos/lv_demos.h"
|
|
#include <unistd.h>
|
|
#include <pthread.h>
|
|
#include <time.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
static const char *getenv_default(const char *name, const char *dflt)
|
|
{
|
|
return getenv(name) ? : dflt;
|
|
}
|
|
|
|
#if LV_USE_LINUX_FBDEV
|
|
static void lv_linux_disp_init(void)
|
|
{
|
|
const char *device = getenv_default("LV_LINUX_FBDEV_DEVICE", "/dev/fb0");
|
|
lv_display_t * disp = lv_linux_fbdev_create();
|
|
|
|
lv_linux_fbdev_set_file(disp, device);
|
|
}
|
|
#elif LV_USE_LINUX_DRM
|
|
static void lv_linux_disp_init(void)
|
|
{
|
|
const char *device = getenv_default("LV_LINUX_DRM_CARD", "/dev/dri/card0");
|
|
lv_display_t * disp = lv_linux_drm_create();
|
|
|
|
lv_linux_drm_set_file(disp, device, -1);
|
|
}
|
|
#elif LV_USE_SDL
|
|
static void lv_linux_disp_init(void)
|
|
{
|
|
const int width = atoi(getenv("LV_SDL_VIDEO_WIDTH") ? : "240");
|
|
const int height = atoi(getenv("LV_SDL_VIDEO_HEIGHT") ? : "240");
|
|
|
|
lv_sdl_window_create(width, height);
|
|
}
|
|
|
|
static void lv_linux_indev_init(void)
|
|
{
|
|
lv_sdl_mouse_create();
|
|
}
|
|
|
|
#else
|
|
#error Unsupported configuration
|
|
#endif
|
|
|
|
#include "./GUI/ui.h"
|
|
|
|
int main(void)
|
|
{
|
|
lv_init();
|
|
|
|
/*Linux display device init*/
|
|
lv_linux_disp_init();
|
|
|
|
lv_linux_indev_init();
|
|
|
|
/*Create a Demo*/
|
|
// lv_demo_widgets();
|
|
// lv_demo_widgets_start_slideshow();
|
|
|
|
ui_init();
|
|
|
|
/*Handle LVGL tasks*/
|
|
while(1) {
|
|
lv_timer_handler();
|
|
usleep(5000);
|
|
}
|
|
|
|
return 0;
|
|
}
|