add some code

This commit is contained in:
2025-09-05 13:25:11 +08:00
parent 9ff0a99e7a
commit 3cf1229a85
8911 changed files with 2535396 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
# The following lines of boilerplate have to be in your project's CMakeLists
# in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.5)
set(EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/unit-test-app/components")
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(test_anim_player)

View File

@@ -0,0 +1,19 @@
idf_component_register(
SRC_DIRS "."
INCLUDE_DIRS "."
)
spiffs_create_partition_assets(
assets_4bit
"../test_4bit"
FLASH_IN_PROJECT
MMAP_FILE_SUPPORT_FORMAT ".aaf"
)
spiffs_create_partition_assets(
assets_8bit
"../test_8bit"
FLASH_IN_PROJECT
MMAP_FILE_SUPPORT_FORMAT ".aaf"
)

View File

@@ -0,0 +1,9 @@
## IDF Component Manager Manifest File
dependencies:
idf: '>=5.0'
image_player:
version: '*'
override_path: ../../
espressif/esp-box: ^3.1.0~1
esp_mmap_assets:
version: 1.*

View File

@@ -0,0 +1,46 @@
/*
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @file
* @brief This file was generated by esp_mmap_assets, don't modify it
*/
#pragma once
#include "esp_mmap_assets.h"
#define MMAP_TEST_4BIT_FILES 26
#define MMAP_TEST_4BIT_CHECKSUM 0x4F98
enum MMAP_TEST_4BIT_LISTS {
MMAP_TEST_4BIT_ANGER_ENTER_AAF = 0, /*!< Anger_enter.aaf */
MMAP_TEST_4BIT_ANGER_LOOP_AAF = 1, /*!< Anger_loop.aaf */
MMAP_TEST_4BIT_ANGER_RETURN_AAF = 2, /*!< Anger_return.aaf */
MMAP_TEST_4BIT_ASKING_AAF = 3, /*!< asking.aaf */
MMAP_TEST_4BIT_BLINK_ONCE_AAF = 4, /*!< blink_once.aaf */
MMAP_TEST_4BIT_BLINK_QUICK_AAF = 5, /*!< blink_quick.aaf */
MMAP_TEST_4BIT_CONNECTING_AAF = 6, /*!< connecting.aaf */
MMAP_TEST_4BIT_HAPP_RETURN_AAF = 7, /*!< happ_return.aaf */
MMAP_TEST_4BIT_HAPPY_ENTER_AAF = 8, /*!< happy_enter.aaf */
MMAP_TEST_4BIT_HAPPY_LOOP_AAF = 9, /*!< happy_loop.aaf */
MMAP_TEST_4BIT_LEFT_ENTER_AAF = 10, /*!< left_enter.aaf */
MMAP_TEST_4BIT_LEFT_LOOP_AAF = 11, /*!< left_loop.aaf */
MMAP_TEST_4BIT_LEFT_RETURN_AAF = 12, /*!< left_return.aaf */
MMAP_TEST_4BIT_PANIC_ENTER_AAF = 13, /*!< panic_enter.aaf */
MMAP_TEST_4BIT_PANIC_LOOP_AAF = 14, /*!< panic_loop.aaf */
MMAP_TEST_4BIT_PANIC_RETURN_AAF = 15, /*!< panic_return.aaf */
MMAP_TEST_4BIT_RIGHT_ENTER_AAF = 16, /*!< right_enter.aaf */
MMAP_TEST_4BIT_RIGHT_LOOP_AAF = 17, /*!< right_loop.aaf */
MMAP_TEST_4BIT_RIGHT_RETURN_AAF = 18, /*!< right_return.aaf */
MMAP_TEST_4BIT_SAD_ENTER_AAF = 19, /*!< sad_enter.aaf */
MMAP_TEST_4BIT_SAD_LOOP_AAF = 20, /*!< sad_loop.aaf */
MMAP_TEST_4BIT_SAD_RETURN_AAF = 21, /*!< sad_return.aaf */
MMAP_TEST_4BIT_SCORN_ENTER_AAF = 22, /*!< scorn_enter.aaf */
MMAP_TEST_4BIT_SCORN_LOOP_AAF = 23, /*!< scorn_loop.aaf */
MMAP_TEST_4BIT_SCORN_RETURN_AAF = 24, /*!< scorn_return.aaf */
MMAP_TEST_4BIT_WAKE_AAF = 25, /*!< wake.aaf */
};

View File

@@ -0,0 +1,46 @@
/*
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @file
* @brief This file was generated by esp_mmap_assets, don't modify it
*/
#pragma once
#include "esp_mmap_assets.h"
#define MMAP_TEST_8BIT_FILES 26
#define MMAP_TEST_8BIT_CHECKSUM 0x88D7
enum MMAP_TEST_8BIT_LISTS {
MMAP_TEST_8BIT_ANGER_ENTER_AAF = 0, /*!< Anger_enter.aaf */
MMAP_TEST_8BIT_ANGER_LOOP_AAF = 1, /*!< Anger_loop.aaf */
MMAP_TEST_8BIT_ANGER_RETURN_AAF = 2, /*!< Anger_return.aaf */
MMAP_TEST_8BIT_ASKING_AAF = 3, /*!< asking.aaf */
MMAP_TEST_8BIT_BLINK_ONCE_AAF = 4, /*!< blink_once.aaf */
MMAP_TEST_8BIT_BLINK_QUICK_AAF = 5, /*!< blink_quick.aaf */
MMAP_TEST_8BIT_CONNECTING_AAF = 6, /*!< connecting.aaf */
MMAP_TEST_8BIT_HAPP_RETURN_AAF = 7, /*!< happ_return.aaf */
MMAP_TEST_8BIT_HAPPY_ENTER_AAF = 8, /*!< happy_enter.aaf */
MMAP_TEST_8BIT_HAPPY_LOOP_AAF = 9, /*!< happy_loop.aaf */
MMAP_TEST_8BIT_LEFT_ENTER_AAF = 10, /*!< left_enter.aaf */
MMAP_TEST_8BIT_LEFT_LOOP_AAF = 11, /*!< left_loop.aaf */
MMAP_TEST_8BIT_LEFT_RETURN_AAF = 12, /*!< left_return.aaf */
MMAP_TEST_8BIT_PANIC_ENTER_AAF = 13, /*!< panic_enter.aaf */
MMAP_TEST_8BIT_PANIC_LOOP_AAF = 14, /*!< panic_loop.aaf */
MMAP_TEST_8BIT_PANIC_RETURN_AAF = 15, /*!< panic_return.aaf */
MMAP_TEST_8BIT_RIGHT_ENTER_AAF = 16, /*!< right_enter.aaf */
MMAP_TEST_8BIT_RIGHT_LOOP_AAF = 17, /*!< right_loop.aaf */
MMAP_TEST_8BIT_RIGHT_RETURN_AAF = 18, /*!< right_return.aaf */
MMAP_TEST_8BIT_SAD_ENTER_AAF = 19, /*!< sad_enter.aaf */
MMAP_TEST_8BIT_SAD_LOOP_AAF = 20, /*!< sad_loop.aaf */
MMAP_TEST_8BIT_SAD_RETURN_AAF = 21, /*!< sad_return.aaf */
MMAP_TEST_8BIT_SCORN_ENTER_AAF = 22, /*!< scorn_enter.aaf */
MMAP_TEST_8BIT_SCORN_LOOP_AAF = 23, /*!< scorn_loop.aaf */
MMAP_TEST_8BIT_SCORN_RETURN_AAF = 24, /*!< scorn_return.aaf */
MMAP_TEST_8BIT_WAKE_AAF = 25, /*!< wake.aaf */
};

View File

@@ -0,0 +1,177 @@
#include <stdio.h>
#include <string.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_log.h"
#include "unity.h"
#include "unity_test_utils.h"
#include "esp_heap_caps.h"
#include "esp_lcd_panel_io.h"
#include "esp_lcd_panel_vendor.h"
#include "esp_lcd_panel_ops.h"
#include "bsp/esp-bsp.h"
#include "anim_player.h"
#include "mmap_generate_test_4bit.h"
#include "mmap_generate_test_8bit.h"
static const char *TAG = "player";
#define TEST_MEMORY_LEAK_THRESHOLD (500)
static size_t before_free_8bit;
static size_t before_free_32bit;
static anim_player_handle_t handle = NULL;
static esp_lcd_panel_io_handle_t io_handle = NULL;
static esp_lcd_panel_handle_t panel_handle = NULL;
void setUp(void)
{
before_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT);
before_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT);
}
void tearDown(void)
{
size_t after_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT);
size_t after_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT);
unity_utils_check_leak(before_free_8bit, after_free_8bit, "8BIT", TEST_MEMORY_LEAK_THRESHOLD);
unity_utils_check_leak(before_free_32bit, after_free_32bit, "32BIT", TEST_MEMORY_LEAK_THRESHOLD);
}
static bool flush_io_ready(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_io_event_data_t *edata, void *user_ctx)
{
anim_player_handle_t handle = (anim_player_handle_t)user_ctx;
anim_player_flush_ready(handle);
return true;
}
static void flush_callback(anim_player_handle_t handle, int x1, int y1, int x2, int y2, const void *data)
{
esp_lcd_panel_handle_t panel = (esp_lcd_panel_handle_t)anim_player_get_user_data(handle);
// if(y1 == 0) {
// ESP_LOGI(TAG, "Flush: (%03d,%03d) (%03d,%03d)", x1, y1, x2, y2);
// }
esp_lcd_panel_draw_bitmap(panel, x1, y1, x2, y2, data);
}
static void update_callback(anim_player_handle_t handle, player_event_t event)
{
switch (event) {
case PLAYER_EVENT_IDLE:
ESP_LOGI(TAG, "Event: IDLE");
break;
case PLAYER_EVENT_ONE_FRAME_DONE:
// ESP_LOGI(TAG, "Event: ONE_FRAME_DONE");
break;
case PLAYER_EVENT_ALL_FRAME_DONE:
ESP_LOGI(TAG, "Event: ALL_FRAME_DONE");
break;
default:
ESP_LOGI(TAG, "Event: UNKNOWN");
break;
}
}
static void test_anim_player_common(const char *partition_label, uint32_t max_files, uint32_t checksum, uint32_t delay_ms)
{
mmap_assets_handle_t assets_handle = NULL;
const mmap_assets_config_t asset_config = {
.partition_label = partition_label,
.max_files = max_files,
.checksum = checksum,
.flags = {.mmap_enable = true, .full_check = true}
};
esp_err_t ret = mmap_assets_new(&asset_config, &assets_handle);
if (ret != ESP_OK) {
ESP_LOGE(TAG, "Failed to initialize assets");
return;
}
const bsp_display_config_t bsp_disp_cfg = {
.max_transfer_sz = (240 * 10) * sizeof(uint16_t),
};
bsp_display_new(&bsp_disp_cfg, &panel_handle, &io_handle);
esp_lcd_panel_disp_on_off(panel_handle, true);
bsp_display_brightness_init();
bsp_display_backlight_on();
anim_player_config_t config = {
.flush_cb = flush_callback,
.update_cb = update_callback,
.user_data = panel_handle,
.flags = {.swap = true},
.task = ANIM_PLAYER_INIT_CONFIG()
};
handle = anim_player_init(&config);
TEST_ASSERT_NOT_NULL(handle);
const esp_lcd_panel_io_callbacks_t cbs = {
.on_color_trans_done = flush_io_ready,
};
esp_lcd_panel_io_register_event_callbacks(io_handle, &cbs, handle);
uint32_t start, end;
const void *src_data;
size_t src_len;
for(int i = 0; i < mmap_assets_get_stored_files(assets_handle); i++) {
src_data = mmap_assets_get_mem(assets_handle, i);
src_len = mmap_assets_get_size(assets_handle, i);
ESP_LOGW(TAG, "set src, %s", mmap_assets_get_name(assets_handle, i));
anim_player_set_src_data(handle, src_data, src_len);
anim_player_get_segment(handle, &start, &end);
anim_player_set_segment(handle, start, end, 30, true);
ESP_LOGW(TAG, "start:%" PRIu32 ", end:%" PRIu32 "", start, end);
anim_player_update(handle, PLAYER_ACTION_START);
vTaskDelay(pdMS_TO_TICKS(1000 * delay_ms));
anim_player_update(handle, PLAYER_ACTION_STOP);
vTaskDelay(pdMS_TO_TICKS(1000 * delay_ms));
}
ESP_LOGI(TAG, "test done");
if (handle) {
anim_player_deinit(handle);
handle = NULL;
}
if (assets_handle) {
mmap_assets_del(assets_handle);
assets_handle = NULL;
}
if (panel_handle) {
esp_lcd_panel_del(panel_handle);
}
if (io_handle) {
esp_lcd_panel_io_del(io_handle);
}
spi_bus_free(BSP_LCD_SPI_NUM);
vTaskDelay(pdMS_TO_TICKS(1000));
}
TEST_CASE("test anim player init and deinit", "[anim_player][4bit]")
{
test_anim_player_common("assets_4bit", MMAP_TEST_4BIT_FILES, MMAP_TEST_4BIT_CHECKSUM, 5);
}
TEST_CASE("test anim player init and deinit", "[anim_player][8bit]")
{
test_anim_player_common("assets_8bit", MMAP_TEST_8BIT_FILES, MMAP_TEST_8BIT_CHECKSUM, 5);
}
void app_main(void)
{
printf("Animation player test\n");
unity_run_menu();
}

View File

@@ -0,0 +1,7 @@
# Name, Type, SubType, Offset, Size, Flags
# Note: if you change the phy_init or app partition offset, make sure to change the offset in Kconfig.projbuild
nvs, data, nvs, , 0x6000,
phy_init, data, phy, , 0x1000,
factory, app, factory, , 500K,
assets_4bit, data, spiffs, , 300K,
assets_8bit, data, spiffs, , 900K,
1 # Name, Type, SubType, Offset, Size, Flags
2 # Note: if you change the phy_init or app partition offset, make sure to change the offset in Kconfig.projbuild
3 nvs, data, nvs, , 0x6000,
4 phy_init, data, phy, , 0x1000,
5 factory, app, factory, , 500K,
6 assets_4bit, data, spiffs, , 300K,
7 assets_8bit, data, spiffs, , 900K,

View File

@@ -0,0 +1,18 @@
# SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
import pytest
from pytest_embedded import Dut
@pytest.mark.target('esp32')
@pytest.mark.target('esp32c3')
@pytest.mark.target('esp32s3')
@pytest.mark.target('esp32p4')
@pytest.mark.env('generic')
@pytest.mark.parametrize(
'config',
[
'defaults',
],
)
def test_anim_player(dut: Dut)-> None:
dut.run_all_single_board_cases()

View File

@@ -0,0 +1,12 @@
# This file was generated using idf.py save-defconfig. It can be edited manually.
# Espressif IoT Development Framework (ESP-IDF) 5.4.0 Project Minimal Configuration
#
CONFIG_IDF_TARGET="esp32s3"
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_SPIRAM=y
CONFIG_SPIRAM_MODE_OCT=y
CONFIG_SPIRAM_SPEED_80M=y
CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=y
CONFIG_ESP_TASK_WDT_EN=n
CONFIG_MMAP_FILE_NAME_LENGTH=32