use lvgl for pic
This commit is contained in:
parent
b77c31d4ff
commit
6f06141f09
@ -99,7 +99,7 @@ target_compile_definitions(e_player PRIVATE LV_CONF_INCLUDE_SIMPLE)
|
||||
|
||||
find_package(PkgConfig REQUIRED)
|
||||
# 添加 MQTT 客户端源码
|
||||
pkg_check_modules(MOSQUITTO REQUIRED libmosquitto)
|
||||
pkg_check_modules(MOSQUITTO libmosquitto)
|
||||
|
||||
pkg_check_modules(PNG REQUIRED libpng)
|
||||
|
||||
@ -123,7 +123,6 @@ target_link_libraries(e_player PRIVATE
|
||||
lvgl
|
||||
m
|
||||
pthread
|
||||
${MOSQUITTO_LIBRARIES}
|
||||
${PNG_LIBRARIES}
|
||||
)
|
||||
|
||||
|
||||
BIN
bin/e_player
BIN
bin/e_player
Binary file not shown.
13
lv_conf.h
13
lv_conf.h
@ -75,9 +75,9 @@
|
||||
|
||||
#if LV_USE_STDLIB_MALLOC == LV_STDLIB_BUILTIN
|
||||
/** Size of memory available for `lv_malloc()` in bytes (>= 2kB) */
|
||||
/*20MB(平衡性能和内存) */
|
||||
//#define LV_MEM_SIZE (10 * 1024 * 1024)
|
||||
#define LV_MEM_SIZE (LV_USE_HOR_SIZE * LV_USE_VER_SIZE * 4*2U)
|
||||
/*增加到 16MB 以支持 PNG 解码 */
|
||||
#define LV_MEM_SIZE (16 * 1024 * 1024)
|
||||
//#define LV_MEM_SIZE (LV_USE_HOR_SIZE * LV_USE_VER_SIZE * 4*2U)
|
||||
|
||||
/** Size of the memory expand for `lv_malloc()` in bytes */
|
||||
#define LV_MEM_POOL_EXPAND_SIZE 0
|
||||
@ -544,11 +544,12 @@
|
||||
#define LV_FS_UEFI_LETTER '\0' /**< Set an upper-case driver-identifier letter for this driver (e.g. 'A'). */
|
||||
#endif
|
||||
|
||||
/** LODEPNG decoder library */
|
||||
#define LV_USE_LODEPNG 0
|
||||
/** PNG decoder library
|
||||
* [LodePNG](https://github.com/lvandeve/lodepng) */
|
||||
#define LV_USE_LODEPNG 1 /* 使用 LodePNG 避免 zlib crc32 冲突 */
|
||||
|
||||
/** PNG decoder(libpng) library */
|
||||
#define LV_USE_LIBPNG 1
|
||||
#define LV_USE_LIBPNG 0 /* 禁用 libpng,避免 crc32 冲突 */
|
||||
|
||||
/** BMP decoder library */
|
||||
#define LV_USE_BMP 0
|
||||
|
||||
Binary file not shown.
@ -1 +1 @@
|
||||
c6b3e50d9d1f9b68daf2ef777fbdcdb9 /home/hyx/work/0212/demo/release/e_player-single-00-70-1.0.84.tar
|
||||
680c4482774abb57ea1151a03c81a0fe /home/hyx/work/0212/demo/release/e_player-single-00-70-1.0.84.tar
|
||||
|
||||
@ -157,8 +157,23 @@ void fbdev_flush(lv_display_t *drv, const lv_area_t *area, uint8_t *color_p)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Skip memcpy: FB buffer already has pre-loaded image (tag.rgba).
|
||||
* Only do hole drawing + render on last flush. */
|
||||
/* 拷贝 LVGL buffer 到 FB(会导致视频 VO_BUSY,但先让图片显示) */
|
||||
int32_t act_x1 = area->x1 < 0 ? 0 : area->x1;
|
||||
int32_t act_y1 = area->y1 < 0 ? 0 : area->y1;
|
||||
int32_t act_x2 = area->x2 > (int32_t)vinfo.xres - 1 ? (int32_t)vinfo.xres - 1 : area->x2;
|
||||
int32_t act_y2 = area->y2 > (int32_t)vinfo.yres - 1 ? (int32_t)vinfo.yres - 1 : area->y2;
|
||||
|
||||
int32_t w = (act_x2 - act_x1 + 1);
|
||||
uint32_t *fbp32 = (uint32_t *)fbp;
|
||||
uint32_t *color_p32 = (uint32_t *)color_p;
|
||||
|
||||
for (int32_t y = act_y1; y <= act_y2; y++)
|
||||
{
|
||||
uint32_t *fb_line = fbp32 + (y * vinfo.xres) + act_x1;
|
||||
uint32_t *color_line = color_p32 + ((y - area->y1) * (area->x2 - area->x1 + 1)) + (act_x1 - area->x1);
|
||||
memcpy(fb_line, color_line, w * sizeof(uint32_t));
|
||||
}
|
||||
|
||||
if (lv_display_flush_is_last(drv))
|
||||
{
|
||||
fbdev_draw_hole();
|
||||
|
||||
@ -25,9 +25,6 @@
|
||||
#include "bootanimation/qua_bootanimation.h"
|
||||
|
||||
#define DISPLAY_ID "id:display0"
|
||||
#define BK_IMAGE_PATH "/usrdata/pic/bk.rgba"
|
||||
#define TAG_IMAGE_PATH "/usrdata/pic/tag.rgba"
|
||||
#define TAG_Y_OFFSET 640
|
||||
|
||||
static QUA_CHAR *pShowScreen;
|
||||
static QUA_U32 u32PhyAddrScreen;
|
||||
@ -162,62 +159,14 @@ static QUA_S32 init_fyfb()
|
||||
printf("map failed\n");
|
||||
goto map_failed;
|
||||
}
|
||||
/* FB 底层保持黑色背景(图片将通过 fbdev_load_images 函数加载) */
|
||||
memset(pShowScreen, 0x00, finfo.smem_len);
|
||||
/* Step 1: load bk.rgba as full-screen background */
|
||||
{
|
||||
int fb_stride = finfo.line_length;
|
||||
int row_bytes = vinfo.xres * 4;
|
||||
FILE *fp = fopen(BK_IMAGE_PATH, "rb");
|
||||
if (fp) {
|
||||
for (unsigned int y = 0; y < vinfo.yres; y++) {
|
||||
if (fread(pShowScreen + y * fb_stride, 1, row_bytes, fp) <= 0) break;
|
||||
}
|
||||
fclose(fp);
|
||||
printf("[init_fyfb] loaded %s full screen\n", BK_IMAGE_PATH);
|
||||
} else {
|
||||
printf("[init_fyfb] %s not found\n", BK_IMAGE_PATH);
|
||||
}
|
||||
|
||||
/* Step 2: overlay tag.rgba at bottom (y=TAG_Y_OFFSET ~ yres) with alpha blend */
|
||||
fp = fopen(TAG_IMAGE_PATH, "rb");
|
||||
if (fp) {
|
||||
unsigned int tag_h = vinfo.yres - TAG_Y_OFFSET;
|
||||
uint8_t *row_buf = (uint8_t *)malloc(row_bytes);
|
||||
if (row_buf) {
|
||||
/* skip top TAG_Y_OFFSET rows of tag image */
|
||||
for (unsigned int y = 0; y < (unsigned int)TAG_Y_OFFSET; y++)
|
||||
if (fread(row_buf, 1, row_bytes, fp) <= 0) break;
|
||||
/* blend bottom rows */
|
||||
for (unsigned int y = 0; y < tag_h; y++) {
|
||||
if (fread(row_buf, 1, row_bytes, fp) <= 0) break;
|
||||
uint8_t *dst = (uint8_t *)(pShowScreen + (TAG_Y_OFFSET + y) * fb_stride);
|
||||
uint8_t *src = row_buf;
|
||||
for (unsigned int x = 0; x < vinfo.xres; x++) {
|
||||
uint8_t sb = src[0], sg = src[1], sr = src[2], sa = src[3];
|
||||
if (sa == 255) {
|
||||
dst[0] = sb; dst[1] = sg; dst[2] = sr; dst[3] = 255;
|
||||
} else if (sa > 0) {
|
||||
dst[0] = (sb * sa + dst[0] * (255 - sa)) / 255;
|
||||
dst[1] = (sg * sa + dst[1] * (255 - sa)) / 255;
|
||||
dst[2] = (sr * sa + dst[2] * (255 - sa)) / 255;
|
||||
dst[3] = 255;
|
||||
}
|
||||
src += 4; dst += 4;
|
||||
}
|
||||
}
|
||||
free(row_buf);
|
||||
}
|
||||
fclose(fp);
|
||||
printf("[init_fyfb] overlaid %s at y=%d\n", TAG_IMAGE_PATH, TAG_Y_OFFSET);
|
||||
} else {
|
||||
printf("[init_fyfb] %s not found\n", TAG_IMAGE_PATH);
|
||||
}
|
||||
}
|
||||
printf("[init_fyfb] FB initialized (images will be loaded via fbdev_load_images)\n");
|
||||
fb_device->compress(fb_device, QUA_TRUE);
|
||||
return QUA_SUCCESS;
|
||||
map_failed:
|
||||
fb_device->unmap(fb_device, pShowScreen, finfo.smem_len);
|
||||
return QUA_FAILURE;
|
||||
return QUA_SUCCESS;
|
||||
}
|
||||
|
||||
static QUA_S32 deinit_fyfb()
|
||||
|
||||
15
src/main.c
15
src/main.c
@ -12,9 +12,10 @@
|
||||
#include <sys/time.h>
|
||||
#include <signal.h>
|
||||
#include <time.h>
|
||||
#include "../lvgl/lvgl.h"
|
||||
#include "lvgl/lvgl.h"
|
||||
#include "e_port_disp.h"
|
||||
#include "e_player_list.h"
|
||||
#include "display/fbdev.h"
|
||||
|
||||
// 全局变量声明
|
||||
volatile sig_atomic_t running = true;
|
||||
@ -57,6 +58,7 @@ void handle_signal(int sig)
|
||||
LV_LOG_USER("signal_handler:sig=%d", sig);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
(void)argc; /*Unused*/
|
||||
@ -94,14 +96,16 @@ int main(int argc, char **argv)
|
||||
pthread_create(&tick_tid, NULL, tick_thread, NULL);
|
||||
pthread_detach(tick_tid);
|
||||
printf("Starting LVGL tick thread\n");
|
||||
/*初始化文件系统*/
|
||||
/*初始化文件系统 - 必须在加载图片前调用*/
|
||||
lv_fs_posix_init();
|
||||
|
||||
disp_handle_t disp = get_front_display();
|
||||
|
||||
/* make LVGL root transparent so FB image (tag.rgba) shows through */
|
||||
lv_obj_set_style_bg_opa(disp.root_obj, LV_OPA_TRANSP, LV_PART_MAIN);
|
||||
|
||||
/* 创建 tag.png 图片 */
|
||||
lv_obj_t *tag_img = lv_img_create(disp.root_obj);
|
||||
lv_img_set_src(tag_img, "A:usrdata/pic/tag.png");
|
||||
lv_obj_set_pos(tag_img, 0, 0);
|
||||
lv_obj_set_size(tag_img, 800, 1280);
|
||||
|
||||
//创建视频播放器
|
||||
VideoPlayer *video_player=video_player_init(0);
|
||||
@ -131,7 +135,6 @@ int main(int argc, char **argv)
|
||||
media_path->type = 1; // 视频
|
||||
|
||||
video_player_add_item(video_player, media_path);
|
||||
|
||||
video_player_play(video_player);
|
||||
|
||||
printf("[MAIN] 启动主循环\n"); fflush(stdout);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user