Upgrade Playlist Features
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,78 +1,74 @@
|
||||
# EchoEar 喵伴
|
||||
|
||||
## 简介
|
||||
|
||||
<div align="center">
|
||||
<a href="https://oshwhub.com/esp-college/echoear"><b> 立创开源平台 </b></a>
|
||||
</div>
|
||||
|
||||
EchoEar 喵伴是一款智能 AI 开发套件,搭载 ESP32-S3-WROOM-1 模组,1.85 寸 QSPI 圆形触摸屏,双麦阵列,支持离线语音唤醒与声源定位算法。硬件详情等可查看[立创开源项目](https://oshwhub.com/esp-college/echoear)。
|
||||
|
||||
## 配置、编译命令
|
||||
|
||||
**配置编译目标为 ESP32S3**
|
||||
|
||||
```bash
|
||||
idf.py set-target esp32s3
|
||||
```
|
||||
|
||||
**打开 menuconfig 并配置**
|
||||
|
||||
```bash
|
||||
idf.py menuconfig
|
||||
```
|
||||
|
||||
分别配置如下选项:
|
||||
|
||||
### 基本配置
|
||||
- `Xiaozhi Assistant` → `Board Type` → 选择 `EchoEar`
|
||||
|
||||
### 分区表配置
|
||||
- `Partition Table` → `Partition Table` → 选择 `Custom partition table CSV`
|
||||
- `Partition Table` → `Custom partition CSV file` → 输入 `partitions/v1/16m_echoear.csv`
|
||||
|
||||
### UI风格选择
|
||||
|
||||
EchoEar 支持两种不同的UI显示风格,通过修改代码中的宏定义来选择:
|
||||
|
||||
#### 自定义表情显示系统 (推荐)
|
||||
```c
|
||||
#define USE_LVGL_DEFAULT 0
|
||||
```
|
||||
- **特点**: 使用自定义的 `EmoteDisplay` 表情显示系统
|
||||
- **功能**: 支持丰富的表情动画、眼睛动画、状态图标显示
|
||||
- **适用**: 智能助手场景,提供更生动的人机交互体验
|
||||
- **类**: `anim::EmoteDisplay` + `anim::EmoteEngine`
|
||||
|
||||
#### LVGL默认显示系统
|
||||
```c
|
||||
#define USE_LVGL_DEFAULT 1
|
||||
```
|
||||
- **特点**: 使用标准LVGL图形库的显示系统
|
||||
- **功能**: 传统的文本和图标显示界面
|
||||
- **适用**: 需要标准GUI控件的应用场景
|
||||
- **类**: `SpiLcdDisplay`
|
||||
|
||||
#### 如何修改
|
||||
1. 打开 `main/boards/echoear/EchoEar.cc` 文件
|
||||
2. 找到第29行的宏定义:`#define USE_LVGL_DEFAULT 0`
|
||||
3. 修改为想要的值(0或1)
|
||||
4. 重新编译项目
|
||||
|
||||
> **说明**: EchoEar 使用16MB Flash,需要使用专门的分区表配置来合理分配存储空间给应用程序、OTA更新、资源文件等。
|
||||
|
||||
按 `S` 保存,按 `Q` 退出。
|
||||
|
||||
**编译**
|
||||
|
||||
```bash
|
||||
idf.py build
|
||||
```
|
||||
|
||||
**烧录**
|
||||
|
||||
将 EchoEar 连接至电脑,**注意打开电源**,并运行:
|
||||
|
||||
```bash
|
||||
idf.py flash
|
||||
# EchoEar 喵伴
|
||||
|
||||
## 简介
|
||||
|
||||
<div align="center">
|
||||
<a href="https://oshwhub.com/esp-college/echoear"><b> 立创开源平台 </b></a>
|
||||
</div>
|
||||
|
||||
EchoEar 喵伴是一款智能 AI 开发套件,搭载 ESP32-S3-WROOM-1 模组,1.85 寸 QSPI 圆形触摸屏,双麦阵列,支持离线语音唤醒与声源定位算法。硬件详情等可查看[立创开源项目](https://oshwhub.com/esp-college/echoear)。
|
||||
|
||||
## 配置、编译命令
|
||||
|
||||
**配置编译目标为 ESP32S3**
|
||||
|
||||
```bash
|
||||
idf.py set-target esp32s3
|
||||
```
|
||||
|
||||
**打开 menuconfig 并配置**
|
||||
|
||||
```bash
|
||||
idf.py menuconfig
|
||||
```
|
||||
|
||||
分别配置如下选项:
|
||||
|
||||
### 基本配置
|
||||
- `Xiaozhi Assistant` → `Board Type` → 选择 `EchoEar`
|
||||
|
||||
### UI风格选择
|
||||
|
||||
EchoEar 支持两种不同的UI显示风格,通过修改代码中的宏定义来选择:
|
||||
|
||||
#### 自定义表情显示系统 (推荐)
|
||||
```c
|
||||
#define USE_LVGL_DEFAULT 0
|
||||
```
|
||||
- **特点**: 使用自定义的 `EmoteDisplay` 表情显示系统
|
||||
- **功能**: 支持丰富的表情动画、眼睛动画、状态图标显示
|
||||
- **适用**: 智能助手场景,提供更生动的人机交互体验
|
||||
- **类**: `anim::EmoteDisplay` + `anim::EmoteEngine`
|
||||
|
||||
#### LVGL默认显示系统
|
||||
```c
|
||||
#define USE_LVGL_DEFAULT 1
|
||||
```
|
||||
- **特点**: 使用标准LVGL图形库的显示系统
|
||||
- **功能**: 传统的文本和图标显示界面
|
||||
- **适用**: 需要标准GUI控件的应用场景
|
||||
- **类**: `SpiLcdDisplay`
|
||||
|
||||
#### 如何修改
|
||||
1. 打开 `main/boards/echoear/EchoEar.cc` 文件
|
||||
2. 找到第29行的宏定义:`#define USE_LVGL_DEFAULT 0`
|
||||
3. 修改为想要的值(0或1)
|
||||
4. 重新编译项目
|
||||
|
||||
> **说明**: EchoEar 使用16MB Flash,需要使用专门的分区表配置来合理分配存储空间给应用程序、OTA更新、资源文件等。
|
||||
|
||||
按 `S` 保存,按 `Q` 退出。
|
||||
|
||||
**编译**
|
||||
|
||||
```bash
|
||||
idf.py build
|
||||
```
|
||||
|
||||
**烧录**
|
||||
|
||||
将 EchoEar 连接至电脑,**注意打开电源**,并运行:
|
||||
|
||||
```bash
|
||||
idf.py flash
|
||||
```
|
||||
@@ -1,88 +1,88 @@
|
||||
#ifndef _BOARD_CONFIG_H_
|
||||
#define _BOARD_CONFIG_H_
|
||||
|
||||
#include <driver/gpio.h>
|
||||
#include <driver/uart.h>
|
||||
#include <driver/spi_master.h>
|
||||
|
||||
#define AUDIO_INPUT_SAMPLE_RATE 24000
|
||||
#define AUDIO_OUTPUT_SAMPLE_RATE 24000
|
||||
#define AUDIO_INPUT_REFERENCE true
|
||||
|
||||
#define CORDEC_POWER_CTRL GPIO_NUM_48
|
||||
|
||||
#define POWER_CTRL GPIO_NUM_9
|
||||
#define LED_G GPIO_NUM_43
|
||||
#define SD_MISO GPIO_NUM_17
|
||||
#define SD_SCK GPIO_NUM_16
|
||||
#define SD_MOSI GPIO_NUM_38
|
||||
|
||||
#define AUDIO_I2S_GPIO_MCLK GPIO_NUM_42
|
||||
#define AUDIO_I2S_GPIO_WS GPIO_NUM_39
|
||||
#define AUDIO_I2S_GPIO_BCLK GPIO_NUM_40
|
||||
#define AUDIO_I2S_GPIO_DIN_1 GPIO_NUM_15
|
||||
#define AUDIO_I2S_GPIO_DIN_2 GPIO_NUM_3
|
||||
#define AUDIO_I2S_GPIO_DOUT GPIO_NUM_41
|
||||
|
||||
#define AUDIO_CODEC_PA_PIN_1 GPIO_NUM_4
|
||||
#define AUDIO_CODEC_PA_PIN_2 GPIO_NUM_15
|
||||
#define AUDIO_CODEC_I2C_SDA_PIN GPIO_NUM_2
|
||||
#define AUDIO_CODEC_I2C_SCL_PIN GPIO_NUM_1
|
||||
#define AUDIO_CODEC_ES8311_ADDR ES8311_CODEC_DEFAULT_ADDR
|
||||
#define AUDIO_CODEC_ES7210_ADDR ES7210_CODEC_DEFAULT_ADDR
|
||||
|
||||
#define BUILTIN_LED_GPIO GPIO_NUM_NC
|
||||
#define BOOT_BUTTON_GPIO GPIO_NUM_0
|
||||
#define VOLUME_UP_BUTTON_GPIO GPIO_NUM_NC
|
||||
#define VOLUME_DOWN_BUTTON_GPIO GPIO_NUM_NC
|
||||
|
||||
#define DISPLAY_WIDTH 360
|
||||
#define DISPLAY_HEIGHT 360
|
||||
#define DISPLAY_MIRROR_X false
|
||||
#define DISPLAY_MIRROR_Y false
|
||||
#define DISPLAY_SWAP_XY false
|
||||
|
||||
#define QSPI_LCD_H_RES (360)
|
||||
#define QSPI_LCD_V_RES (360)
|
||||
#define QSPI_LCD_BIT_PER_PIXEL (16)
|
||||
|
||||
#define QSPI_LCD_HOST SPI2_HOST
|
||||
#define QSPI_PIN_NUM_LCD_PCLK GPIO_NUM_18
|
||||
#define QSPI_PIN_NUM_LCD_CS GPIO_NUM_14
|
||||
#define QSPI_PIN_NUM_LCD_DATA0 GPIO_NUM_46
|
||||
#define QSPI_PIN_NUM_LCD_DATA1 GPIO_NUM_13
|
||||
#define QSPI_PIN_NUM_LCD_DATA2 GPIO_NUM_11
|
||||
#define QSPI_PIN_NUM_LCD_DATA3 GPIO_NUM_12
|
||||
#define QSPI_PIN_NUM_LCD_RST_1 GPIO_NUM_3
|
||||
#define QSPI_PIN_NUM_LCD_RST_2 GPIO_NUM_47
|
||||
#define QSPI_PIN_NUM_LCD_BL GPIO_NUM_44
|
||||
|
||||
#define UART1_TX_1 GPIO_NUM_6
|
||||
#define UART1_TX_2 GPIO_NUM_5
|
||||
#define UART1_RX_1 GPIO_NUM_5
|
||||
#define UART1_RX_2 GPIO_NUM_4
|
||||
#define TOUCH_PAD2_1 GPIO_NUM_NC
|
||||
#define TOUCH_PAD2_2 GPIO_NUM_6
|
||||
#define TOUCH_PAD1 GPIO_NUM_7
|
||||
|
||||
#define DISPLAY_OFFSET_X 0
|
||||
#define DISPLAY_OFFSET_Y 0
|
||||
|
||||
#define TP_PORT (I2C_NUM_1)
|
||||
#define TP_PIN_NUM_RST (GPIO_NUM_NC)
|
||||
#define TP_PIN_NUM_INT (GPIO_NUM_10)
|
||||
|
||||
#define DISPLAY_BACKLIGHT_PIN QSPI_PIN_NUM_LCD_BL
|
||||
#define DISPLAY_BACKLIGHT_OUTPUT_INVERT false
|
||||
|
||||
#define TAIJIPI_ST77916_PANEL_BUS_QSPI_CONFIG(sclk, d0, d1, d2, d3, max_trans_sz) \
|
||||
{ \
|
||||
.data0_io_num = d0, \
|
||||
.data1_io_num = d1, \
|
||||
.sclk_io_num = sclk, \
|
||||
.data2_io_num = d2, \
|
||||
.data3_io_num = d3, \
|
||||
.max_transfer_sz = max_trans_sz, \
|
||||
}
|
||||
|
||||
#endif // _BOARD_CONFIG_H_
|
||||
#ifndef _BOARD_CONFIG_H_
|
||||
#define _BOARD_CONFIG_H_
|
||||
|
||||
#include <driver/gpio.h>
|
||||
#include <driver/uart.h>
|
||||
#include <driver/spi_master.h>
|
||||
|
||||
#define AUDIO_INPUT_SAMPLE_RATE 24000
|
||||
#define AUDIO_OUTPUT_SAMPLE_RATE 24000
|
||||
#define AUDIO_INPUT_REFERENCE true
|
||||
|
||||
#define CORDEC_POWER_CTRL GPIO_NUM_48
|
||||
|
||||
#define POWER_CTRL GPIO_NUM_9
|
||||
#define LED_G GPIO_NUM_43
|
||||
#define SD_MISO GPIO_NUM_17
|
||||
#define SD_SCK GPIO_NUM_16
|
||||
#define SD_MOSI GPIO_NUM_38
|
||||
|
||||
#define AUDIO_I2S_GPIO_MCLK GPIO_NUM_42
|
||||
#define AUDIO_I2S_GPIO_WS GPIO_NUM_39
|
||||
#define AUDIO_I2S_GPIO_BCLK GPIO_NUM_40
|
||||
#define AUDIO_I2S_GPIO_DIN_1 GPIO_NUM_15
|
||||
#define AUDIO_I2S_GPIO_DIN_2 GPIO_NUM_3
|
||||
#define AUDIO_I2S_GPIO_DOUT GPIO_NUM_41
|
||||
|
||||
#define AUDIO_CODEC_PA_PIN_1 GPIO_NUM_4
|
||||
#define AUDIO_CODEC_PA_PIN_2 GPIO_NUM_15
|
||||
#define AUDIO_CODEC_I2C_SDA_PIN GPIO_NUM_2
|
||||
#define AUDIO_CODEC_I2C_SCL_PIN GPIO_NUM_1
|
||||
#define AUDIO_CODEC_ES8311_ADDR ES8311_CODEC_DEFAULT_ADDR
|
||||
#define AUDIO_CODEC_ES7210_ADDR ES7210_CODEC_DEFAULT_ADDR
|
||||
|
||||
#define BUILTIN_LED_GPIO GPIO_NUM_NC
|
||||
#define BOOT_BUTTON_GPIO GPIO_NUM_0
|
||||
#define VOLUME_UP_BUTTON_GPIO GPIO_NUM_NC
|
||||
#define VOLUME_DOWN_BUTTON_GPIO GPIO_NUM_NC
|
||||
|
||||
#define DISPLAY_WIDTH 360
|
||||
#define DISPLAY_HEIGHT 360
|
||||
#define DISPLAY_MIRROR_X false
|
||||
#define DISPLAY_MIRROR_Y false
|
||||
#define DISPLAY_SWAP_XY false
|
||||
|
||||
#define QSPI_LCD_H_RES (360)
|
||||
#define QSPI_LCD_V_RES (360)
|
||||
#define QSPI_LCD_BIT_PER_PIXEL (16)
|
||||
|
||||
#define QSPI_LCD_HOST SPI2_HOST
|
||||
#define QSPI_PIN_NUM_LCD_PCLK GPIO_NUM_18
|
||||
#define QSPI_PIN_NUM_LCD_CS GPIO_NUM_14
|
||||
#define QSPI_PIN_NUM_LCD_DATA0 GPIO_NUM_46
|
||||
#define QSPI_PIN_NUM_LCD_DATA1 GPIO_NUM_13
|
||||
#define QSPI_PIN_NUM_LCD_DATA2 GPIO_NUM_11
|
||||
#define QSPI_PIN_NUM_LCD_DATA3 GPIO_NUM_12
|
||||
#define QSPI_PIN_NUM_LCD_RST_1 GPIO_NUM_3
|
||||
#define QSPI_PIN_NUM_LCD_RST_2 GPIO_NUM_47
|
||||
#define QSPI_PIN_NUM_LCD_BL GPIO_NUM_44
|
||||
|
||||
#define UART1_TX_1 GPIO_NUM_6
|
||||
#define UART1_TX_2 GPIO_NUM_5
|
||||
#define UART1_RX_1 GPIO_NUM_5
|
||||
#define UART1_RX_2 GPIO_NUM_4
|
||||
#define TOUCH_PAD2_1 GPIO_NUM_NC
|
||||
#define TOUCH_PAD2_2 GPIO_NUM_6
|
||||
#define TOUCH_PAD1 GPIO_NUM_7
|
||||
|
||||
#define DISPLAY_OFFSET_X 0
|
||||
#define DISPLAY_OFFSET_Y 0
|
||||
|
||||
#define TP_PORT (I2C_NUM_1)
|
||||
#define TP_PIN_NUM_RST (GPIO_NUM_NC)
|
||||
#define TP_PIN_NUM_INT (GPIO_NUM_10)
|
||||
|
||||
#define DISPLAY_BACKLIGHT_PIN QSPI_PIN_NUM_LCD_BL
|
||||
#define DISPLAY_BACKLIGHT_OUTPUT_INVERT false
|
||||
|
||||
#define TAIJIPI_ST77916_PANEL_BUS_QSPI_CONFIG(sclk, d0, d1, d2, d3, max_trans_sz) \
|
||||
{ \
|
||||
.data0_io_num = d0, \
|
||||
.data1_io_num = d1, \
|
||||
.sclk_io_num = sclk, \
|
||||
.data2_io_num = d2, \
|
||||
.data3_io_num = d3, \
|
||||
.max_transfer_sz = max_trans_sz, \
|
||||
}
|
||||
|
||||
#endif // _BOARD_CONFIG_H_
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
{
|
||||
"target": "esp32s3",
|
||||
"builds": [
|
||||
{
|
||||
"name": "echoear",
|
||||
"sdkconfig_append": [
|
||||
"CONFIG_PARTITION_TABLE_CUSTOM_FILENAME=\"partitions/v1/16m_echoear.csv\""
|
||||
]
|
||||
}
|
||||
]
|
||||
{
|
||||
"target": "esp32s3",
|
||||
"builds": [
|
||||
{
|
||||
"name": "echoear",
|
||||
"sdkconfig_append": [
|
||||
"CONFIG_PARTITION_TABLE_CUSTOM_FILENAME=\"partitions/v2/16m.csv\"",
|
||||
"CONFIG_USE_EMOTE_MESSAGE_STYLE=y",
|
||||
"CONFIG_BOARD_TYPE_ECHOEAR=y",
|
||||
"CONFIG_FLASH_CUSTOM_ASSETS=y",
|
||||
"CONFIG_CUSTOM_ASSETS_FILE=\"https://dl.espressif.com/AE/wn9_nihaoxiaozhi_tts-font_puhui_common_20_4-echoear.bin\""
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
22
main/boards/echoear/emote.json
Normal file
22
main/boards/echoear/emote.json
Normal file
@@ -0,0 +1,22 @@
|
||||
[
|
||||
{"emote": "happy", "src": "Happy.eaf", "loop": true, "fps": 20},
|
||||
{"emote": "laughing", "src": "Happy.eaf", "loop": true, "fps": 20},
|
||||
{"emote": "funny", "src": "Happy.eaf", "loop": true, "fps": 20},
|
||||
{"emote": "loving", "src": "Happy.eaf", "loop": true, "fps": 20},
|
||||
{"emote": "embarrassed", "src": "Happy.eaf", "loop": true, "fps": 20},
|
||||
{"emote": "confident", "src": "Happy.eaf", "loop": true, "fps": 20},
|
||||
{"emote": "delicious", "src": "Happy.eaf", "loop": true, "fps": 20},
|
||||
{"emote": "sad", "src": "Sad.eaf", "loop": true, "fps": 20},
|
||||
{"emote": "crying", "src": "cry.eaf", "loop": true, "fps": 20},
|
||||
{"emote": "sleepy", "src": "sleep.eaf", "loop": true, "fps": 20},
|
||||
{"emote": "silly", "src": "Happy.eaf", "loop": true, "fps": 20},
|
||||
{"emote": "angry", "src": "angry.eaf", "loop": true, "fps": 20},
|
||||
{"emote": "surprised", "src": "Happy.eaf", "loop": true, "fps": 20},
|
||||
{"emote": "shocked", "src": "shocked.eaf", "loop": true, "fps": 20},
|
||||
{"emote": "thinking", "src": "confused.eaf", "loop": true, "fps": 20},
|
||||
{"emote": "winking", "src": "neutral.eaf", "loop": true, "fps": 20},
|
||||
{"emote": "relaxed", "src": "Happy.eaf", "loop": true, "fps": 20},
|
||||
{"emote": "confused", "src": "confused.eaf", "loop": true, "fps": 20},
|
||||
{"emote": "neutral", "src": "winking.eaf", "loop": false, "fps": 20},
|
||||
{"emote": "idle", "src": "neutral.eaf", "loop": false, "fps": 20}
|
||||
]
|
||||
@@ -1,419 +0,0 @@
|
||||
#include "emote_display.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <tuple>
|
||||
#include <esp_log.h>
|
||||
#include <esp_lcd_panel_io.h>
|
||||
#include <freertos/FreeRTOS.h>
|
||||
#include <freertos/task.h>
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "display/lcd_display.h"
|
||||
#include "mmap_generate_emoji_normal.h"
|
||||
#include "config.h"
|
||||
#include "gfx.h"
|
||||
|
||||
namespace anim {
|
||||
|
||||
static const char* TAG = "emoji";
|
||||
|
||||
// UI element management
|
||||
static gfx_obj_t* obj_label_tips = nullptr;
|
||||
static gfx_obj_t* obj_label_time = nullptr;
|
||||
static gfx_obj_t* obj_anim_eye = nullptr;
|
||||
static gfx_obj_t* obj_anim_mic = nullptr;
|
||||
static gfx_obj_t* obj_img_icon = nullptr;
|
||||
static gfx_image_dsc_t icon_img_dsc;
|
||||
|
||||
// Track current icon to determine when to show time
|
||||
static int current_icon_type = MMAP_EMOJI_NORMAL_ICON_BATTERY_BIN;
|
||||
|
||||
enum class UIDisplayMode : uint8_t {
|
||||
SHOW_ANIM_TOP = 1, // Show obj_anim_mic
|
||||
SHOW_TIME = 2, // Show obj_label_time
|
||||
SHOW_TIPS = 3 // Show obj_label_tips
|
||||
};
|
||||
|
||||
static void SetUIDisplayMode(UIDisplayMode mode)
|
||||
{
|
||||
gfx_obj_set_visible(obj_anim_mic, false);
|
||||
gfx_obj_set_visible(obj_label_time, false);
|
||||
gfx_obj_set_visible(obj_label_tips, false);
|
||||
|
||||
// Show the selected control
|
||||
switch (mode) {
|
||||
case UIDisplayMode::SHOW_ANIM_TOP:
|
||||
gfx_obj_set_visible(obj_anim_mic, true);
|
||||
break;
|
||||
case UIDisplayMode::SHOW_TIME:
|
||||
gfx_obj_set_visible(obj_label_time, true);
|
||||
break;
|
||||
case UIDisplayMode::SHOW_TIPS:
|
||||
gfx_obj_set_visible(obj_label_tips, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void clock_tm_callback(void* user_data)
|
||||
{
|
||||
// Only display time when battery icon is shown
|
||||
if (current_icon_type == MMAP_EMOJI_NORMAL_ICON_BATTERY_BIN) {
|
||||
time_t now;
|
||||
struct tm timeinfo;
|
||||
time(&now);
|
||||
|
||||
setenv("TZ", "GMT+0", 1);
|
||||
tzset();
|
||||
localtime_r(&now, &timeinfo);
|
||||
|
||||
char time_str[6];
|
||||
snprintf(time_str, sizeof(time_str), "%02d:%02d", timeinfo.tm_hour, timeinfo.tm_min);
|
||||
|
||||
gfx_label_set_text(obj_label_time, time_str);
|
||||
SetUIDisplayMode(UIDisplayMode::SHOW_TIME);
|
||||
}
|
||||
}
|
||||
|
||||
static void InitializeAssets(mmap_assets_handle_t* assets_handle)
|
||||
{
|
||||
const mmap_assets_config_t assets_cfg = {
|
||||
.partition_label = "assets_A",
|
||||
.max_files = MMAP_EMOJI_NORMAL_FILES,
|
||||
.checksum = MMAP_EMOJI_NORMAL_CHECKSUM,
|
||||
.flags = {.mmap_enable = true, .full_check = true}
|
||||
};
|
||||
|
||||
mmap_assets_new(&assets_cfg, assets_handle);
|
||||
}
|
||||
|
||||
static void InitializeGraphics(esp_lcd_panel_handle_t panel, gfx_handle_t* engine_handle)
|
||||
{
|
||||
gfx_core_config_t gfx_cfg = {
|
||||
.flush_cb = EmoteEngine::OnFlush,
|
||||
.user_data = panel,
|
||||
.flags = {
|
||||
.swap = true,
|
||||
.double_buffer = true,
|
||||
.buff_dma = true,
|
||||
},
|
||||
.h_res = DISPLAY_WIDTH,
|
||||
.v_res = DISPLAY_HEIGHT,
|
||||
.fps = 30,
|
||||
.buffers = {
|
||||
.buf1 = nullptr,
|
||||
.buf2 = nullptr,
|
||||
.buf_pixels = DISPLAY_WIDTH * 16,
|
||||
},
|
||||
.task = GFX_EMOTE_INIT_CONFIG()
|
||||
};
|
||||
|
||||
gfx_cfg.task.task_stack_caps = MALLOC_CAP_DEFAULT;
|
||||
gfx_cfg.task.task_affinity = 0;
|
||||
gfx_cfg.task.task_priority = 5;
|
||||
gfx_cfg.task.task_stack = 20 * 1024;
|
||||
|
||||
*engine_handle = gfx_emote_init(&gfx_cfg);
|
||||
}
|
||||
|
||||
static void InitializeEyeAnimation(gfx_handle_t engine_handle, mmap_assets_handle_t assets_handle)
|
||||
{
|
||||
obj_anim_eye = gfx_anim_create(engine_handle);
|
||||
|
||||
const void* anim_data = mmap_assets_get_mem(assets_handle, MMAP_EMOJI_NORMAL_IDLE_ONE_AAF);
|
||||
size_t anim_size = mmap_assets_get_size(assets_handle, MMAP_EMOJI_NORMAL_IDLE_ONE_AAF);
|
||||
|
||||
gfx_anim_set_src(obj_anim_eye, anim_data, anim_size);
|
||||
|
||||
gfx_obj_align(obj_anim_eye, GFX_ALIGN_LEFT_MID, 10, -20);
|
||||
gfx_anim_set_mirror(obj_anim_eye, true, (DISPLAY_WIDTH - (173 + 10) * 2));
|
||||
gfx_anim_set_segment(obj_anim_eye, 0, 0xFFFF, 20, false);
|
||||
gfx_anim_start(obj_anim_eye);
|
||||
}
|
||||
|
||||
static void InitializeFont(gfx_handle_t engine_handle, mmap_assets_handle_t assets_handle)
|
||||
{
|
||||
gfx_font_t font;
|
||||
gfx_label_cfg_t font_cfg = {
|
||||
.name = "DejaVuSans.ttf",
|
||||
.mem = mmap_assets_get_mem(assets_handle, MMAP_EMOJI_NORMAL_KAITI_TTF),
|
||||
.mem_size = static_cast<size_t>(mmap_assets_get_size(assets_handle, MMAP_EMOJI_NORMAL_KAITI_TTF)),
|
||||
};
|
||||
gfx_label_new_font(engine_handle, &font_cfg, &font);
|
||||
|
||||
ESP_LOGI(TAG, "stack: %d", uxTaskGetStackHighWaterMark(nullptr));
|
||||
}
|
||||
|
||||
static void InitializeLabels(gfx_handle_t engine_handle)
|
||||
{
|
||||
// Initialize tips label
|
||||
obj_label_tips = gfx_label_create(engine_handle);
|
||||
gfx_obj_align(obj_label_tips, GFX_ALIGN_TOP_MID, 0, 45);
|
||||
gfx_obj_set_size(obj_label_tips, 160, 40);
|
||||
gfx_label_set_text(obj_label_tips, "启动中...");
|
||||
gfx_label_set_font_size(obj_label_tips, 20);
|
||||
gfx_label_set_color(obj_label_tips, GFX_COLOR_HEX(0xFFFFFF));
|
||||
gfx_label_set_text_align(obj_label_tips, GFX_TEXT_ALIGN_LEFT);
|
||||
gfx_label_set_long_mode(obj_label_tips, GFX_LABEL_LONG_SCROLL);
|
||||
gfx_label_set_scroll_speed(obj_label_tips, 20);
|
||||
gfx_label_set_scroll_loop(obj_label_tips, true);
|
||||
|
||||
// Initialize time label
|
||||
obj_label_time = gfx_label_create(engine_handle);
|
||||
gfx_obj_align(obj_label_time, GFX_ALIGN_TOP_MID, 0, 30);
|
||||
gfx_obj_set_size(obj_label_time, 160, 50);
|
||||
gfx_label_set_text(obj_label_time, "--:--");
|
||||
gfx_label_set_font_size(obj_label_time, 40);
|
||||
gfx_label_set_color(obj_label_time, GFX_COLOR_HEX(0xFFFFFF));
|
||||
gfx_label_set_text_align(obj_label_time, GFX_TEXT_ALIGN_CENTER);
|
||||
}
|
||||
|
||||
static void InitializeMicAnimation(gfx_handle_t engine_handle, mmap_assets_handle_t assets_handle)
|
||||
{
|
||||
obj_anim_mic = gfx_anim_create(engine_handle);
|
||||
gfx_obj_align(obj_anim_mic, GFX_ALIGN_TOP_MID, 0, 25);
|
||||
|
||||
const void* anim_data = mmap_assets_get_mem(assets_handle, MMAP_EMOJI_NORMAL_LISTEN_AAF);
|
||||
size_t anim_size = mmap_assets_get_size(assets_handle, MMAP_EMOJI_NORMAL_LISTEN_AAF);
|
||||
gfx_anim_set_src(obj_anim_mic, anim_data, anim_size);
|
||||
gfx_anim_start(obj_anim_mic);
|
||||
gfx_obj_set_visible(obj_anim_mic, false);
|
||||
}
|
||||
|
||||
static void InitializeIcon(gfx_handle_t engine_handle, mmap_assets_handle_t assets_handle)
|
||||
{
|
||||
obj_img_icon = gfx_img_create(engine_handle);
|
||||
gfx_obj_align(obj_img_icon, GFX_ALIGN_TOP_MID, -100, 38);
|
||||
|
||||
SetupImageDescriptor(assets_handle, &icon_img_dsc, MMAP_EMOJI_NORMAL_ICON_WIFI_FAILED_BIN);
|
||||
gfx_img_set_src(obj_img_icon, static_cast<void*>(&icon_img_dsc));
|
||||
}
|
||||
|
||||
static void RegisterCallbacks(esp_lcd_panel_io_handle_t panel_io, gfx_handle_t engine_handle)
|
||||
{
|
||||
const esp_lcd_panel_io_callbacks_t cbs = {
|
||||
.on_color_trans_done = EmoteEngine::OnFlushIoReady,
|
||||
};
|
||||
esp_lcd_panel_io_register_event_callbacks(panel_io, &cbs, engine_handle);
|
||||
}
|
||||
|
||||
void SetupImageDescriptor(mmap_assets_handle_t assets_handle,
|
||||
gfx_image_dsc_t* img_dsc,
|
||||
int asset_id)
|
||||
{
|
||||
const void* img_data = mmap_assets_get_mem(assets_handle, asset_id);
|
||||
size_t img_size = mmap_assets_get_size(assets_handle, asset_id);
|
||||
|
||||
std::memcpy(&img_dsc->header, img_data, sizeof(gfx_image_header_t));
|
||||
img_dsc->data = static_cast<const uint8_t*>(img_data) + sizeof(gfx_image_header_t);
|
||||
img_dsc->data_size = img_size - sizeof(gfx_image_header_t);
|
||||
}
|
||||
|
||||
EmoteEngine::EmoteEngine(esp_lcd_panel_handle_t panel, esp_lcd_panel_io_handle_t panel_io)
|
||||
{
|
||||
ESP_LOGI(TAG, "Create EmoteEngine, panel: %p, panel_io: %p", panel, panel_io);
|
||||
|
||||
InitializeAssets(&assets_handle_);
|
||||
InitializeGraphics(panel, &engine_handle_);
|
||||
|
||||
gfx_emote_lock(engine_handle_);
|
||||
gfx_emote_set_bg_color(engine_handle_, GFX_COLOR_HEX(0x000000));
|
||||
|
||||
// Initialize all UI components
|
||||
InitializeEyeAnimation(engine_handle_, assets_handle_);
|
||||
InitializeFont(engine_handle_, assets_handle_);
|
||||
InitializeLabels(engine_handle_);
|
||||
InitializeMicAnimation(engine_handle_, assets_handle_);
|
||||
InitializeIcon(engine_handle_, assets_handle_);
|
||||
|
||||
current_icon_type = MMAP_EMOJI_NORMAL_ICON_WIFI_FAILED_BIN;
|
||||
SetUIDisplayMode(UIDisplayMode::SHOW_TIPS);
|
||||
|
||||
gfx_timer_create(engine_handle_, clock_tm_callback, 1000, obj_label_tips);
|
||||
|
||||
gfx_emote_unlock(engine_handle_);
|
||||
|
||||
RegisterCallbacks(panel_io, engine_handle_);
|
||||
}
|
||||
|
||||
EmoteEngine::~EmoteEngine()
|
||||
{
|
||||
if (engine_handle_) {
|
||||
gfx_emote_deinit(engine_handle_);
|
||||
engine_handle_ = nullptr;
|
||||
}
|
||||
|
||||
if (assets_handle_) {
|
||||
mmap_assets_del(assets_handle_);
|
||||
assets_handle_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void EmoteEngine::setEyes(int aaf, bool repeat, int fps)
|
||||
{
|
||||
if (!engine_handle_) {
|
||||
return;
|
||||
}
|
||||
|
||||
const void* src_data = mmap_assets_get_mem(assets_handle_, aaf);
|
||||
size_t src_len = mmap_assets_get_size(assets_handle_, aaf);
|
||||
|
||||
Lock();
|
||||
gfx_anim_set_src(obj_anim_eye, src_data, src_len);
|
||||
gfx_anim_set_segment(obj_anim_eye, 0, 0xFFFF, fps, repeat);
|
||||
gfx_anim_start(obj_anim_eye);
|
||||
Unlock();
|
||||
}
|
||||
|
||||
void EmoteEngine::stopEyes()
|
||||
{
|
||||
// Implementation if needed
|
||||
}
|
||||
|
||||
void EmoteEngine::Lock()
|
||||
{
|
||||
if (engine_handle_) {
|
||||
gfx_emote_lock(engine_handle_);
|
||||
}
|
||||
}
|
||||
|
||||
void EmoteEngine::Unlock()
|
||||
{
|
||||
if (engine_handle_) {
|
||||
gfx_emote_unlock(engine_handle_);
|
||||
}
|
||||
}
|
||||
|
||||
void EmoteEngine::SetIcon(int asset_id)
|
||||
{
|
||||
if (!engine_handle_) {
|
||||
return;
|
||||
}
|
||||
|
||||
Lock();
|
||||
SetupImageDescriptor(assets_handle_, &icon_img_dsc, asset_id);
|
||||
gfx_img_set_src(obj_img_icon, static_cast<void*>(&icon_img_dsc));
|
||||
current_icon_type = asset_id;
|
||||
Unlock();
|
||||
}
|
||||
|
||||
bool EmoteEngine::OnFlushIoReady(esp_lcd_panel_io_handle_t panel_io,
|
||||
esp_lcd_panel_io_event_data_t* edata,
|
||||
void* user_ctx)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void EmoteEngine::OnFlush(gfx_handle_t handle, int x_start, int y_start,
|
||||
int x_end, int y_end, const void* color_data)
|
||||
{
|
||||
auto* panel = static_cast<esp_lcd_panel_handle_t>(gfx_emote_get_user_data(handle));
|
||||
if (panel) {
|
||||
esp_lcd_panel_draw_bitmap(panel, x_start, y_start, x_end, y_end, color_data);
|
||||
}
|
||||
gfx_emote_flush_ready(handle, true);
|
||||
}
|
||||
|
||||
// EmoteDisplay implementation
|
||||
EmoteDisplay::EmoteDisplay(esp_lcd_panel_handle_t panel, esp_lcd_panel_io_handle_t panel_io)
|
||||
{
|
||||
InitializeEngine(panel, panel_io);
|
||||
}
|
||||
|
||||
EmoteDisplay::~EmoteDisplay() = default;
|
||||
|
||||
void EmoteDisplay::SetEmotion(const char* emotion)
|
||||
{
|
||||
if (!engine_) {
|
||||
return;
|
||||
}
|
||||
|
||||
using EmotionParam = std::tuple<int, bool, int>;
|
||||
static const std::unordered_map<std::string, EmotionParam> emotion_map = {
|
||||
{"happy", {MMAP_EMOJI_NORMAL_HAPPY_ONE_AAF, true, 20}},
|
||||
{"laughing", {MMAP_EMOJI_NORMAL_ENJOY_ONE_AAF, true, 20}},
|
||||
{"funny", {MMAP_EMOJI_NORMAL_HAPPY_ONE_AAF, true, 20}},
|
||||
{"loving", {MMAP_EMOJI_NORMAL_HAPPY_ONE_AAF, true, 20}},
|
||||
{"embarrassed", {MMAP_EMOJI_NORMAL_HAPPY_ONE_AAF, true, 20}},
|
||||
{"confident", {MMAP_EMOJI_NORMAL_HAPPY_ONE_AAF, true, 20}},
|
||||
{"delicious", {MMAP_EMOJI_NORMAL_HAPPY_ONE_AAF, true, 20}},
|
||||
{"sad", {MMAP_EMOJI_NORMAL_SAD_ONE_AAF, true, 20}},
|
||||
{"crying", {MMAP_EMOJI_NORMAL_HAPPY_ONE_AAF, true, 20}},
|
||||
{"sleepy", {MMAP_EMOJI_NORMAL_HAPPY_ONE_AAF, true, 20}},
|
||||
{"silly", {MMAP_EMOJI_NORMAL_HAPPY_ONE_AAF, true, 20}},
|
||||
{"angry", {MMAP_EMOJI_NORMAL_ANGRY_ONE_AAF, true, 20}},
|
||||
{"surprised", {MMAP_EMOJI_NORMAL_HAPPY_ONE_AAF, true, 20}},
|
||||
{"shocked", {MMAP_EMOJI_NORMAL_SHOCKED_ONE_AAF, true, 20}},
|
||||
{"thinking", {MMAP_EMOJI_NORMAL_THINKING_ONE_AAF, true, 20}},
|
||||
{"winking", {MMAP_EMOJI_NORMAL_HAPPY_ONE_AAF, true, 20}},
|
||||
{"relaxed", {MMAP_EMOJI_NORMAL_HAPPY_ONE_AAF, true, 20}},
|
||||
{"confused", {MMAP_EMOJI_NORMAL_DIZZY_ONE_AAF, true, 20}},
|
||||
{"neutral", {MMAP_EMOJI_NORMAL_IDLE_ONE_AAF, false, 20}},
|
||||
{"idle", {MMAP_EMOJI_NORMAL_IDLE_ONE_AAF, false, 20}},
|
||||
};
|
||||
|
||||
auto it = emotion_map.find(emotion);
|
||||
if (it != emotion_map.end()) {
|
||||
int aaf = std::get<0>(it->second);
|
||||
bool repeat = std::get<1>(it->second);
|
||||
int fps = std::get<2>(it->second);
|
||||
engine_->setEyes(aaf, repeat, fps);
|
||||
}
|
||||
}
|
||||
|
||||
void EmoteDisplay::SetChatMessage(const char* role, const char* content)
|
||||
{
|
||||
engine_->Lock();
|
||||
if (content && strlen(content) > 0) {
|
||||
gfx_label_set_text(obj_label_tips, content);
|
||||
SetUIDisplayMode(UIDisplayMode::SHOW_TIPS);
|
||||
}
|
||||
engine_->Unlock();
|
||||
}
|
||||
|
||||
void EmoteDisplay::SetStatus(const char* status)
|
||||
{
|
||||
if (!engine_) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (std::strcmp(status, "聆听中...") == 0) {
|
||||
SetUIDisplayMode(UIDisplayMode::SHOW_ANIM_TOP);
|
||||
engine_->setEyes(MMAP_EMOJI_NORMAL_HAPPY_ONE_AAF, true, 20);
|
||||
engine_->SetIcon(MMAP_EMOJI_NORMAL_ICON_MIC_BIN);
|
||||
} else if (std::strcmp(status, "待命") == 0) {
|
||||
SetUIDisplayMode(UIDisplayMode::SHOW_TIME);
|
||||
engine_->SetIcon(MMAP_EMOJI_NORMAL_ICON_BATTERY_BIN);
|
||||
} else if (std::strcmp(status, "说话中...") == 0) {
|
||||
SetUIDisplayMode(UIDisplayMode::SHOW_TIPS);
|
||||
engine_->SetIcon(MMAP_EMOJI_NORMAL_ICON_SPEAKER_ZZZ_BIN);
|
||||
} else if (std::strcmp(status, "错误") == 0) {
|
||||
SetUIDisplayMode(UIDisplayMode::SHOW_TIPS);
|
||||
engine_->SetIcon(MMAP_EMOJI_NORMAL_ICON_WIFI_FAILED_BIN);
|
||||
}
|
||||
|
||||
engine_->Lock();
|
||||
if (std::strcmp(status, "连接中...") != 0) {
|
||||
gfx_label_set_text(obj_label_tips, status);
|
||||
}
|
||||
engine_->Unlock();
|
||||
}
|
||||
|
||||
void EmoteDisplay::InitializeEngine(esp_lcd_panel_handle_t panel, esp_lcd_panel_io_handle_t panel_io)
|
||||
{
|
||||
engine_ = std::make_unique<EmoteEngine>(panel, panel_io);
|
||||
}
|
||||
|
||||
bool EmoteDisplay::Lock(int timeout_ms)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void EmoteDisplay::Unlock()
|
||||
{
|
||||
// Implementation if needed
|
||||
}
|
||||
|
||||
} // namespace anim
|
||||
@@ -1,66 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "display/lcd_display.h"
|
||||
#include <memory>
|
||||
#include <functional>
|
||||
#include <esp_lcd_panel_io.h>
|
||||
#include <esp_lcd_panel_ops.h>
|
||||
#include "mmap_generate_emoji_normal.h"
|
||||
#include "gfx.h"
|
||||
|
||||
namespace anim {
|
||||
|
||||
// Helper function for setting up image descriptors
|
||||
void SetupImageDescriptor(mmap_assets_handle_t assets_handle, gfx_image_dsc_t* img_dsc, int asset_id);
|
||||
|
||||
class EmoteEngine;
|
||||
|
||||
using FlushIoReadyCallback = std::function<bool(esp_lcd_panel_io_handle_t, esp_lcd_panel_io_event_data_t*, void*)>;
|
||||
using FlushCallback = std::function<void(gfx_handle_t, int, int, int, int, const void*)>;
|
||||
|
||||
class EmoteEngine {
|
||||
public:
|
||||
EmoteEngine(esp_lcd_panel_handle_t panel, esp_lcd_panel_io_handle_t panel_io);
|
||||
~EmoteEngine();
|
||||
|
||||
void setEyes(int aaf, bool repeat, int fps);
|
||||
void stopEyes();
|
||||
|
||||
void Lock();
|
||||
void Unlock();
|
||||
|
||||
void SetIcon(int asset_id);
|
||||
mmap_assets_handle_t GetAssetsHandle() const { return assets_handle_; }
|
||||
|
||||
// Callback functions (public to be accessible from static helper functions)
|
||||
static bool OnFlushIoReady(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_io_event_data_t *edata, void *user_ctx);
|
||||
static void OnFlush(gfx_handle_t handle, int x_start, int y_start, int x_end, int y_end, const void *color_data);
|
||||
|
||||
private:
|
||||
gfx_handle_t engine_handle_;
|
||||
mmap_assets_handle_t assets_handle_;
|
||||
};
|
||||
|
||||
class EmoteDisplay : public Display {
|
||||
public:
|
||||
EmoteDisplay(esp_lcd_panel_handle_t panel, esp_lcd_panel_io_handle_t panel_io);
|
||||
virtual ~EmoteDisplay();
|
||||
|
||||
virtual void SetEmotion(const char* emotion) override;
|
||||
virtual void SetStatus(const char* status) override;
|
||||
virtual void SetChatMessage(const char* role, const char* content) override;
|
||||
|
||||
anim::EmoteEngine* GetEngine()
|
||||
{
|
||||
return engine_.get();
|
||||
}
|
||||
|
||||
private:
|
||||
void InitializeEngine(esp_lcd_panel_handle_t panel, esp_lcd_panel_io_handle_t panel_io);
|
||||
virtual bool Lock(int timeout_ms = 0) override;
|
||||
virtual void Unlock() override;
|
||||
|
||||
std::unique_ptr<anim::EmoteEngine> engine_;
|
||||
};
|
||||
|
||||
} // namespace anim
|
||||
37
main/boards/echoear/layout.json
Normal file
37
main/boards/echoear/layout.json
Normal file
@@ -0,0 +1,37 @@
|
||||
[
|
||||
{
|
||||
"name": "eye_anim",
|
||||
"align": "GFX_ALIGN_LEFT_MID",
|
||||
"x": 10,
|
||||
"y": 10
|
||||
},
|
||||
{
|
||||
"name": "status_icon",
|
||||
"align": "GFX_ALIGN_TOP_MID",
|
||||
"x": -100,
|
||||
"y": 38
|
||||
},
|
||||
{
|
||||
"name": "toast_label",
|
||||
"align": "GFX_ALIGN_TOP_MID",
|
||||
"x": 0,
|
||||
"y": 40,
|
||||
"width": 160,
|
||||
"height": 40
|
||||
},
|
||||
{
|
||||
"name": "clock_label",
|
||||
"align": "GFX_ALIGN_TOP_MID",
|
||||
"x": 0,
|
||||
"y": 40,
|
||||
"width": 60,
|
||||
"height": 50
|
||||
},
|
||||
{
|
||||
"name": "listen_anim",
|
||||
"align": "GFX_ALIGN_TOP_MID",
|
||||
"x": 0,
|
||||
"y": 25
|
||||
}
|
||||
]
|
||||
|
||||
@@ -1,51 +1,51 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief BSP Touchscreen
|
||||
*
|
||||
* This file offers API for basic touchscreen initialization.
|
||||
* It is useful for users who want to use the touchscreen without the default Graphical Library LVGL.
|
||||
*
|
||||
* For standard LCD initialization with LVGL graphical library, you can call all-in-one function bsp_display_start().
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "esp_lcd_touch.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief BSP touch configuration structure
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
void *dummy; /*!< Prepared for future use. */
|
||||
} bsp_touch_config_t;
|
||||
|
||||
/**
|
||||
* @brief Create new touchscreen
|
||||
*
|
||||
* If you want to free resources allocated by this function, you can use esp_lcd_touch API, ie.:
|
||||
*
|
||||
* \code{.c}
|
||||
* esp_lcd_touch_del(tp);
|
||||
* \endcode
|
||||
*
|
||||
* @param[in] config touch configuration
|
||||
* @param[out] ret_touch esp_lcd_touch touchscreen handle
|
||||
* @return
|
||||
* - ESP_OK On success
|
||||
* - Else esp_lcd_touch failure
|
||||
*/
|
||||
esp_err_t bsp_touch_new(const bsp_touch_config_t *config, esp_lcd_touch_handle_t *ret_touch);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief BSP Touchscreen
|
||||
*
|
||||
* This file offers API for basic touchscreen initialization.
|
||||
* It is useful for users who want to use the touchscreen without the default Graphical Library LVGL.
|
||||
*
|
||||
* For standard LCD initialization with LVGL graphical library, you can call all-in-one function bsp_display_start().
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "esp_lcd_touch.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief BSP touch configuration structure
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
void *dummy; /*!< Prepared for future use. */
|
||||
} bsp_touch_config_t;
|
||||
|
||||
/**
|
||||
* @brief Create new touchscreen
|
||||
*
|
||||
* If you want to free resources allocated by this function, you can use esp_lcd_touch API, ie.:
|
||||
*
|
||||
* \code{.c}
|
||||
* esp_lcd_touch_del(tp);
|
||||
* \endcode
|
||||
*
|
||||
* @param[in] config touch configuration
|
||||
* @param[out] ret_touch esp_lcd_touch touchscreen handle
|
||||
* @return
|
||||
* - ESP_OK On success
|
||||
* - Else esp_lcd_touch failure
|
||||
*/
|
||||
esp_err_t bsp_touch_new(const bsp_touch_config_t *config, esp_lcd_touch_handle_t *ret_touch);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user