这是一次长久的提交:

1. 应用界面增加了返回主页的按钮
2. 修复了gif渲染内存泄漏的严重bug
3. 将PetDao当中的cJSON API替换为cpp_json,完美通过测试
4. 整合已经实现的各种上层建筑,实现了一个宠物对话基本业务应用,用于样品测试展示用
5. 重构了音频播放类,使其更modern,更加便于移植和拓展
This commit is contained in:
Misaki
2025-10-16 11:36:45 +08:00
parent 801138631e
commit ba5e47bc77
38 changed files with 2487 additions and 2008 deletions
+5 -5
View File
@@ -239,7 +239,7 @@ int QSPI_Init(void){
.data6_io_num = -1,
.data7_io_num = -1,
.max_transfer_sz = ESP_PANEL_HOST_SPI_MAX_TRANSFER_SIZE,
.flags = SPICOMMON_BUSFLAG_MASTER,
.flags = SPICOMMON_BUSFLAG_MASTER,
.intr_flags = 0,
};
if(spi_bus_initialize(ESP_PANEL_HOST_SPI_ID_DEFAULT, &host_config, SPI_DMA_CH_AUTO) != ESP_OK){
@@ -252,7 +252,7 @@ int QSPI_Init(void){
.cs_gpio_num = ESP_PANEL_LCD_SPI_IO_CS,
.dc_gpio_num = -1,
.spi_mode = ESP_PANEL_LCD_SPI_MODE,
.pclk_hz = 3 * 1000 * 1000,
.pclk_hz = 3 * 1000 * 1000,
.trans_queue_depth = ESP_PANEL_LCD_SPI_TRANS_QUEUE_SZ,
.on_color_trans_done = NULL,
.user_ctx = NULL,
@@ -283,17 +283,17 @@ int QSPI_Init(void){
printf("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\r\n");
esp_err_t ret;
int lcd_cmd = 0x04;
uint8_t register_data[4];
uint8_t register_data[4];
size_t param_size = sizeof(register_data);
lcd_cmd &= 0xff;
lcd_cmd <<= 8;
lcd_cmd |= LCD_OPCODE_READ_CMD << 24; // Use the read opcode instead of write
ret = esp_lcd_panel_io_rx_param(io_handle, lcd_cmd, register_data, param_size);
ret = esp_lcd_panel_io_rx_param(io_handle, lcd_cmd, register_data, param_size);
if (ret == ESP_OK) {
printf("Register 0x04 data: %02x %02x %02x %02x\n", register_data[0], register_data[1], register_data[2], register_data[3]);
} else {
printf("Failed to read register 0x04, error code: %d\n", ret);
}
}
// panel_io_spi_del(io_handle);
io_config.pclk_hz = ESP_PANEL_LCD_SPI_CLK_HZ;
if(esp_lcd_new_panel_io_spi((esp_lcd_spi_bus_handle_t)ESP_PANEL_HOST_SPI_ID_DEFAULT, &io_config, &io_handle) != ESP_OK){
+3 -3
View File
@@ -33,8 +33,8 @@ extern "C" {
#define ESP_PANEL_HOST_SPI_ID_DEFAULT (SPI2_HOST)
#define ESP_PANEL_LCD_SPI_MODE (0) // 0/1/2/3, typically set to 0
#define ESP_PANEL_LCD_SPI_CLK_HZ (80 * 1000 * 1000) // Should be an integer divisor of 80M, typically set to 40M
#define ESP_PANEL_LCD_SPI_TRANS_QUEUE_SZ (10) // Typically set to 10
#define ESP_PANEL_LCD_SPI_CLK_HZ (40 * 1000 * 1000) // Should be an integer divisor of 80M, typically set to 40M
#define ESP_PANEL_LCD_SPI_TRANS_QUEUE_SZ (40) // Typically set to 10
#define ESP_PANEL_LCD_SPI_CMD_BITS (32) // Typically set to 32
#define ESP_PANEL_LCD_SPI_PARAM_BITS (8) // Typically set to 8
@@ -51,7 +51,7 @@ extern "C" {
#define EXAMPLE_LCD_BK_LIGHT_ON_LEVEL (1)
#define EXAMPLE_LCD_BK_LIGHT_OFF_LEVEL !EXAMPLE_LCD_BK_LIGHT_ON_LEVEL
#define ESP_PANEL_HOST_SPI_MAX_TRANSFER_SIZE (2048)
#define ESP_PANEL_HOST_SPI_MAX_TRANSFER_SIZE (8192)
#define LEDC_HS_TIMER LEDC_TIMER_0
#define LEDC_LS_MODE LEDC_LOW_SPEED_MODE
+7 -8
View File
@@ -18,13 +18,12 @@ void example_increase_lvgl_tick(void *arg)
void example_lvgl_flush_cb(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_map)
{
esp_lcd_panel_handle_t panel_handle = (esp_lcd_panel_handle_t) drv->user_data;
int offsetx1 = area->x1;
int offsetx2 = area->x2;
int offsety1 = area->y1;
int offsety2 = area->y2;
// copy a buffer's content to a specific area of the display
esp_lcd_panel_draw_bitmap(panel_handle, offsetx1, offsety1, offsetx2 +1, offsety2 + 1, color_map);
// 立即通知LVGL传输开始,使用DMA传输
lv_disp_flush_ready(drv);
// copy a buffer's content to a specific area of the display
// 异步传输数据
esp_lcd_panel_draw_bitmap(panel_handle, area->x1, area->y1, area->x2 + 1, area->y2 + 1, color_map);
}
/*Read the touchpad*/
@@ -89,7 +88,7 @@ void LVGL_Init(void)
lv_color_t *buf1 = heap_caps_malloc(LVGL_BUF_LEN * sizeof(lv_color_t), MALLOC_CAP_SPIRAM);
assert(buf1);
lv_color_t *buf2 = heap_caps_malloc(LVGL_BUF_LEN * sizeof(lv_color_t) , MALLOC_CAP_SPIRAM);
lv_color_t *buf2 = heap_caps_malloc(LVGL_BUF_LEN * sizeof(lv_color_t) , MALLOC_CAP_SPIRAM);
assert(buf2);
lv_disp_draw_buf_init(&disp_buf, buf1, buf2, LVGL_BUF_LEN); // initialize LVGL draw buffers
@@ -119,7 +118,7 @@ void LVGL_Init(void)
.callback = &example_increase_lvgl_tick,
.name = "lvgl_tick"
};
esp_timer_handle_t lvgl_tick_timer = NULL;
ESP_ERROR_CHECK(esp_timer_create(&lvgl_tick_timer_args, &lvgl_tick_timer));
ESP_ERROR_CHECK(esp_timer_start_periodic(lvgl_tick_timer, EXAMPLE_LVGL_TICK_PERIOD_MS * 1000));
+1 -1
View File
@@ -15,7 +15,7 @@ extern "C" {
#define LVGL_BUF_LEN (EXAMPLE_LCD_WIDTH * EXAMPLE_LCD_HEIGHT / 20)
#define LVGL_BUF_LEN (EXAMPLE_LCD_WIDTH * EXAMPLE_LCD_HEIGHT / 8) // 1 byte per pixel
#define EXAMPLE_LVGL_TICK_PERIOD_MS 2
extern lv_disp_draw_buf_t disp_buf; // contains internal graphic buffer(s) called draw buffer(s)