forked from xiaozhi/xiaozhi-esp32
Adds battery power to the current board (#249)
* Add files via upload Added board description * Add files via upload New battery control * Add files via upload New battery control * Add files via upload Update format * Add files via upload Added screen version compatibility * Add files via upload Added screen version compatibility * Add files via upload 修改程序风格 * Add files via upload 修改程序风格 * Add files via upload 更新背光 * Add files via upload Update the backlight control program * Add files via upload Update the backlight control program * Add files via upload Update the backlight control program * Add files via upload Update function function implementation * Add files via upload Update function function implementation * Add files via upload Remove excess space * Add files via upload 添加注释 * Add files via upload 添加程序注释
This commit is contained in:
4
main/boards/esp32-s3-touch-lcd-1.46/README.md
Normal file
4
main/boards/esp32-s3-touch-lcd-1.46/README.md
Normal file
@@ -0,0 +1,4 @@
|
||||
新增 微雪 开发板: ESP32-S3-Touch-LCD-1.46、ESP32-S3-Touch-LCD-1.46B
|
||||
产品链接:
|
||||
https://www.waveshare.net/shop/ESP32-S3-Touch-LCD-1.46.htm
|
||||
https://www.waveshare.net/shop/ESP32-S3-Touch-LCD-1.46B.htm
|
||||
@@ -8,7 +8,8 @@
|
||||
#define AUDIO_OUTPUT_SAMPLE_RATE 24000
|
||||
|
||||
#define BOOT_BUTTON_GPIO GPIO_NUM_0
|
||||
|
||||
#define PWR_BUTTON_GPIO GPIO_NUM_6
|
||||
#define PWR_Control_PIN GPIO_NUM_7
|
||||
|
||||
#define AUDIO_I2S_MIC_GPIO_WS GPIO_NUM_2
|
||||
#define AUDIO_I2S_MIC_GPIO_SCK GPIO_NUM_15
|
||||
@@ -20,6 +21,7 @@
|
||||
#define I2C_SCL_IO GPIO_NUM_10
|
||||
#define I2C_SDA_IO GPIO_NUM_11
|
||||
|
||||
|
||||
#define I2C_ADDRESS ESP_IO_EXPANDER_I2C_TCA9554_ADDRESS_000
|
||||
|
||||
#define DISPLAY_WIDTH 412
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
#include <esp_timer.h>
|
||||
#include "esp_io_expander_tca9554.h"
|
||||
#include "lcd_display.h"
|
||||
#include <iot_button.h>
|
||||
|
||||
#define TAG "waveshare_lcd_1_46"
|
||||
|
||||
LV_FONT_DECLARE(font_puhui_16_4);
|
||||
@@ -59,10 +61,10 @@ public:
|
||||
|
||||
class CustomBoard : public WifiBoard {
|
||||
private:
|
||||
Button boot_button_;
|
||||
i2c_master_bus_handle_t i2c_bus_;
|
||||
esp_io_expander_handle_t io_expander = NULL;
|
||||
LcdDisplay* display_;
|
||||
button_handle_t boot_btn,pwr_btn;
|
||||
|
||||
void InitializeI2c() {
|
||||
// Initialize I2C peripheral
|
||||
@@ -145,14 +147,69 @@ private:
|
||||
DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_OFFSET_X, DISPLAY_OFFSET_Y, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y, DISPLAY_SWAP_XY);
|
||||
}
|
||||
|
||||
void InitializeButtonsCustom() {
|
||||
gpio_reset_pin(BOOT_BUTTON_GPIO);
|
||||
gpio_set_direction(BOOT_BUTTON_GPIO, GPIO_MODE_INPUT);
|
||||
gpio_reset_pin(PWR_BUTTON_GPIO);
|
||||
gpio_set_direction(PWR_BUTTON_GPIO, GPIO_MODE_INPUT);
|
||||
gpio_reset_pin(PWR_Control_PIN);
|
||||
gpio_set_direction(PWR_Control_PIN, GPIO_MODE_OUTPUT);
|
||||
// gpio_set_level(PWR_Control_PIN, false);
|
||||
gpio_set_level(PWR_Control_PIN, true);
|
||||
}
|
||||
void InitializeButtons() {
|
||||
boot_button_.OnClick([this]() {
|
||||
InitializeButtonsCustom();
|
||||
button_config_t btns_config = {
|
||||
.type = BUTTON_TYPE_CUSTOM,
|
||||
.long_press_time = 2000,
|
||||
.short_press_time = 50,
|
||||
.custom_button_config = {
|
||||
.active_level = 0,
|
||||
.button_custom_init = nullptr,
|
||||
.button_custom_get_key_value = [](void *param) -> uint8_t {
|
||||
return gpio_get_level(BOOT_BUTTON_GPIO);
|
||||
},
|
||||
.button_custom_deinit = nullptr,
|
||||
.priv = this,
|
||||
},
|
||||
};
|
||||
boot_btn = iot_button_create(&btns_config);
|
||||
iot_button_register_cb(boot_btn, BUTTON_SINGLE_CLICK, [](void* button_handle, void* usr_data) {
|
||||
auto self = static_cast<CustomBoard*>(usr_data);
|
||||
auto& app = Application::GetInstance();
|
||||
if (app.GetDeviceState() == kDeviceStateStarting && !WifiStation::GetInstance().IsConnected()) {
|
||||
ResetWifiConfiguration();
|
||||
self->ResetWifiConfiguration();
|
||||
}
|
||||
app.ToggleChatState();
|
||||
});
|
||||
}, this);
|
||||
iot_button_register_cb(boot_btn, BUTTON_LONG_PRESS_START, [](void* button_handle, void* usr_data) {
|
||||
// 长按无处理
|
||||
}, this);
|
||||
|
||||
btns_config.long_press_time = 5000;
|
||||
btns_config.custom_button_config.button_custom_get_key_value = [](void *param) -> uint8_t {
|
||||
return gpio_get_level(PWR_BUTTON_GPIO);
|
||||
};
|
||||
pwr_btn = iot_button_create(&btns_config);
|
||||
iot_button_register_cb(pwr_btn, BUTTON_SINGLE_CLICK, [](void* button_handle, void* usr_data) {
|
||||
// auto self = static_cast<CustomBoard*>(usr_data); // 以下程序实现供用户参考 ,实现单击pwr按键调整亮度
|
||||
// if(self->GetBacklight()->brightness() > 1) // 如果亮度不为0
|
||||
// self->GetBacklight()->SetBrightness(1); // 设置亮度为1
|
||||
// else
|
||||
// self->GetBacklight()->RestoreBrightness(); // 恢复原本亮度
|
||||
// 短按无处理
|
||||
}, this);
|
||||
iot_button_register_cb(pwr_btn, BUTTON_LONG_PRESS_START, [](void* button_handle, void* usr_data) {
|
||||
auto self = static_cast<CustomBoard*>(usr_data);
|
||||
if(self->GetBacklight()->brightness() > 0) {
|
||||
self->GetBacklight()->SetBrightness(0);
|
||||
gpio_set_level(PWR_Control_PIN, false);
|
||||
}
|
||||
else {
|
||||
self->GetBacklight()->RestoreBrightness();
|
||||
gpio_set_level(PWR_Control_PIN, true);
|
||||
}
|
||||
}, this);
|
||||
}
|
||||
|
||||
// 物联网初始化,添加对 AI 可见设备
|
||||
@@ -163,8 +220,7 @@ private:
|
||||
}
|
||||
|
||||
public:
|
||||
CustomBoard() :
|
||||
boot_button_(BOOT_BUTTON_GPIO) {
|
||||
CustomBoard() {
|
||||
InitializeI2c();
|
||||
InitializeTca9554();
|
||||
InitializeSpi();
|
||||
|
||||
Reference in New Issue
Block a user