forked from xiaozhi/xiaozhi-esp32
@@ -52,10 +52,4 @@ choice BOARD_TYPE
|
|||||||
bool "立创开发板"
|
bool "立创开发板"
|
||||||
endchoice
|
endchoice
|
||||||
|
|
||||||
config USE_AFE_SR
|
|
||||||
bool "Use Espressif AFE SR"
|
|
||||||
default y
|
|
||||||
help
|
|
||||||
Use AFE SR for wake word detection.
|
|
||||||
|
|
||||||
endmenu
|
endmenu
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ class CompactMl307Board : public Ml307Board {
|
|||||||
private:
|
private:
|
||||||
i2c_master_bus_handle_t display_i2c_bus_;
|
i2c_master_bus_handle_t display_i2c_bus_;
|
||||||
Button boot_button_;
|
Button boot_button_;
|
||||||
|
Button touch_button_;
|
||||||
Button volume_up_button_;
|
Button volume_up_button_;
|
||||||
Button volume_down_button_;
|
Button volume_down_button_;
|
||||||
SystemReset system_reset_;
|
SystemReset system_reset_;
|
||||||
@@ -40,6 +41,12 @@ private:
|
|||||||
boot_button_.OnClick([this]() {
|
boot_button_.OnClick([this]() {
|
||||||
Application::GetInstance().ToggleChatState();
|
Application::GetInstance().ToggleChatState();
|
||||||
});
|
});
|
||||||
|
touch_button_.OnPressDown([this]() {
|
||||||
|
Application::GetInstance().StartListening();
|
||||||
|
});
|
||||||
|
touch_button_.OnPressUp([this]() {
|
||||||
|
Application::GetInstance().StopListening();
|
||||||
|
});
|
||||||
|
|
||||||
volume_up_button_.OnClick([this]() {
|
volume_up_button_.OnClick([this]() {
|
||||||
auto codec = GetAudioCodec();
|
auto codec = GetAudioCodec();
|
||||||
@@ -77,6 +84,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
CompactMl307Board() : Ml307Board(ML307_TX_PIN, ML307_RX_PIN, 4096),
|
CompactMl307Board() : Ml307Board(ML307_TX_PIN, ML307_RX_PIN, 4096),
|
||||||
boot_button_(BOOT_BUTTON_GPIO),
|
boot_button_(BOOT_BUTTON_GPIO),
|
||||||
|
touch_button_(TOUCH_BUTTON_GPIO, 1),
|
||||||
volume_up_button_(VOLUME_UP_BUTTON_GPIO),
|
volume_up_button_(VOLUME_UP_BUTTON_GPIO),
|
||||||
volume_down_button_(VOLUME_DOWN_BUTTON_GPIO),
|
volume_down_button_(VOLUME_DOWN_BUTTON_GPIO),
|
||||||
system_reset_(RESET_NVS_BUTTON_GPIO, RESET_FACTORY_BUTTON_GPIO) {
|
system_reset_(RESET_NVS_BUTTON_GPIO, RESET_FACTORY_BUTTON_GPIO) {
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
#define BUILTIN_LED_GPIO GPIO_NUM_48
|
#define BUILTIN_LED_GPIO GPIO_NUM_48
|
||||||
#define BOOT_BUTTON_GPIO GPIO_NUM_0
|
#define BOOT_BUTTON_GPIO GPIO_NUM_0
|
||||||
|
#define TOUCH_BUTTON_GPIO GPIO_NUM_45
|
||||||
#define VOLUME_UP_BUTTON_GPIO GPIO_NUM_40
|
#define VOLUME_UP_BUTTON_GPIO GPIO_NUM_40
|
||||||
#define VOLUME_DOWN_BUTTON_GPIO GPIO_NUM_39
|
#define VOLUME_DOWN_BUTTON_GPIO GPIO_NUM_39
|
||||||
#define RESET_NVS_BUTTON_GPIO GPIO_NUM_1
|
#define RESET_NVS_BUTTON_GPIO GPIO_NUM_1
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ class CompactWifiBoard : public WifiBoard {
|
|||||||
private:
|
private:
|
||||||
i2c_master_bus_handle_t display_i2c_bus_;
|
i2c_master_bus_handle_t display_i2c_bus_;
|
||||||
Button boot_button_;
|
Button boot_button_;
|
||||||
|
Button touch_button_;
|
||||||
Button volume_up_button_;
|
Button volume_up_button_;
|
||||||
Button volume_down_button_;
|
Button volume_down_button_;
|
||||||
SystemReset system_reset_;
|
SystemReset system_reset_;
|
||||||
@@ -43,7 +44,12 @@ private:
|
|||||||
if (app.GetChatState() == kChatStateUnknown && !WifiStation::GetInstance().IsConnected()) {
|
if (app.GetChatState() == kChatStateUnknown && !WifiStation::GetInstance().IsConnected()) {
|
||||||
ResetWifiConfiguration();
|
ResetWifiConfiguration();
|
||||||
}
|
}
|
||||||
app.ToggleChatState();
|
});
|
||||||
|
touch_button_.OnPressDown([this]() {
|
||||||
|
Application::GetInstance().StartListening();
|
||||||
|
});
|
||||||
|
touch_button_.OnPressUp([this]() {
|
||||||
|
Application::GetInstance().StopListening();
|
||||||
});
|
});
|
||||||
|
|
||||||
volume_up_button_.OnClick([this]() {
|
volume_up_button_.OnClick([this]() {
|
||||||
@@ -82,6 +88,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
CompactWifiBoard() :
|
CompactWifiBoard() :
|
||||||
boot_button_(BOOT_BUTTON_GPIO),
|
boot_button_(BOOT_BUTTON_GPIO),
|
||||||
|
touch_button_(TOUCH_BUTTON_GPIO, 1),
|
||||||
volume_up_button_(VOLUME_UP_BUTTON_GPIO),
|
volume_up_button_(VOLUME_UP_BUTTON_GPIO),
|
||||||
volume_down_button_(VOLUME_DOWN_BUTTON_GPIO),
|
volume_down_button_(VOLUME_DOWN_BUTTON_GPIO),
|
||||||
system_reset_(RESET_NVS_BUTTON_GPIO, RESET_FACTORY_BUTTON_GPIO) {
|
system_reset_(RESET_NVS_BUTTON_GPIO, RESET_FACTORY_BUTTON_GPIO) {
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
#define BUILTIN_LED_GPIO GPIO_NUM_48
|
#define BUILTIN_LED_GPIO GPIO_NUM_48
|
||||||
#define BOOT_BUTTON_GPIO GPIO_NUM_0
|
#define BOOT_BUTTON_GPIO GPIO_NUM_0
|
||||||
|
#define TOUCH_BUTTON_GPIO GPIO_NUM_45
|
||||||
#define VOLUME_UP_BUTTON_GPIO GPIO_NUM_40
|
#define VOLUME_UP_BUTTON_GPIO GPIO_NUM_40
|
||||||
#define VOLUME_DOWN_BUTTON_GPIO GPIO_NUM_39
|
#define VOLUME_DOWN_BUTTON_GPIO GPIO_NUM_39
|
||||||
#define RESET_NVS_BUTTON_GPIO GPIO_NUM_1
|
#define RESET_NVS_BUTTON_GPIO GPIO_NUM_1
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
static const char* TAG = "Button";
|
static const char* TAG = "Button";
|
||||||
|
|
||||||
Button::Button(gpio_num_t gpio_num) : gpio_num_(gpio_num) {
|
Button::Button(gpio_num_t gpio_num, bool active_high) : gpio_num_(gpio_num) {
|
||||||
if (gpio_num == GPIO_NUM_NC) {
|
if (gpio_num == GPIO_NUM_NC) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -14,7 +14,7 @@ Button::Button(gpio_num_t gpio_num) : gpio_num_(gpio_num) {
|
|||||||
.short_press_time = 50,
|
.short_press_time = 50,
|
||||||
.gpio_button_config = {
|
.gpio_button_config = {
|
||||||
.gpio_num = gpio_num,
|
.gpio_num = gpio_num,
|
||||||
.active_level = 0
|
.active_level = static_cast<uint8_t>(active_high ? 1 : 0)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
button_handle_ = iot_button_create(&button_config);
|
button_handle_ = iot_button_create(&button_config);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
class Button {
|
class Button {
|
||||||
public:
|
public:
|
||||||
Button(gpio_num_t gpio_num);
|
Button(gpio_num_t gpio_num, bool active_high = false);
|
||||||
~Button();
|
~Button();
|
||||||
|
|
||||||
void OnPressDown(std::function<void()> callback);
|
void OnPressDown(std::function<void()> callback);
|
||||||
|
|||||||
Reference in New Issue
Block a user