Skip to content

Commit 6a28a98

Browse files
Added Waveshare ESP32-P4-WIFI6-Touch-LCD-7B third party board (#1243)
* Modify the MIPILCDDISPLAY class * Added Waveshare ESP32-P4-WIFI6-Touch-LCD-7B third party board * Add config,json for Waveshare ESP32-P4 series boards * Fix some errors
1 parent 549399b commit 6a28a98

File tree

11 files changed

+335
-8
lines changed

11 files changed

+335
-8
lines changed

main/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,11 @@ elseif(CONFIG_BOARD_TYPE_ESP32P4_WIFI6_Touch_LCD_4B)
289289
set(BUILTIN_TEXT_FONT font_puhui_basic_30_4)
290290
set(BUILTIN_ICON_FONT font_awesome_30_4)
291291
set(DEFAULT_EMOJI_COLLECTION twemoji_64)
292+
elseif(CONFIG_BOARD_TYPE_ESP32P4_WIFI6_Touch_LCD_7B)
293+
set(BOARD_TYPE "waveshare-p4-wifi6-touch-lcd-7b")
294+
set(BUILTIN_TEXT_FONT font_puhui_basic_30_4)
295+
set(BUILTIN_ICON_FONT font_awesome_30_4)
296+
set(DEFAULT_EMOJI_COLLECTION twemoji_64)
292297
elseif(CONFIG_BOARD_TYPE_ESP32P4_WIFI6_Touch_LCD_XC)
293298
set(BOARD_TYPE "waveshare-p4-wifi6-touch-lcd-xc")
294299
set(BUILTIN_TEXT_FONT font_puhui_basic_30_4)

main/Kconfig.projbuild

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,8 @@ choice BOARD_TYPE
249249
depends on IDF_TARGET_ESP32P4
250250
config BOARD_TYPE_ESP32P4_WIFI6_Touch_LCD_4B
251251
bool "Waveshare ESP32-P4-WIFI6-Touch-LCD-4B"
252+
config BOARD_TYPE_ESP32P4_WIFI6_Touch_LCD_7B
253+
bool "Waveshare ESP32-P4-WIFI6-Touch-LCD-7B"
252254
depends on IDF_TARGET_ESP32P4
253255
config BOARD_TYPE_ESP32P4_WIFI6_Touch_LCD_XC
254256
bool "Waveshare ESP32-P4-WIFI6-Touch-LCD-3.4C or ESP32-P4-WIFI6-Touch-LCD-4C"
@@ -290,7 +292,7 @@ choice BOARD_TYPE
290292
bool "正点原子DNESP32S3-BOX2-WIFI"
291293
depends on IDF_TARGET_ESP32S3
292294
config BOARD_TYPE_ATK_DNESP32S3_BOX2_4G
293-
bool "正点原子DNESP32S3-BOX2-4G"
295+
bool "正点原子DNESP32S3-BOX2-4G"
294296
depends on IDF_TARGET_ESP32S3
295297
config BOARD_TYPE_ATK_DNESP32S3M_WIFI
296298
bool "正点原子DNESP32S3M-WIFI"
@@ -556,7 +558,7 @@ config SEND_WAKE_WORD_DATA
556558
depends on USE_AFE_WAKE_WORD || USE_CUSTOM_WAKE_WORD
557559
help
558560
Send wake word data to the server as the first message of the conversation and wait for response
559-
561+
560562
config USE_AUDIO_PROCESSOR
561563
bool "Enable Audio Noise Reduction"
562564
default y
@@ -569,7 +571,7 @@ config USE_DEVICE_AEC
569571
default n
570572
depends on USE_AUDIO_PROCESSOR && (BOARD_TYPE_ESP_BOX_3 || BOARD_TYPE_ESP_BOX || BOARD_TYPE_ESP_BOX_LITE \
571573
|| BOARD_TYPE_LICHUANG_DEV || BOARD_TYPE_ESP32S3_KORVO2_V3 || BOARD_TYPE_ESP32S3_Touch_AMOLED_1_75 \
572-
|| BOARD_TYPE_ESP32S3_Touch_AMOLED_2_06 || BOARD_TYPE_ESP32S3_Touch_LCD_4B || BOARD_TYPE_ESP32P4_WIFI6_Touch_LCD_4B \
574+
|| BOARD_TYPE_ESP32S3_Touch_AMOLED_2_06 || BOARD_TYPE_ESP32S3_Touch_LCD_4B || BOARD_TYPE_ESP32P4_WIFI6_Touch_LCD_4B || BOARD_TYPE_ESP32P4_WIFI6_Touch_LCD_7B \
573575
|| BOARD_TYPE_ESP32P4_WIFI6_Touch_LCD_XC || BOARD_TYPE_ESP_S3_LCD_EV_Board_2 || BOARD_TYPE_YUNLIAO_S3 \
574576
|| BOARD_TYPE_ECHOEAR || BOARD_TYPE_ESP32S3_Touch_LCD_3_49)
575577
help
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"target": "esp32p4",
3+
"builds": [
4+
{
5+
"name": "waveshare-p4-nano-10.1-a",
6+
"sdkconfig_append": [
7+
"CONFIG_USE_WECHAT_MESSAGE_STYLE=y",
8+
"CONFIG_LCD_TYPE_800_1280_10_1_INCH_A=y"
9+
]
10+
}
11+
]
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"target": "esp32p4",
3+
"builds": [
4+
{
5+
"name": "waveshare-p4-wifi6-touch-lcd-4b",
6+
"sdkconfig_append": [
7+
"CONFIG_USE_WECHAT_MESSAGE_STYLE=n",
8+
"CONFIG_USE_DEVICE_AEC=y"
9+
]
10+
}
11+
]
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Waveshare ESP32-P4-WIFI6-Touch-LCD-7B
2+
3+
4+
[ESP32-P4-WIFI6-Touch-LCD-7B](https://www.waveshare.com/esp32-p4-wifi6-touch-lcd-7b.htm) is waveshare electronics designed an intelligent 86 box based on ESP32-P4 module equipped with a 1024*600 IPS capacitive touch screen
5+
6+
7+
## Configuration
8+
9+
Configuration in `menuconfig`.
10+
11+
Selection Board Type `Xiaozhi Assistant --> Board Type`
12+
- Waveshare ESP32-P4-WIFI6-Touch-LCD-7B
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#ifndef _BOARD_CONFIG_H_
2+
#define _BOARD_CONFIG_H_
3+
4+
#include <driver/gpio.h>
5+
6+
#define AUDIO_INPUT_SAMPLE_RATE 24000
7+
#define AUDIO_OUTPUT_SAMPLE_RATE 24000
8+
9+
#define AUDIO_INPUT_REFERENCE true
10+
11+
#define AUDIO_I2S_GPIO_MCLK GPIO_NUM_13
12+
#define AUDIO_I2S_GPIO_WS GPIO_NUM_10
13+
#define AUDIO_I2S_GPIO_BCLK GPIO_NUM_12
14+
#define AUDIO_I2S_GPIO_DIN GPIO_NUM_11
15+
#define AUDIO_I2S_GPIO_DOUT GPIO_NUM_9
16+
17+
#define AUDIO_CODEC_PA_PIN GPIO_NUM_53
18+
#define AUDIO_CODEC_I2C_SDA_PIN GPIO_NUM_7
19+
#define AUDIO_CODEC_I2C_SCL_PIN GPIO_NUM_8
20+
#define AUDIO_CODEC_ES8311_ADDR ES8311_CODEC_DEFAULT_ADDR
21+
#define AUDIO_CODEC_ES7210_ADDR ES7210_CODEC_DEFAULT_ADDR
22+
23+
#define BOOT_BUTTON_GPIO GPIO_NUM_35
24+
25+
#define DISPLAY_WIDTH 1024
26+
#define DISPLAY_HEIGHT 600
27+
28+
#define LCD_BIT_PER_PIXEL (16)
29+
#define PIN_NUM_LCD_RST GPIO_NUM_33
30+
31+
#define DELAY_TIME_MS (3000)
32+
#define LCD_MIPI_DSI_LANE_NUM (2) // 2 data lanes
33+
34+
#define MIPI_DSI_PHY_PWR_LDO_CHAN (3)
35+
#define MIPI_DSI_PHY_PWR_LDO_VOLTAGE_MV (2500)
36+
37+
#define DISPLAY_SWAP_XY false
38+
#define DISPLAY_MIRROR_X false
39+
#define DISPLAY_MIRROR_Y false
40+
41+
#define DISPLAY_OFFSET_X 0
42+
#define DISPLAY_OFFSET_Y 0
43+
44+
#define DISPLAY_BACKLIGHT_PIN GPIO_NUM_32
45+
#define DISPLAY_BACKLIGHT_OUTPUT_INVERT true
46+
47+
#endif // _BOARD_CONFIG_H_
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"target": "esp32p4",
3+
"builds": [
4+
{
5+
"name": "waveshare-p4-wifi6-touch-lcd-7b",
6+
"sdkconfig_append": [
7+
"CONFIG_USE_WECHAT_MESSAGE_STYLE=n",
8+
"CONFIG_USE_DEVICE_AEC=y"
9+
]
10+
}
11+
]
12+
}
Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
#include "wifi_board.h"
2+
#include "codecs/box_audio_codec.h"
3+
#include "application.h"
4+
#include "display/lcd_display.h"
5+
// #include "display/no_display.h"
6+
#include "button.h"
7+
#include "config.h"
8+
9+
#include "esp_lcd_panel_ops.h"
10+
#include "esp_lcd_mipi_dsi.h"
11+
#include "esp_ldo_regulator.h"
12+
13+
#include "esp_lcd_ek79007.h"
14+
15+
#include <wifi_station.h>
16+
#include <esp_log.h>
17+
#include <driver/i2c_master.h>
18+
#include <esp_lvgl_port.h>
19+
#include "esp_lcd_touch_gt911.h"
20+
#define TAG "WaveshareEsp32p47b"
21+
22+
class WaveshareEsp32p47b : public WifiBoard {
23+
private:
24+
i2c_master_bus_handle_t i2c_bus_;
25+
Button boot_button_;
26+
LcdDisplay *display_;
27+
28+
void InitializeCodecI2c() {
29+
// Initialize I2C peripheral
30+
i2c_master_bus_config_t i2c_bus_cfg = {
31+
.i2c_port = I2C_NUM_1,
32+
.sda_io_num = AUDIO_CODEC_I2C_SDA_PIN,
33+
.scl_io_num = AUDIO_CODEC_I2C_SCL_PIN,
34+
.clk_source = I2C_CLK_SRC_DEFAULT,
35+
.glitch_ignore_cnt = 7,
36+
.intr_priority = 0,
37+
.trans_queue_depth = 0,
38+
.flags = {
39+
.enable_internal_pullup = 1,
40+
},
41+
};
42+
ESP_ERROR_CHECK(i2c_new_master_bus(&i2c_bus_cfg, &i2c_bus_));
43+
}
44+
45+
static esp_err_t bsp_enable_dsi_phy_power(void) {
46+
#if MIPI_DSI_PHY_PWR_LDO_CHAN > 0
47+
// Turn on the power for MIPI DSI PHY, so it can go from "No Power" state to "Shutdown" state
48+
static esp_ldo_channel_handle_t phy_pwr_chan = NULL;
49+
esp_ldo_channel_config_t ldo_cfg = {
50+
.chan_id = MIPI_DSI_PHY_PWR_LDO_CHAN,
51+
.voltage_mv = MIPI_DSI_PHY_PWR_LDO_VOLTAGE_MV,
52+
};
53+
esp_ldo_acquire_channel(&ldo_cfg, &phy_pwr_chan);
54+
ESP_LOGI(TAG, "MIPI DSI PHY Powered on");
55+
#endif // BSP_MIPI_DSI_PHY_PWR_LDO_CHAN > 0
56+
57+
return ESP_OK;
58+
}
59+
60+
void InitializeLCD() {
61+
bsp_enable_dsi_phy_power();
62+
esp_lcd_panel_io_handle_t io = NULL;
63+
esp_lcd_panel_handle_t disp_panel = NULL;
64+
65+
esp_lcd_dsi_bus_handle_t mipi_dsi_bus = NULL;
66+
esp_lcd_dsi_bus_config_t bus_config = {
67+
.bus_id = 0,
68+
.num_data_lanes = 2,
69+
.phy_clk_src = MIPI_DSI_PHY_CLK_SRC_DEFAULT,
70+
.lane_bit_rate_mbps = 900,
71+
};
72+
esp_lcd_new_dsi_bus(&bus_config, &mipi_dsi_bus);
73+
74+
ESP_LOGI(TAG, "Install MIPI DSI LCD control panel");
75+
// we use DBI interface to send LCD commands and parameters
76+
esp_lcd_dbi_io_config_t dbi_config = EK79007_PANEL_IO_DBI_CONFIG();
77+
esp_lcd_new_panel_io_dbi(mipi_dsi_bus, &dbi_config, &io);
78+
79+
esp_lcd_dpi_panel_config_t dpi_config = {
80+
.dpi_clk_src = MIPI_DSI_DPI_CLK_SRC_DEFAULT,
81+
.dpi_clock_freq_mhz = 52,
82+
.pixel_format = LCD_COLOR_PIXEL_FORMAT_RGB565,
83+
.num_fbs = 1,
84+
.video_timing = {
85+
.h_size = 1024,
86+
.v_size = 600,
87+
.hsync_pulse_width = 10,
88+
.hsync_back_porch = 160,
89+
.hsync_front_porch = 160,
90+
.vsync_pulse_width = 1,
91+
.vsync_back_porch = 23,
92+
.vsync_front_porch = 12,
93+
},
94+
.flags = {
95+
.use_dma2d = true,
96+
},
97+
};
98+
ek79007_vendor_config_t vendor_config = {
99+
.mipi_config = {
100+
.dsi_bus = mipi_dsi_bus,
101+
.dpi_config = &dpi_config,
102+
},
103+
};
104+
105+
const esp_lcd_panel_dev_config_t lcd_dev_config = {
106+
.reset_gpio_num = PIN_NUM_LCD_RST,
107+
.rgb_ele_order = LCD_RGB_ELEMENT_ORDER_RGB,
108+
.bits_per_pixel = 16,
109+
.vendor_config = &vendor_config,
110+
};
111+
esp_lcd_new_panel_ek79007(io, &lcd_dev_config, &disp_panel);
112+
esp_lcd_panel_reset(disp_panel);
113+
esp_lcd_panel_init(disp_panel);
114+
115+
display_ = new MipiLcdDisplay(io, disp_panel, DISPLAY_WIDTH, DISPLAY_HEIGHT,
116+
DISPLAY_OFFSET_X, DISPLAY_OFFSET_Y, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y, DISPLAY_SWAP_XY);
117+
118+
lv_display_t *disp = lv_display_get_default();
119+
if (disp) {
120+
lv_disp_set_rotation(disp, LV_DISPLAY_ROTATION_180);
121+
ESP_LOGI(TAG, "Display rotated 180 degrees");
122+
} else {
123+
ESP_LOGE(TAG, "Failed to get default display for rotation");
124+
}
125+
}
126+
void InitializeTouch()
127+
{
128+
esp_lcd_touch_handle_t tp;
129+
esp_lcd_touch_config_t tp_cfg = {
130+
.x_max = DISPLAY_WIDTH,
131+
.y_max = DISPLAY_HEIGHT,
132+
.rst_gpio_num = GPIO_NUM_23,
133+
.int_gpio_num = GPIO_NUM_NC,
134+
.levels = {
135+
.reset = 0,
136+
.interrupt = 0,
137+
},
138+
.flags = {
139+
.swap_xy = 0,
140+
.mirror_x = 0,
141+
.mirror_y = 0,
142+
},
143+
};
144+
esp_lcd_panel_io_handle_t tp_io_handle = NULL;
145+
esp_lcd_panel_io_i2c_config_t tp_io_config = ESP_LCD_TOUCH_IO_I2C_GT911_CONFIG();
146+
tp_io_config.scl_speed_hz = 400 * 1000;
147+
ESP_ERROR_CHECK(esp_lcd_new_panel_io_i2c(i2c_bus_, &tp_io_config, &tp_io_handle));
148+
ESP_LOGI(TAG, "Initialize touch controller");
149+
ESP_ERROR_CHECK(esp_lcd_touch_new_i2c_gt911(tp_io_handle, &tp_cfg, &tp));
150+
const lvgl_port_touch_cfg_t touch_cfg = {
151+
.disp = lv_display_get_default(),
152+
.handle = tp,
153+
};
154+
lvgl_port_add_touch(&touch_cfg);
155+
ESP_LOGI(TAG, "Touch panel initialized successfully");
156+
}
157+
void InitializeButtons() {
158+
boot_button_.OnClick([this]() {
159+
auto& app = Application::GetInstance();
160+
if (app.GetDeviceState() == kDeviceStateStarting && !WifiStation::GetInstance().IsConnected()) {
161+
ResetWifiConfiguration();
162+
}
163+
app.ToggleChatState(); });
164+
}
165+
166+
public:
167+
WaveshareEsp32p47b() :
168+
boot_button_(BOOT_BUTTON_GPIO) {
169+
InitializeCodecI2c();
170+
InitializeLCD();
171+
InitializeTouch();
172+
InitializeButtons();
173+
GetBacklight()->RestoreBrightness();
174+
}
175+
176+
virtual AudioCodec* GetAudioCodec() override {
177+
static BoxAudioCodec audio_codec(
178+
i2c_bus_,
179+
AUDIO_INPUT_SAMPLE_RATE,
180+
AUDIO_OUTPUT_SAMPLE_RATE,
181+
AUDIO_I2S_GPIO_MCLK,
182+
AUDIO_I2S_GPIO_BCLK,
183+
AUDIO_I2S_GPIO_WS,
184+
AUDIO_I2S_GPIO_DOUT,
185+
AUDIO_I2S_GPIO_DIN,
186+
AUDIO_CODEC_PA_PIN,
187+
AUDIO_CODEC_ES8311_ADDR,
188+
AUDIO_CODEC_ES7210_ADDR,
189+
AUDIO_INPUT_REFERENCE);
190+
return &audio_codec;
191+
}
192+
193+
virtual Display *GetDisplay() override {
194+
return display_;
195+
}
196+
197+
virtual Backlight* GetBacklight() override {
198+
static PwmBacklight backlight(DISPLAY_BACKLIGHT_PIN, DISPLAY_BACKLIGHT_OUTPUT_INVERT);
199+
return &backlight;
200+
}
201+
202+
};
203+
204+
DECLARE_BOARD(WaveshareEsp32p47b);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"target": "esp32p4",
3+
"builds": [
4+
{
5+
"name": "waveshare-p4-wifi6-touch-lcd-xc-3.4c",
6+
"sdkconfig_append": [
7+
"CONFIG_USE_WECHAT_MESSAGE_STYLE=n",
8+
"CONFIG_USE_DEVICE_AEC=y",
9+
"CONFIG_LCD_TYPE_800_800_3_4_INCH=y"
10+
]
11+
},
12+
{
13+
"name": "waveshare-p4-wifi6-touch-lcd-xc-4c",
14+
"sdkconfig_append": [
15+
"CONFIG_USE_WECHAT_MESSAGE_STYLE=n",
16+
"CONFIG_USE_DEVICE_AEC=y",
17+
"CONFIG_LCD_TYPE_720_720_4_INCH=y"
18+
]
19+
}
20+
]
21+
}

main/display/lcd_display.cc

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,6 @@ MipiLcdDisplay::MipiLcdDisplay(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel
232232
bool mirror_x, bool mirror_y, bool swap_xy)
233233
: LcdDisplay(panel_io, panel, width, height) {
234234

235-
// Set the display to on
236-
ESP_LOGI(TAG, "Turning display on");
237-
ESP_ERROR_CHECK(esp_lcd_panel_disp_on_off(panel_, true));
238-
239235
ESP_LOGI(TAG, "Initialize LVGL library");
240236
lv_init();
241237

@@ -262,7 +258,7 @@ MipiLcdDisplay::MipiLcdDisplay(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel
262258
.flags = {
263259
.buff_dma = true,
264260
.buff_spiram =false,
265-
.sw_rotate = false,
261+
.sw_rotate = true,
266262
},
267263
};
268264

0 commit comments

Comments
 (0)