2025-02-27 17:59:18 +08:00

166 lines
3.8 KiB
C
Executable File

#include "bk_private/bk_init.h"
#include <components/system.h>
#include <os/os.h>
#include <components/shell_task.h>
#include "cli.h"
#include "lcd_act.h"
#include "media_app.h"
#include "driver/drv_tp.h"
#if (CONFIG_LVGL)
#include "lv_vendor.h"
#include "lvgl.h"
#include "page_load_ctrol.h"
#include "img_utility.h"
#endif
#include <driver/lcd.h>
#include "media_service.h"
extern void user_app_main(void);
extern void rtos_set_user_app_entry(beken_thread_function_t entry);
#define CMDS_COUNT (sizeof(s_86box_commands) / sizeof(struct cli_command))
const lcd_open_t lcd_open =
{
.device_ppi = PPI_480X480,
.device_name = "st7701s",
};
void cli_86box_cmd(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv)
{
os_printf("%s %d\r\n", __func__, __LINE__);
media_app_lvgl_close();
}
static const struct cli_command s_86box_commands[] =
{
{"86box", "86box", cli_86box_cmd},
};
int cli_86box_init(void)
{
return cli_register_commands(s_86box_commands, CMDS_COUNT);
}
#if (CONFIG_SYS_CPU1)
#include "yuv_encode.h"
#include "media_evt.h"
extern lv_obj_t *ui_tabview_screen;
void lvgl_event_open_handle(media_mailbox_msg_t *msg)
{
os_printf("%s EVENT_LVGL_OPEN_IND \n", __func__);
lv_vnd_config_t lv_vnd_config = {0};
lcd_open_t *lcd_open = (lcd_open_t *)msg->param;
#ifdef CONFIG_LVGL_USE_PSRAM
#define PSRAM_DRAW_BUFFER ((0x60000000UL) + 5 * 1024 * 1024)
lv_vnd_config.draw_pixel_size = ppi_to_pixel_x(lcd_open->device_ppi) * ppi_to_pixel_y(lcd_open->device_ppi);
lv_vnd_config.draw_buf_2_1 = (lv_color_t *)PSRAM_DRAW_BUFFER;
lv_vnd_config.draw_buf_2_2 = (lv_color_t *)(PSRAM_DRAW_BUFFER + lv_vnd_config->draw_pixel_size * sizeof(lv_color_t));
#else
#define PSRAM_FRAME_BUFFER ((0x60000000UL) + 5 * 1024 * 1024)
lv_vnd_config.draw_pixel_size = (45 * 1024) / sizeof(lv_color_t);
lv_vnd_config.draw_buf_2_1 = LV_MEM_CUSTOM_ALLOC(lv_vnd_config.draw_pixel_size * sizeof(lv_color_t));
lv_vnd_config.draw_buf_2_2 = NULL;
lv_vnd_config.frame_buf_1 = (lv_color_t *)PSRAM_FRAME_BUFFER;
lv_vnd_config.frame_buf_2 = (lv_color_t *)(PSRAM_FRAME_BUFFER + ppi_to_pixel_x(lcd_open->device_ppi) * ppi_to_pixel_y(lcd_open->device_ppi) * sizeof(lv_color_t));
#endif
lv_vnd_config.lcd_hor_res = ppi_to_pixel_x(lcd_open->device_ppi);
lv_vnd_config.lcd_ver_res = ppi_to_pixel_y(lcd_open->device_ppi);
lv_vnd_config.rotation = ROTATE_NONE;
lv_vendor_init(&lv_vnd_config);
lcd_display_open(lcd_open);
#if (CONFIG_TP)
drv_tp_open(ppi_to_pixel_x(lcd_open->device_ppi), ppi_to_pixel_y(lcd_open->device_ppi), TP_MIRROR_NONE);
#endif
lv_vendor_disp_lock();
hor_page_load_main();
lv_vendor_disp_unlock();
lv_vendor_start();
}
void lvgl_event_close_handle(media_mailbox_msg_t *msg)
{
lcd_display_close();
#if (CONFIG_TP)
drv_tp_close();
#endif
lv_vendor_stop();
lv_vendor_deinit();
}
void lvgl_event_handle(media_mailbox_msg_t *msg)
{
switch (msg->event)
{
case EVENT_LVGL_OPEN_IND:
lvgl_event_open_handle(msg);
break;
case EVENT_LVGL_CLOSE_IND:
lvgl_event_close_handle(msg);
break;
default:
break;
}
msg_send_rsp_to_media_major_mailbox(msg, BK_OK, APP_MODULE);
}
#endif
#if (CONFIG_SYS_CPU0)
void lv_86box_init(void)
{
bk_err_t ret;
os_printf("!!!BK7258 LVGL 86box!!!\r\n");
cli_86box_init();
ret = media_app_lvgl_open((lcd_open_t *)&lcd_open);
if (ret != BK_OK)
{
os_printf("media_app_lvgl_open failed\r\n");
return;
}
}
#endif
void user_app_main(void)
{
}
int main(void)
{
#if (CONFIG_SYS_CPU0)
rtos_set_user_app_entry((beken_thread_function_t)user_app_main);
// bk_set_printf_sync(true);
// shell_set_log_level(BK_LOG_WARN);
#endif
bk_init();
media_service_init();
#if (CONFIG_SYS_CPU0)
lv_86box_init();
#endif
return 0;
}