v1.2.2
@@ -0,0 +1,27 @@
|
||||
from building import *
|
||||
import os
|
||||
|
||||
group = []
|
||||
src = []
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
src = Glob('*.c')
|
||||
CPPPATH = [cwd]
|
||||
|
||||
if GetDepend(['LVGL_STORAGE_PATH']):
|
||||
ins_dst = GetDepend('LVGL_STORAGE_PATH').strip('"/')
|
||||
else:
|
||||
ins_dst='rodata/lvgl_data'
|
||||
|
||||
ins_src = 'assets/'
|
||||
install = [(ins_src, ins_dst)]
|
||||
|
||||
list = os.listdir(cwd)
|
||||
for d in list:
|
||||
path = os.path.join(cwd, d)
|
||||
if os.path.isfile(os.path.join(path, 'SConscript')):
|
||||
group = group + SConscript(os.path.join(d, 'SConscript'))
|
||||
|
||||
group = group + DefineGroup('LVGL-port', src, depend = ['AIC_APNG_DEMO'], CPPPATH = CPPPATH, INSTALL = install)
|
||||
|
||||
Return('group')
|
||||
@@ -0,0 +1,173 @@
|
||||
/*
|
||||
* Copyright (c) 2025, ArtInChip Technology Co., Ltd
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Authors: Zequan Liang <zequan.liang@artinchip.com>
|
||||
*/
|
||||
|
||||
#include "aic_ui.h"
|
||||
#include "lvgl.h"
|
||||
#include "lv_aic_player.h"
|
||||
|
||||
#define PNG_DEMO_TYPE 0
|
||||
|
||||
static char *g_apng_source[] = {
|
||||
LVGL_PATH(ayanami_rei.png),
|
||||
LVGL_PATH(world-cup.png),
|
||||
LVGL_PATH(clock.png),
|
||||
};
|
||||
|
||||
#define SRC_NUM (sizeof(g_apng_source) / sizeof(g_apng_source[0]))
|
||||
|
||||
static lv_obj_t *create_apng_label(lv_obj_t *parent, char *text);
|
||||
static lv_obj_t *create_apng_player(lv_obj_t *parent, void *src);
|
||||
|
||||
#if PNG_DEMO_TYPE == 0
|
||||
static int g_normal_player_index = 0;
|
||||
static void normal_apng_src_switch_cb(lv_timer_t *timer);
|
||||
static void normal_apng_init(void);
|
||||
#elif PNG_DEMO_TYPE == 1
|
||||
static int g_slave_player_index = 0;
|
||||
static void slave_apng_src_switch_cb(lv_timer_t *timer);
|
||||
static void slave_apng_init(void);
|
||||
#else
|
||||
static int g_sync_player_index = 0;
|
||||
static void group_sync_apng_group_set_sync(lv_obj_t *group, lv_obj_t *player);
|
||||
static void group_sync_apng_src_switch_cb(lv_timer_t *timer);
|
||||
static void group_sync_apng_init(void);
|
||||
#endif
|
||||
|
||||
void aic_png_demo()
|
||||
{
|
||||
#if PNG_DEMO_TYPE == 0
|
||||
normal_apng_init();
|
||||
#elif PNG_DEMO_TYPE == 1
|
||||
slave_apng_init(); // a single src case
|
||||
#else
|
||||
group_sync_apng_init(); // multiple src case
|
||||
#endif
|
||||
}
|
||||
|
||||
static lv_obj_t *create_apng_label(lv_obj_t *parent, char *text)
|
||||
{
|
||||
lv_obj_t *label = lv_label_create(parent);
|
||||
lv_label_set_text(label, text);
|
||||
lv_obj_set_style_bg_opa(label, LV_OPA_100, 0);
|
||||
lv_obj_set_style_bg_color(label, lv_color_hex(0x0), 0);
|
||||
lv_obj_set_style_text_color(label, lv_color_hex(0xffffff), 0);
|
||||
lv_obj_align(label, LV_ALIGN_BOTTOM_LEFT, 0, 0);
|
||||
return label;
|
||||
}
|
||||
|
||||
static lv_obj_t *create_apng_player(lv_obj_t *parent, void *src)
|
||||
{
|
||||
lv_obj_t *player = lv_aic_player_create(parent);
|
||||
lv_aic_player_set_auto_restart(player, true);
|
||||
lv_aic_player_set_src(player, src);
|
||||
return player;
|
||||
}
|
||||
|
||||
#if PNG_DEMO_TYPE == 0
|
||||
static void normal_apng_src_switch_cb(lv_timer_t *timer)
|
||||
{
|
||||
lv_obj_t *player = (lv_obj_t *)timer->user_data;
|
||||
g_normal_player_index++;
|
||||
if (g_normal_player_index > SRC_NUM - 1)
|
||||
g_normal_player_index = 0;
|
||||
lv_aic_player_set_src(player, g_apng_source[g_normal_player_index]);
|
||||
lv_aic_player_set_cmd(player, LV_AIC_PLAYER_CMD_START, NULL);
|
||||
}
|
||||
|
||||
static void normal_apng_init(void)
|
||||
{
|
||||
lv_obj_t *player = create_apng_player(lv_scr_act(), g_apng_source[g_normal_player_index]);
|
||||
lv_aic_player_set_cmd(player, LV_AIC_PLAYER_CMD_START, NULL);
|
||||
lv_obj_align(player, LV_ALIGN_CENTER, 0, 0);
|
||||
|
||||
create_apng_label(player, "normal apng");
|
||||
|
||||
lv_timer_create(normal_apng_src_switch_cb, 100, player);
|
||||
}
|
||||
#elif PNG_DEMO_TYPE == 1
|
||||
static void slave_apng_src_switch_cb(lv_timer_t *timer)
|
||||
{
|
||||
lv_obj_t *player = (lv_obj_t *)timer->user_data;
|
||||
g_slave_player_index++;
|
||||
if (g_slave_player_index > SRC_NUM - 1)
|
||||
g_slave_player_index = 0;
|
||||
lv_aic_player_set_src(player, g_apng_source[g_slave_player_index]);
|
||||
lv_aic_player_set_cmd(player, LV_AIC_PLAYER_CMD_START, NULL);
|
||||
}
|
||||
|
||||
static void slave_apng_init(void)
|
||||
{
|
||||
lv_obj_t *master = create_apng_player(lv_scr_act(), g_apng_source[g_slave_player_index]);
|
||||
lv_aic_player_set_cmd(master, LV_AIC_PLAYER_CMD_START, NULL);
|
||||
lv_obj_align(master, LV_ALIGN_TOP_LEFT, 0, 0);
|
||||
|
||||
create_apng_label(master, "master apng");
|
||||
|
||||
lv_obj_t *slave0 = lv_aic_slave_player_create(lv_scr_act());
|
||||
lv_obj_align(slave0, LV_ALIGN_TOP_MID, 0, 0);
|
||||
|
||||
create_apng_label(slave0, "slaver 1 apng");
|
||||
|
||||
lv_obj_t *slave1 = lv_aic_slave_player_create(lv_scr_act());
|
||||
lv_obj_align(slave1, LV_ALIGN_TOP_RIGHT, 0, 0);
|
||||
|
||||
create_apng_label(slave1, "slaver 2 apng");
|
||||
|
||||
lv_aic_player_set_cmd(master, LV_AIC_PLAYER_CMD_ATTACH_SLAVE, slave0);
|
||||
lv_aic_player_set_cmd(master, LV_AIC_PLAYER_CMD_ATTACH_SLAVE, slave1);
|
||||
|
||||
lv_timer_create(slave_apng_src_switch_cb, 20000, master);
|
||||
}
|
||||
#else
|
||||
static void group_sync_apng_src_switch_cb(lv_timer_t *timer)
|
||||
{
|
||||
lv_obj_t *scr = (lv_obj_t *)timer->user_data;
|
||||
lv_obj_t *group = lv_obj_get_child(scr, -1);
|
||||
lv_obj_t *player_1 = lv_obj_get_child(scr, -2);
|
||||
lv_obj_t *player_2 = lv_obj_get_child(scr, -3);
|
||||
|
||||
g_sync_player_index++;
|
||||
if (g_sync_player_index > SRC_NUM - 1)
|
||||
g_sync_player_index = 0;
|
||||
|
||||
int player2_index = (g_sync_player_index + 1) % SRC_NUM;
|
||||
lv_aic_player_set_src(player_1, g_apng_source[g_sync_player_index]);
|
||||
lv_aic_player_set_src(player_2, g_apng_source[player2_index]);
|
||||
|
||||
lv_aic_player_group_set_cmd(group, LV_AIC_PLAYER_CMD_START, NULL);
|
||||
}
|
||||
|
||||
static void group_sync_apng_group_set_sync(lv_obj_t *group, lv_obj_t *player)
|
||||
{
|
||||
lv_aic_player_set_cmd(player, LV_AIC_PLAYER_CMD_ATTACH_GROUP, group);
|
||||
lv_aic_player_group_add(group, player);
|
||||
}
|
||||
|
||||
static void group_sync_apng_init(void)
|
||||
{
|
||||
lv_obj_t *player_1 = create_apng_player(lv_scr_act(), g_apng_source[g_sync_player_index]);
|
||||
lv_obj_align(player_1, LV_ALIGN_BOTTOM_LEFT, 0, 0);
|
||||
|
||||
create_apng_label(player_1, "sync player 1");
|
||||
|
||||
int player2_index = (g_sync_player_index + 1) % SRC_NUM;
|
||||
lv_obj_t *player_2 = create_apng_player(lv_scr_act(), g_apng_source[player2_index]);
|
||||
lv_obj_align(player_2, LV_ALIGN_BOTTOM_RIGHT, 0, 0);
|
||||
|
||||
create_apng_label(player_2, "sync player 2");
|
||||
|
||||
/* control by group to ensure uniform playback speed among group members. */
|
||||
lv_obj_t *group = lv_aic_player_group_create(lv_scr_act());
|
||||
group_sync_apng_group_set_sync(group, player_1);
|
||||
group_sync_apng_group_set_sync(group, player_2);
|
||||
|
||||
lv_aic_player_group_set_cmd(group, LV_AIC_PLAYER_CMD_START, NULL);
|
||||
|
||||
lv_timer_create(group_sync_apng_src_switch_cb, 30000, lv_scr_act());
|
||||
}
|
||||
#endif
|
||||
|
After Width: | Height: | Size: 728 KiB |
|
After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 34 KiB |
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright (C) 2025 ArtInChip Technology Co., Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* lv_conf_custom.h for custom lv_conf.h file
|
||||
* example :
|
||||
* #undef LV_USE_LOG
|
||||
* #define LV_USE_LOG 1
|
||||
*/
|
||||
|
||||
#ifndef LV_CONF_CUSTOM_H
|
||||
#define LV_CONF_CUSTOM_H
|
||||
|
||||
/* code begin */
|
||||
|
||||
/* code end */
|
||||
|
||||
#endif /* LV_CONF_CUSTOM_H */
|
||||
@@ -10,6 +10,10 @@
|
||||
#include "lvgl.h"
|
||||
#include "lv_aic_player.h"
|
||||
|
||||
#define VIDEO_INDEX_0 0
|
||||
#define VIDEO_INDEX_1 1
|
||||
#define VIDEO_NUM 2
|
||||
|
||||
#define CHECK_CONDITION_RETURN_VOID(confition, ...) \
|
||||
if (confition) { __VA_ARGS__; return; }
|
||||
|
||||
@@ -128,13 +132,16 @@ static void next_button_handler(lv_event_t *e)
|
||||
|
||||
if (code == LV_EVENT_CLICKED) {
|
||||
CHECK_CONDITION_RETURN_VOID(g_del_player, print_del());
|
||||
if (cur_video == 0)
|
||||
cur_video++;
|
||||
cur_video = cur_video > VIDEO_NUM ? VIDEO_INDEX_0 : cur_video;
|
||||
if (cur_video == VIDEO_INDEX_0)
|
||||
lv_aic_player_set_src(player, LVGL_PATH(elevator_mjpeg.mp4));
|
||||
else if (cur_video == VIDEO_INDEX_1)
|
||||
lv_aic_player_set_src(player, LVGL_PATH(cartoon_mjpeg.mp4));
|
||||
else
|
||||
lv_aic_player_set_src(player, LVGL_PATH(elevator_mjpeg.mp4));
|
||||
lv_aic_player_set_src(player, LVGL_PATH(world-cup.png)); // private apng format
|
||||
if (g_playing)
|
||||
lv_aic_player_set_cmd(player, LV_AIC_PLAYER_CMD_START, NULL);
|
||||
cur_video = cur_video == 0 ? 1 :0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
After Width: | Height: | Size: 34 KiB |
|
After Width: | Height: | Size: 34 KiB |
@@ -21,6 +21,10 @@ void aic_img_roller(void);
|
||||
extern void aic_player_demo(void);
|
||||
#endif
|
||||
|
||||
#ifdef AIC_APNG_DEMO
|
||||
extern void aic_png_demo(void);
|
||||
#endif
|
||||
|
||||
#ifdef AIC_IMAGE_USAGE_DEMO
|
||||
extern void aic_img_usage(void);
|
||||
#endif
|
||||
@@ -38,6 +42,10 @@ void ui_init(void)
|
||||
aic_player_demo();
|
||||
#endif
|
||||
|
||||
#ifdef AIC_APNG_DEMO
|
||||
aic_png_demo();
|
||||
#endif
|
||||
|
||||
#ifdef AIC_IMAGE_USAGE_DEMO
|
||||
aic_img_usage();
|
||||
#endif
|
||||
|
||||
@@ -86,13 +86,6 @@ lv_obj_t *aic_video_ui_init(void)
|
||||
|
||||
lv_obj_add_event_cb(aic_video_ui, ui_aic_video_cb, LV_EVENT_ALL, &player);
|
||||
|
||||
/* Enable LV_AIC_PLAYER_CMD_KEEP_LAST_FRAME_EX when playing multiple video sources
|
||||
to avoid black screens during source switching, though it will increase memory usage.
|
||||
Alternatively, add a loading icon to indicate to users that a switch is in progress,
|
||||
which can mitigate the impact of black screens on viewing experience.
|
||||
Need to set before setting src. */
|
||||
//lv_aic_player_set_cmd(player.obj, LV_AIC_PLAYER_CMD_KEEP_LAST_FRAME_EX, NULL);
|
||||
|
||||
lv_aic_player_set_src(player.obj, player.cur_info.source);
|
||||
lv_aic_player_set_cmd(player.obj, LV_AIC_PLAYER_CMD_START, NULL);
|
||||
|
||||
|
||||
21
packages/artinchip/lvgl-ui/aic_demo/dm_daemon/SConscript
Executable file
@@ -0,0 +1,21 @@
|
||||
from building import *
|
||||
import os
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
group = []
|
||||
src = Glob('*.c')
|
||||
CPPPATH = [cwd]
|
||||
|
||||
list = os.listdir(cwd)
|
||||
for d in list:
|
||||
path = os.path.join(cwd, d)
|
||||
if os.path.isfile(os.path.join(path, 'SConscript')):
|
||||
group = group + SConscript(os.path.join(d, 'SConscript'))
|
||||
|
||||
install = [('assets/', 'rodata/'), ('bin/', 'data/')]
|
||||
|
||||
|
||||
group = group + DefineGroup('LVGL-port', src, depend = ['AIC_LVGL_DM_DAEMON'], CPPPATH = CPPPATH,
|
||||
INSTALL=install)
|
||||
|
||||
Return('group')
|
||||
BIN
packages/artinchip/lvgl-ui/aic_demo/dm_daemon/bin/hello.mo
Executable file
28
packages/artinchip/lvgl-ui/aic_demo/dm_daemon/dm_daemon.c
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (C) 2022-2025 ArtInChip Technology Co., Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Authors: Geo Dong <guojun.dong@artinchip.com>
|
||||
*/
|
||||
#include <rtthread.h>
|
||||
#include "lvgl.h"
|
||||
#include "dfs_posix.h"
|
||||
#include <sys/errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
// #define DM_EXCUTABLE_FILE "/sdcard/hello.mo"
|
||||
#define DM_EXCUTABLE_FILE "/data/hello.mo"
|
||||
|
||||
int dm_daemon(void)
|
||||
{
|
||||
if (access(DM_EXCUTABLE_FILE, 0) == 0) {
|
||||
printf(" '%s' exist\n", DM_EXCUTABLE_FILE);
|
||||
system(DM_EXCUTABLE_FILE);
|
||||
} else {
|
||||
printf("file '%s' does not exist!\n", DM_EXCUTABLE_FILE);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
54
packages/artinchip/lvgl-ui/aic_demo/dm_daemon/dm_export.c
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (C) 2022-2025 ArtInChip Technology Co., Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Authors: Geo Dong <guojun.dong@artinchip.com>
|
||||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <lvgl.h>
|
||||
#include <rtm.h>
|
||||
#include <stdint.h>
|
||||
#include "aic_common.h"
|
||||
|
||||
// LVGL API
|
||||
RTM_EXPORT(lv_obj_remove_flag);
|
||||
RTM_EXPORT(lv_obj_add_event_cb);
|
||||
RTM_EXPORT(lv_obj_align);
|
||||
RTM_EXPORT(lv_screen_active);
|
||||
RTM_EXPORT(lv_button_create);
|
||||
RTM_EXPORT(lv_display_get_screen_active);
|
||||
RTM_EXPORT(lv_display_get_default);
|
||||
RTM_EXPORT(lv_event_get_code);
|
||||
RTM_EXPORT(lv_log_register_print_cb);
|
||||
RTM_EXPORT(lv_tick_set_cb);
|
||||
RTM_EXPORT(lv_init);
|
||||
RTM_EXPORT(lv_timer_handler);
|
||||
RTM_EXPORT(lv_label_create);
|
||||
RTM_EXPORT(lv_label_set_text);
|
||||
RTM_EXPORT(lv_obj_center);
|
||||
RTM_EXPORT(lv_obj_set_height);
|
||||
RTM_EXPORT(lv_obj_add_flag);
|
||||
|
||||
// ArtInChip API
|
||||
extern int lvgl_thread_init(void);
|
||||
RTM_EXPORT(lvgl_thread_init);
|
||||
extern void lv_port_disp_init(void);
|
||||
RTM_EXPORT(lv_port_disp_init);
|
||||
extern void lv_port_indev_init(void);
|
||||
RTM_EXPORT(lv_port_indev_init);
|
||||
extern void lv_user_gui_init(void);
|
||||
RTM_EXPORT(lv_user_gui_init);
|
||||
extern void lv_wait_fs_mounted(void);
|
||||
RTM_EXPORT(lv_wait_fs_mounted);
|
||||
extern void aic_mdelay(u32 ms);
|
||||
RTM_EXPORT(aic_mdelay);
|
||||
|
||||
// RT-Thread API
|
||||
RTM_EXPORT(rt_tick_get_millisecond);
|
||||
extern void ulog_output(rt_uint32_t level, const char *tag, rt_bool_t newline, const char *format, ...);
|
||||
RTM_EXPORT(ulog_output);
|
||||
extern struct dfs_filesystem *dfs_filesystem_lookup(const char *path);
|
||||
RTM_EXPORT(dfs_filesystem_lookup);
|
||||
|
||||
@@ -13,7 +13,11 @@
|
||||
#define LV_CONF_CUSTOM_H
|
||||
|
||||
/* code begin */
|
||||
#undef LV_USE_FREETYPE
|
||||
#undef LV_USE_IME_PINYIN
|
||||
|
||||
#define LV_USE_FREETYPE 1
|
||||
#define LV_USE_IME_PINYIN 1
|
||||
/* code end */
|
||||
|
||||
#endif /* LV_CONF_CUSTOM_H */
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
/* code begin */
|
||||
|
||||
#undef LV_USE_FREETYPE
|
||||
#define LV_USE_FREETYPE 1
|
||||
#define LV_USE_FREETYPE 0
|
||||
|
||||
/* code end */
|
||||
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2025, ArtInChip Technology Co., Ltd
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Authors: zequan liang <zequan liang@artinchip.com>
|
||||
*/
|
||||
#include "simple_msg_queen.h"
|
||||
#include <rtthread.h>
|
||||
|
||||
static rt_mq_t g_ui_mq;
|
||||
|
||||
int simple_msg_queen_init(void)
|
||||
{
|
||||
g_ui_mq = rt_mq_create("ui_mq", sizeof(ui_message_t), 128, RT_IPC_FLAG_FIFO);
|
||||
if (g_ui_mq == RT_NULL) {
|
||||
rt_kprintf("create message queue failed!\n");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int simple_msg_queen_send(ui_message_t *msg)
|
||||
{
|
||||
if(rt_mq_send(g_ui_mq, msg, sizeof(ui_message_t)) == RT_EOK)
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int simple_msg_queen_recv(ui_message_t * msg)
|
||||
{
|
||||
if(rt_mq_recv(g_ui_mq, msg, sizeof(ui_message_t), 0) == RT_EOK) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
@@ -11,7 +11,8 @@
|
||||
#include <aic_core.h>
|
||||
#include "simple_serial.h"
|
||||
|
||||
#define DEBUG_SIMPLE_SERIAL 1
|
||||
#define UART_MQ_SIZE 128
|
||||
|
||||
static rt_mq_t g_rx_mq;
|
||||
static rt_device_t g_serial;
|
||||
|
||||
@@ -25,6 +26,12 @@ static rt_err_t serial_input_mq(rt_device_t dev, rt_size_t size);
|
||||
|
||||
int simple_serial_init(char *uart, int boaud, int data_bits, int stop_bits, int parity)
|
||||
{
|
||||
g_rx_mq = rt_mq_create("uart_rx_mq", sizeof(struct rx_msg), UART_MQ_SIZE, RT_IPC_FLAG_FIFO);
|
||||
if (!g_rx_mq) {
|
||||
printf("rt mq create failed, msq size = %d\n", sizeof(struct rx_msg) * UART_MQ_SIZE);
|
||||
return -1;
|
||||
}
|
||||
|
||||
g_serial = rt_device_find(uart);
|
||||
if (!g_serial)
|
||||
{
|
||||
@@ -44,59 +51,56 @@ int simple_serial_init(char *uart, int boaud, int data_bits, int stop_bits, int
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* recv config */
|
||||
rt_device_set_rx_indicate(g_serial, serial_input_mq);
|
||||
uint32_t msg_num = 128;
|
||||
uint32_t msg_pool_size = sizeof(struct rx_msg) * msg_num;
|
||||
g_rx_mq = rt_mq_create("uart_rx_mq", msg_pool_size, sizeof(struct rx_msg), RT_IPC_FLAG_FIFO);
|
||||
|
||||
rt_err_t ret = rt_device_open(g_serial, RT_DEVICE_OFLAG_RDWR | RT_DEVICE_FLAG_INT_RX);
|
||||
if (ret != RT_EOK) {
|
||||
printf("open %s failed !\n", uart);
|
||||
return -RT_ERROR;
|
||||
}
|
||||
|
||||
/* recv config */
|
||||
rt_device_set_rx_indicate(g_serial, serial_input_mq);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int simple_serial_send(unsigned char *data, int len)
|
||||
{
|
||||
if (rt_device_write(g_serial, 0, data, len) == RT_EOK)
|
||||
return 0;
|
||||
|
||||
return -1;
|
||||
if (rt_device_write(g_serial, 0, data, len) != RT_EOK) {
|
||||
rt_kprintf("rt write serial failed, name = %d", g_serial->parent.name);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int simple_serial_recv(unsigned char *data, int max_len)
|
||||
{
|
||||
struct rx_msg msg;
|
||||
struct rx_msg msg = {0};
|
||||
int len = -1;
|
||||
|
||||
rt_memset(&msg, 0, sizeof(msg));
|
||||
if (rt_mq_recv(g_rx_mq, &msg, sizeof(msg), 10000) == 0) {
|
||||
if (rt_mq_recv(g_rx_mq, &msg, sizeof(msg), RT_WAITING_FOREVER) == 0) {
|
||||
if (msg.size >= max_len - 1) {
|
||||
len = rt_device_read(msg.dev, 0, data, max_len - 1);
|
||||
printf("The %s receive buffer is configured too small. config size = %d, recv size = %d", g_serial->parent.name, max_len, msg.size);
|
||||
} else {
|
||||
len = rt_device_read(msg.dev, 0, data, msg.size);
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG_SIMPLE_SERIAL
|
||||
if (len > 0)
|
||||
simple_serial_send(data, len);
|
||||
#endif
|
||||
return len;
|
||||
}
|
||||
|
||||
static rt_err_t serial_input_mq(rt_device_t dev, rt_size_t size)
|
||||
{
|
||||
struct rx_msg msg;
|
||||
rt_err_t result;
|
||||
struct rx_msg msg = {0};
|
||||
rt_err_t result = 0;
|
||||
msg.dev = dev;
|
||||
msg.size = size;
|
||||
|
||||
result = rt_mq_send(g_rx_mq, &msg, sizeof(msg));
|
||||
if (result == -RT_EFULL) {
|
||||
printf("message queue full!\n");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (C) 2025, ArtInChip Technology Co., Ltd
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Authors: zequan liang <zequan liang@artinchip.com>
|
||||
*/
|
||||
#include "ui_msg_queen.h"
|
||||
#include <rtthread.h>
|
||||
|
||||
#define SIMPLE_MQ_SIZE 128
|
||||
static rt_mq_t g_ui_mq;
|
||||
|
||||
int ui_msg_queen_init(void)
|
||||
{
|
||||
g_ui_mq = rt_mq_create("ui_mq", sizeof(ui_message_t), SIMPLE_MQ_SIZE, RT_IPC_FLAG_FIFO);
|
||||
if (g_ui_mq == RT_NULL) {
|
||||
rt_kprintf("create message queue failed!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ui_msg_queen_send(ui_message_t *msg)
|
||||
{
|
||||
if(rt_mq_send(g_ui_mq, msg, sizeof(ui_message_t)) != RT_EOK) {
|
||||
rt_kprintf("rt send mq failed, mq name = %s", g_ui_mq->parent.parent.name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ui_msg_queen_recv(ui_message_t * msg)
|
||||
{
|
||||
if(rt_mq_recv(g_ui_mq, msg, sizeof(ui_message_t), 0) != RT_EOK) {
|
||||
rt_kprintf("rt recv mq failed, mq name = %s", g_ui_mq->parent.parent.name);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -6,11 +6,12 @@
|
||||
* Authors: zequan liang <zequan liang@artinchip.com>
|
||||
*/
|
||||
|
||||
#define SIMPLE_MSQ_SIZE 256
|
||||
typedef struct {
|
||||
char *msg;
|
||||
char msg[SIMPLE_MSQ_SIZE];
|
||||
int msg_len;
|
||||
} ui_message_t;
|
||||
|
||||
int simple_msg_queen_init(void);
|
||||
int simple_msg_queen_send(ui_message_t *msg);
|
||||
int simple_msg_queen_recv(ui_message_t *msg);
|
||||
int ui_msg_queen_init(void);
|
||||
int ui_msg_queen_send(ui_message_t *msg);
|
||||
int ui_msg_queen_recv(ui_message_t *msg);
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "string.h"
|
||||
|
||||
#include "./view/simple_screen.h"
|
||||
#include "./module/simple_msg_queen.h"
|
||||
#include "./module/ui_msg_queen.h"
|
||||
#include "./module/simple_serial.h"
|
||||
|
||||
#define LOAD_SCREEN_0_CMD "load simple_screen_0"
|
||||
@@ -20,15 +20,15 @@
|
||||
#define SCREEN_0_PREFIX "simple_screen_0"
|
||||
#define SCREEN_1_PREFIX "simple_screen_1"
|
||||
|
||||
static void send_ui_msg_thread_entry(void *parameter);
|
||||
static int send_ui_msg_thread_init(void);
|
||||
static void recv_ui_msg_timer_cb(lv_timer_t *timer);
|
||||
static int recv_ui_msg_timer_init(void);
|
||||
static void serial_recv_entry(void *parameter);
|
||||
static int serial_recv_thread_init(void);
|
||||
static void process_ui_msg_cb(lv_timer_t *timer);
|
||||
static int process_ui_msg_timer_init(void);
|
||||
|
||||
static lv_obj_t *g_simple_screen0;
|
||||
static lv_obj_t *g_simple_screen1;
|
||||
|
||||
char g_cureent_screen[128];
|
||||
char g_current_screen[128];
|
||||
|
||||
void ui_init(void)
|
||||
{
|
||||
@@ -39,7 +39,7 @@ void ui_init(void)
|
||||
|
||||
lv_screen_load_anim(g_simple_screen0, LV_SCR_LOAD_ANIM_FADE_ON, 2000, 0, 0);
|
||||
|
||||
ret = simple_msg_queen_init();
|
||||
ret = ui_msg_queen_init();
|
||||
if (ret < 0)
|
||||
return;
|
||||
|
||||
@@ -47,47 +47,44 @@ void ui_init(void)
|
||||
if (ret < 0)
|
||||
return;
|
||||
|
||||
ret = send_ui_msg_thread_init();
|
||||
ret = serial_recv_thread_init();
|
||||
if (ret < 0)
|
||||
return;
|
||||
|
||||
recv_ui_msg_timer_init();
|
||||
process_ui_msg_timer_init();
|
||||
}
|
||||
|
||||
char *get_current_active_screen_str(void)
|
||||
{
|
||||
return g_cureent_screen;
|
||||
return g_current_screen;
|
||||
}
|
||||
|
||||
void set_current_acvtive_screen_str(const char *name)
|
||||
void set_current_active_screen_str(const char *name)
|
||||
{
|
||||
memset(g_cureent_screen, 0, sizeof(g_cureent_screen));
|
||||
strncpy(g_cureent_screen, name, sizeof(g_cureent_screen) - 1);
|
||||
memset(g_current_screen, 0, sizeof(g_current_screen));
|
||||
strncpy(g_current_screen, name, sizeof(g_current_screen) - 1);
|
||||
}
|
||||
|
||||
static void send_ui_msg_thread_entry(void *parameter)
|
||||
static void serial_recv_entry(void *parameter)
|
||||
{
|
||||
ui_message_t ui_msg = {0};
|
||||
uint8_t buffer[128] = {0};
|
||||
int len = 0;
|
||||
|
||||
while (1) {
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
memset(&ui_msg, 0, sizeof(ui_message_t));
|
||||
|
||||
len = simple_serial_recv(buffer, sizeof(buffer));
|
||||
len = simple_serial_recv((unsigned char *)ui_msg.msg, SIMPLE_MSQ_SIZE);
|
||||
if (len <= 0)
|
||||
continue;
|
||||
|
||||
ui_msg.msg = lv_strdup((char *)buffer);
|
||||
ui_msg.msg_len = len;
|
||||
simple_msg_queen_send(&ui_msg);
|
||||
ui_msg_queen_send(&ui_msg);
|
||||
}
|
||||
}
|
||||
|
||||
static int send_ui_msg_thread_init(void)
|
||||
static int serial_recv_thread_init(void)
|
||||
{
|
||||
rt_thread_t thread = rt_thread_create("ui_msg_send", send_ui_msg_thread_entry, RT_NULL, 1024*4, 25, 10);
|
||||
rt_thread_t thread = rt_thread_create("ui_msg_send", serial_recv_entry, RT_NULL, 1024*4, 20, 10);
|
||||
if (thread == RT_NULL) {
|
||||
printf("create ui msg thread failed!\n");
|
||||
return -1;
|
||||
@@ -97,11 +94,11 @@ static int send_ui_msg_thread_init(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void recv_ui_msg_timer_cb(lv_timer_t *timer)
|
||||
static void process_ui_msg_cb(lv_timer_t *timer)
|
||||
{
|
||||
ui_message_t msg;
|
||||
|
||||
if (simple_msg_queen_recv(&msg) == -1)
|
||||
if (ui_msg_queen_recv(&msg) == -1)
|
||||
return;
|
||||
|
||||
/* handle msg */
|
||||
@@ -118,13 +115,11 @@ static void recv_ui_msg_timer_cb(lv_timer_t *timer)
|
||||
lv_obj_t *label = simple_screen_get_label(g_simple_screen1);
|
||||
lv_label_set_text_fmt(label, "msg1:%s", msg.msg);
|
||||
}
|
||||
|
||||
lv_free(msg.msg);
|
||||
}
|
||||
|
||||
static int recv_ui_msg_timer_init(void)
|
||||
static int process_ui_msg_timer_init(void)
|
||||
{
|
||||
if (lv_timer_create(recv_ui_msg_timer_cb, 5, NULL) == NULL) {
|
||||
if (lv_timer_create(process_ui_msg_cb, 5, NULL) == NULL) {
|
||||
printf("create recv_ui_msg_timer failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ lv_obj_t *simple_screen_create(void)
|
||||
{
|
||||
char current_name[32] = {0};
|
||||
|
||||
snprintf(current_name, sizeof(current_name), "simple_screen_%d:None", simple_screen_count);
|
||||
snprintf(current_name, sizeof(current_name), "simple_screen_%d:None", (int)simple_screen_count);
|
||||
|
||||
lv_obj_t *screen = lv_obj_create(NULL);
|
||||
lv_obj_set_size(screen, LV_HOR_RES, LV_VER_RES);
|
||||
@@ -52,8 +52,8 @@ static void simple_screen_cb(lv_event_t *e)
|
||||
}
|
||||
|
||||
if (code == LV_EVENT_SCREEN_LOADED) {
|
||||
snprintf(current_name, sizeof(current_name), "simple_screen_%d", *id);
|
||||
extern void set_current_acvtive_screen_str(const char *name);
|
||||
set_current_acvtive_screen_str(current_name);
|
||||
snprintf(current_name, sizeof(current_name), "simple_screen_%d", (int)*id);
|
||||
extern void set_current_active_screen_str(const char *name);
|
||||
set_current_active_screen_str(current_name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
from building import *
|
||||
import os
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
group = []
|
||||
src = Glob('*.c')
|
||||
CPPPATH = [cwd]
|
||||
|
||||
list = os.listdir(cwd)
|
||||
for d in list:
|
||||
path = os.path.join(cwd, d)
|
||||
if os.path.isfile(os.path.join(path, 'SConscript')):
|
||||
group = group + SConscript(os.path.join(d, 'SConscript'))
|
||||
|
||||
if GetDepend(['LVGL_STORAGE_PATH']):
|
||||
ins_dst = GetDepend('LVGL_STORAGE_PATH').strip('"/')
|
||||
else:
|
||||
ins_dst='rodata/lvgl_data'
|
||||
|
||||
ins_src = 'assets/'
|
||||
install = [(ins_src, ins_dst)]
|
||||
|
||||
group = group + DefineGroup('LVGL-port', src, depend = ['AIC_LVGL_SPI_EXTEND_DEMO'], CPPPATH = CPPPATH,
|
||||
INSTALL = install)
|
||||
|
||||
Return('group')
|
||||
|
||||
|
After Width: | Height: | Size: 136 KiB |
|
After Width: | Height: | Size: 133 KiB |
|
After Width: | Height: | Size: 485 KiB |
|
After Width: | Height: | Size: 136 KiB |
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright (C) 2025 ArtInChip Technology Co., Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* lv_conf_custom.h for custom lv_conf.h file
|
||||
* example :
|
||||
* #undef LV_USE_LOG
|
||||
* #define LV_USE_LOG 1
|
||||
*/
|
||||
|
||||
#ifndef LV_CONF_CUSTOM_H
|
||||
#define LV_CONF_CUSTOM_H
|
||||
|
||||
/* code begin */
|
||||
|
||||
/* code end */
|
||||
|
||||
#endif /* LV_CONF_CUSTOM_H */
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (C) 2025, ArtInChip Technology Co., Ltd
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Authors: zequan liang <zequan liang@artinchip.com>
|
||||
*/
|
||||
|
||||
#include "aic_ui.h"
|
||||
#include "lv_aic_spi.h"
|
||||
#include "lv_aic_player.h"
|
||||
|
||||
/* the relationship between display, screen, and obj
|
||||
┌───────────────────────────────────────────────────────────────┐
|
||||
│ Physical Displays (disp) │
|
||||
│ ┌─────────────────────┐ ┌─────────────────────┐ │
|
||||
│ │ SPI Display │ │ DE Display │ │
|
||||
│ └──────────┬──────────┘ └──────────┬──────────┘ │
|
||||
│ │ │ │
|
||||
│ ┌──────────▼──────────┐ ┌──────────▼──────────┐ │
|
||||
│ │ Screen 1 │ │ Screen 2 │ │
|
||||
│ │ (root container) │ │ (root container) │ │
|
||||
│ └──────────┬──────────┘ └──────────┬──────────┘ │
|
||||
│ │ │ │
|
||||
│ ┌──────────▼──────────┐ ┌──────────▼──────────┐ │
|
||||
│ │ APNG Player Object │ │ APNG Player Object │ │
|
||||
│ │ (child widget) │ │ (child widget) │ │
|
||||
│ └─────────────────────┘ └─────────────────────┘ │
|
||||
└───────────────────────────────────────────────────────────────┘
|
||||
*/
|
||||
|
||||
typedef void (*lv_disp_operation_t)(void* user_data);
|
||||
|
||||
static lv_obj_t *lv_aic_apng_create(lv_obj_t *obj, void *src);
|
||||
static void lv_obj_with_disp(lv_disp_t* disp, lv_disp_operation_t operation, void* user_data);
|
||||
static void init_screen(void *user_data);
|
||||
|
||||
void ui_init(void)
|
||||
{
|
||||
lv_disp_t *spi_disp = lv_disp_get_next(NULL); /* get the head display */
|
||||
lv_disp_t *de_disp = lv_disp_get_next(spi_disp);
|
||||
|
||||
lv_obj_with_disp(spi_disp, init_screen, LVGL_PATH(A1_b0.png));
|
||||
|
||||
lv_obj_with_disp(de_disp, init_screen, LVGL_PATH(A2_b0.png));
|
||||
}
|
||||
|
||||
static lv_obj_t *lv_aic_apng_create(lv_obj_t *obj, void *src)
|
||||
{
|
||||
lv_obj_t *player;
|
||||
player = lv_aic_player_create(obj);
|
||||
lv_aic_player_set_src(player, src);
|
||||
lv_aic_player_set_auto_restart(player, true);
|
||||
lv_aic_player_set_cmd(player, LV_AIC_PLAYER_CMD_START, NULL);
|
||||
return player;
|
||||
}
|
||||
|
||||
static void lv_obj_with_disp(lv_disp_t* disp, lv_disp_operation_t operation, void* user_data)
|
||||
{
|
||||
if(!disp || !operation) return;
|
||||
|
||||
lv_disp_t* old_disp = lv_disp_get_default();
|
||||
lv_disp_set_default(disp);
|
||||
|
||||
operation(user_data);
|
||||
|
||||
lv_disp_set_default(old_disp);
|
||||
}
|
||||
|
||||
static void init_screen(void *user_data)
|
||||
{
|
||||
char *image_path = (char *)user_data;
|
||||
|
||||
lv_obj_t *screen = lv_obj_create(NULL);
|
||||
lv_obj_t *player = lv_aic_apng_create(screen, image_path);
|
||||
lv_obj_align(player, LV_ALIGN_CENTER, 0, 0);
|
||||
lv_scr_load(screen);
|
||||
}
|
||||
@@ -257,22 +257,15 @@ static void usb_osd_ui_theme_set(void)
|
||||
}
|
||||
|
||||
#ifdef LV_USB_OSD_SETTINGS_MENU
|
||||
static bool wake_up_key = false;
|
||||
|
||||
static void gpio_input_irq_handler(void *args)
|
||||
{
|
||||
struct osd_manager *mgr = usb_osd_get_ui_manager();
|
||||
|
||||
if (mgr->current_state & STATE_SETTINGS)
|
||||
mgr->new_state &= ~(STATE_SETTINGS);
|
||||
else
|
||||
mgr->new_state |= STATE_SETTINGS;
|
||||
|
||||
USB_OSD_DEBUG("%s\n", __func__);
|
||||
wake_up_key = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void usb_osd_wakeup_key_register(void)
|
||||
static void keypad_init(void)
|
||||
{
|
||||
#ifdef LV_USB_OSD_SETTINGS_MENU
|
||||
u32 pin;
|
||||
|
||||
/* 1.get pin number */
|
||||
@@ -287,6 +280,61 @@ static void usb_osd_wakeup_key_register(void)
|
||||
|
||||
/* 4.enable pin irq */
|
||||
rt_pin_irq_enable(pin, PIN_IRQ_ENABLE);
|
||||
}
|
||||
|
||||
static uint32_t keypad_get_key(void)
|
||||
{
|
||||
if (wake_up_key) {
|
||||
wake_up_key = false;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void keypad_read(lv_indev_t * indev_drv, lv_indev_data_t * data)
|
||||
{
|
||||
static uint32_t last_key = 0;
|
||||
|
||||
uint32_t act_key = keypad_get_key();
|
||||
if (act_key != 0) {
|
||||
data->state = LV_INDEV_STATE_PR;
|
||||
|
||||
act_key = LV_KEY_ENTER;
|
||||
last_key = act_key;
|
||||
} else {
|
||||
data->state = LV_INDEV_STATE_REL;
|
||||
}
|
||||
|
||||
data->key = last_key;
|
||||
}
|
||||
|
||||
static void wakeup_key_event_callback(lv_event_t *e)
|
||||
{
|
||||
struct osd_manager *mgr = usb_osd_get_ui_manager();
|
||||
|
||||
if (mgr->current_state & STATE_SETTINGS)
|
||||
mgr->new_state &= ~(STATE_SETTINGS);
|
||||
else
|
||||
mgr->new_state |= STATE_SETTINGS;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void usb_osd_wakeup_key_register(void)
|
||||
{
|
||||
#ifdef LV_USB_OSD_SETTINGS_MENU
|
||||
keypad_init();
|
||||
|
||||
lv_indev_t * indev_keypad;
|
||||
indev_keypad = lv_indev_create();
|
||||
lv_indev_set_type(indev_keypad, LV_INDEV_TYPE_KEYPAD);
|
||||
lv_indev_set_read_cb(indev_keypad, keypad_read);
|
||||
|
||||
lv_group_t * group = lv_group_create();
|
||||
lv_group_add_obj(group, lv_scr_act());
|
||||
lv_indev_set_group(indev_keypad, group);
|
||||
|
||||
lv_indev_add_event_cb(indev_keypad, wakeup_key_event_callback, LV_EVENT_CLICKED, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -364,6 +412,9 @@ int usb_disp_get_suspend_ms(void)
|
||||
}
|
||||
|
||||
#ifdef LV_USB_OSD_LOGO_VIDEO
|
||||
extern uint8_t usb_display_en;
|
||||
static uint8_t lv_display_en = 0;
|
||||
|
||||
static void ffmpeg_player_update_cb(lv_timer_t * timer)
|
||||
{
|
||||
bool play_end = false;
|
||||
@@ -378,6 +429,10 @@ static void ffmpeg_player_update_cb(lv_timer_t * timer)
|
||||
lv_timer_pause(play_end_timer);
|
||||
lv_timer_del(play_end_timer);
|
||||
play_end_timer = NULL;
|
||||
|
||||
extern void usb_display_enable(void);
|
||||
if (lv_display_en)
|
||||
usb_display_enable();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -478,6 +533,10 @@ static void usb_osd_ui_display_logo(void)
|
||||
#elif defined(AIC_FB_ROTATE_EN)
|
||||
rotation = AIC_FB_ROTATE_DEGREE;
|
||||
#endif
|
||||
|
||||
lv_display_en = usb_display_en;
|
||||
usb_display_en = 0;
|
||||
|
||||
ffmpeg = lv_ffmpeg_player_create(logo_screen);
|
||||
lv_obj_set_style_transform_angle(ffmpeg, rotation, LV_PART_MAIN);
|
||||
lv_obj_add_flag(ffmpeg, LV_OBJ_FLAG_HIDDEN);
|
||||
|
||||
@@ -95,15 +95,8 @@ static void lv_bg_dark_set(lv_obj_t * parent)
|
||||
|
||||
static void lv_get_hv_timing(unsigned int *hdisplay, unsigned int *vdisplay)
|
||||
{
|
||||
struct mpp_fb * fb = mpp_fb_open();
|
||||
struct aicfb_screeninfo info;
|
||||
|
||||
mpp_fb_ioctl(fb, AICFB_GET_SCREENINFO, &info);
|
||||
|
||||
*hdisplay = info.width;
|
||||
*vdisplay = info.height;
|
||||
|
||||
mpp_fb_close(fb);
|
||||
*hdisplay = LV_HOR_RES;
|
||||
*vdisplay = LV_VER_RES;
|
||||
}
|
||||
|
||||
static bool long_press_end = 0;
|
||||
|
||||