Add image & video examples
This commit is contained in:
parent
d95a902ff7
commit
b255c84632
4
Makefile
4
Makefile
@ -29,8 +29,8 @@ CFLAGS := -O0 -g $(WARNINGS)
|
||||
DEFINES := -D SIMULATOR=1 -D LV_BUILD_TEST=0
|
||||
|
||||
# Include simulator inc folder first so lv_conf.h from custom UI can be used instead
|
||||
INC := -I./ui/simulator/inc/ -I./ -I./lvgl/
|
||||
LDLIBS := -lSDL2 -lm
|
||||
INC := -I./ui/simulator/inc/ -I./ -I./lvgl/ -I/usr/include/freetype2 -L/usr/local/lib
|
||||
LDLIBS := -lSDL2 -lm -lfreetype -lavformat -lavcodec -lavutil -lswscale -lm -lz -lpthread
|
||||
BIN := $(BIN_DIR)/demo
|
||||
|
||||
COMPILE = $(CC) $(CFLAGS) $(INC) $(DEFINES)
|
||||
|
||||
81
lv_conf.h
81
lv_conf.h
@ -498,6 +498,87 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/
|
||||
/*A layout similar to Grid in CSS.*/
|
||||
#define LV_USE_GRID 1
|
||||
|
||||
/*---------------------
|
||||
* 3rd party libraries
|
||||
*--------------------*/
|
||||
|
||||
/*File system interfaces for common APIs */
|
||||
|
||||
/*API for fopen, fread, etc*/
|
||||
#define LV_USE_FS_STDIO 1
|
||||
#if LV_USE_FS_STDIO
|
||||
#define LV_FS_STDIO_LETTER 'A' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/
|
||||
#define LV_FS_STDIO_PATH "" /*Set the working directory. File/directory paths will be appended to it.*/
|
||||
#define LV_FS_STDIO_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/
|
||||
#endif
|
||||
|
||||
/*API for open, read, etc*/
|
||||
#define LV_USE_FS_POSIX 0
|
||||
#if LV_USE_FS_POSIX
|
||||
#define LV_FS_POSIX_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/
|
||||
#define LV_FS_POSIX_PATH "" /*Set the working directory. File/directory paths will be appended to it.*/
|
||||
#define LV_FS_POSIX_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/
|
||||
#endif
|
||||
|
||||
/*API for CreateFile, ReadFile, etc*/
|
||||
#define LV_USE_FS_WIN32 0
|
||||
#if LV_USE_FS_WIN32
|
||||
#define LV_FS_WIN32_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/
|
||||
#define LV_FS_WIN32_PATH "" /*Set the working directory. File/directory paths will be appended to it.*/
|
||||
#define LV_FS_WIN32_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/
|
||||
#endif
|
||||
|
||||
/*API for FATFS (needs to be added separately). Uses f_open, f_read, etc*/
|
||||
#define LV_USE_FS_FATFS 0
|
||||
#if LV_USE_FS_FATFS
|
||||
#define LV_FS_FATFS_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/
|
||||
#define LV_FS_FATFS_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/
|
||||
#endif
|
||||
|
||||
/*PNG decoder library*/
|
||||
#define LV_USE_PNG 1
|
||||
|
||||
/*BMP decoder library*/
|
||||
#define LV_USE_BMP 1
|
||||
|
||||
/* JPG + split JPG decoder library.
|
||||
* Split JPG is a custom format optimized for embedded systems. */
|
||||
#define LV_USE_SJPG 1
|
||||
|
||||
/*GIF decoder library*/
|
||||
#define LV_USE_GIF 1
|
||||
|
||||
/*QR code library*/
|
||||
#define LV_USE_QRCODE 1
|
||||
|
||||
/*FreeType library*/
|
||||
#define LV_USE_FREETYPE 1
|
||||
#if LV_USE_FREETYPE
|
||||
/*Memory used by FreeType to cache characters [bytes] (-1: no caching)*/
|
||||
#define LV_FREETYPE_CACHE_SIZE (16 * 1024)
|
||||
#if LV_FREETYPE_CACHE_SIZE >= 0
|
||||
/* 1: bitmap cache use the sbit cache, 0:bitmap cache use the image cache. */
|
||||
/* sbit cache:it is much more memory efficient for small bitmaps(font size < 256) */
|
||||
/* if font size >= 256, must be configured as image cache */
|
||||
#define LV_FREETYPE_SBIT_CACHE 0
|
||||
/* Maximum number of opened FT_Face/FT_Size objects managed by this cache instance. */
|
||||
/* (0:use system defaults) */
|
||||
#define LV_FREETYPE_CACHE_FT_FACES 0
|
||||
#define LV_FREETYPE_CACHE_FT_SIZES 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*Rlottie library*/
|
||||
#define LV_USE_RLOTTIE 0
|
||||
|
||||
/*FFmpeg library for image decoding and playing videos
|
||||
*Supports all major image formats so do not enable other image decoder with it*/
|
||||
#define LV_USE_FFMPEG 1
|
||||
#if LV_USE_FFMPEG
|
||||
/*Dump input information to stderr*/
|
||||
#define LV_FFMPEG_DUMP_FORMAT 0
|
||||
#endif
|
||||
|
||||
/*==================
|
||||
* EXAMPLES
|
||||
*==================*/
|
||||
|
||||
@ -95,8 +95,8 @@
|
||||
#endif
|
||||
|
||||
#if USE_SDL || USE_SDL_GPU
|
||||
# define SDL_HOR_RES 800
|
||||
# define SDL_VER_RES 480
|
||||
# define SDL_HOR_RES 1024
|
||||
# define SDL_VER_RES 1080
|
||||
|
||||
#define MONITOR_HOR_RES SDL_HOR_RES
|
||||
#define MONITOR_VER_RES SDL_VER_RES
|
||||
|
||||
@ -67,6 +67,91 @@ static int tick_thread(void *data);
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
static void user_image_demo()
|
||||
{
|
||||
lv_obj_t * img = lv_gif_create(lv_scr_act());
|
||||
lv_gif_set_src(img, "A:lvgl/examples/libs/gif/bulb.gif");
|
||||
lv_obj_align(img, LV_ALIGN_BOTTOM_RIGHT, -20, -20);
|
||||
|
||||
lv_color_t bg_color = lv_palette_lighten(LV_PALETTE_LIGHT_BLUE, 5);
|
||||
lv_color_t fg_color = lv_palette_darken(LV_PALETTE_BLUE, 4);
|
||||
|
||||
lv_obj_t * qr = lv_qrcode_create(lv_scr_act(), 150, fg_color, bg_color);
|
||||
|
||||
/*Set data*/
|
||||
const char * data = "https://lvgl.io";
|
||||
lv_qrcode_update(qr, data, strlen(data));
|
||||
lv_obj_center(qr);
|
||||
|
||||
/*Add a border with bg_color*/
|
||||
lv_obj_set_style_border_color(qr, bg_color, 0);
|
||||
lv_obj_set_style_border_width(qr, 5, 0);
|
||||
|
||||
/*Create a font*/
|
||||
static lv_ft_info_t info;
|
||||
/*FreeType uses C standard file system, so no driver letter is required.*/
|
||||
info.name = "./lvgl/examples/libs/freetype/Lato-Regular.ttf";
|
||||
info.weight = 24;
|
||||
info.style = FT_FONT_STYLE_NORMAL;
|
||||
info.mem = NULL;
|
||||
if(!lv_ft_font_init(&info)) {
|
||||
LV_LOG_ERROR("create failed.");
|
||||
}
|
||||
|
||||
/*Create style with the new font*/
|
||||
static lv_style_t style;
|
||||
lv_style_init(&style);
|
||||
lv_style_set_text_font(&style, info.font);
|
||||
lv_style_set_text_align(&style, LV_TEXT_ALIGN_CENTER);
|
||||
|
||||
/*Create a label with the new style*/
|
||||
lv_obj_t * label = lv_label_create(lv_scr_act());
|
||||
lv_obj_add_style(label, &style, 0);
|
||||
lv_label_set_text(label, "Hello world\nI'm a font created with FreeType");
|
||||
lv_obj_set_pos(label, 10, 10);
|
||||
|
||||
lv_obj_t * img1 = lv_img_create(lv_scr_act());
|
||||
/* Assuming a File system is attached to letter 'A'
|
||||
* E.g. set LV_USE_FS_STDIO 'A' in lv_conf.h */
|
||||
lv_img_set_src(img1, "A:lvgl/examples/libs/png/wink.png");
|
||||
lv_obj_align(img1, LV_ALIGN_LEFT_MID, 20, 0);
|
||||
|
||||
lv_obj_t * wp;
|
||||
|
||||
wp = lv_img_create(lv_scr_act());
|
||||
/* Assuming a File system is attached to letter 'A'
|
||||
* E.g. set LV_USE_FS_STDIO 'A' in lv_conf.h */
|
||||
lv_img_set_src(wp, "A:lvgl/examples/libs/sjpg/small_image.sjpg");
|
||||
lv_obj_align(wp, LV_ALIGN_RIGHT_MID, -20, 0);
|
||||
|
||||
lv_obj_t * img2 = lv_img_create(lv_scr_act());
|
||||
/* Assuming a File system is attached to letter 'A'
|
||||
* E.g. set LV_USE_FS_STDIO 'A' in lv_conf.h */
|
||||
lv_img_set_src(img2, "A:lvgl/examples/libs/sjpg/lv_example_jpg.jpg");
|
||||
//lv_obj_center(img);
|
||||
lv_obj_align(img2, LV_ALIGN_TOP_RIGHT, -20, 20);
|
||||
|
||||
lv_obj_t * img3 = lv_img_create(lv_scr_act());
|
||||
/* Assuming a File system is attached to letter 'A'
|
||||
* E.g. set LV_USE_FS_STDIO 'A' in lv_conf.h */
|
||||
#if LV_COLOR_DEPTH == 32
|
||||
lv_img_set_src(img3, "A:lvgl/examples/libs/bmp/example_32bit.bmp");
|
||||
#elif LV_COLOR_DEPTH == 16
|
||||
lv_img_set_src(img, "A:lvgl/examples/libs/bmp/example_16bit.bmp");
|
||||
#endif
|
||||
lv_obj_align(img3, LV_ALIGN_BOTTOM_MID, 0, -20);
|
||||
|
||||
lv_obj_t * img4 = lv_img_create(lv_scr_act());
|
||||
lv_img_set_src(img4, "A:lvgl/examples/libs/ffmpeg/ffmpeg.png");
|
||||
lv_obj_align(img4, LV_ALIGN_BOTTOM_LEFT, 20, -20);
|
||||
|
||||
lv_obj_t * player = lv_ffmpeg_player_create(lv_scr_act());
|
||||
lv_ffmpeg_player_set_src(player, "./lvgl/examples/libs/ffmpeg/birds.mp4");
|
||||
lv_ffmpeg_player_set_auto_restart(player, true);
|
||||
lv_ffmpeg_player_set_cmd(player, LV_FFMPEG_PLAYER_CMD_START);
|
||||
lv_obj_align(player, LV_ALIGN_TOP_MID, 0, 20);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
(void)argc; /*Unused*/
|
||||
@ -96,12 +181,14 @@ int main(int argc, char **argv)
|
||||
// lv_example_flex_3();
|
||||
// lv_example_label_1();
|
||||
|
||||
lv_demo_widgets();
|
||||
// lv_demo_widgets();
|
||||
// lv_demo_keypad_encoder();
|
||||
// lv_demo_benchmark();
|
||||
// lv_demo_stress();
|
||||
// lv_demo_music();
|
||||
|
||||
user_image_demo();
|
||||
|
||||
while(1) {
|
||||
/* Periodically call the lv_task handler.
|
||||
* It could be done in a timer interrupt or an OS task too.*/
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user