diff --git a/main/Kconfig.projbuild b/main/Kconfig.projbuild index 0113fdcc..76eb8cf9 100644 --- a/main/Kconfig.projbuild +++ b/main/Kconfig.projbuild @@ -52,10 +52,4 @@ choice BOARD_TYPE bool "立创开发板" endchoice -config USE_AFE_SR - bool "Use Espressif AFE SR" - default y - help - Use AFE SR for wake word detection. - endmenu diff --git a/main/boards/bread-compact-ml307/compact_ml307_board.cc b/main/boards/bread-compact-ml307/compact_ml307_board.cc index 709aacfe..539acc9d 100644 --- a/main/boards/bread-compact-ml307/compact_ml307_board.cc +++ b/main/boards/bread-compact-ml307/compact_ml307_board.cc @@ -16,6 +16,7 @@ class CompactMl307Board : public Ml307Board { private: i2c_master_bus_handle_t display_i2c_bus_; Button boot_button_; + Button touch_button_; Button volume_up_button_; Button volume_down_button_; SystemReset system_reset_; @@ -40,6 +41,12 @@ private: boot_button_.OnClick([this]() { Application::GetInstance().ToggleChatState(); }); + touch_button_.OnPressDown([this]() { + Application::GetInstance().StartListening(); + }); + touch_button_.OnPressUp([this]() { + Application::GetInstance().StopListening(); + }); volume_up_button_.OnClick([this]() { auto codec = GetAudioCodec(); @@ -77,6 +84,7 @@ private: public: CompactMl307Board() : Ml307Board(ML307_TX_PIN, ML307_RX_PIN, 4096), boot_button_(BOOT_BUTTON_GPIO), + touch_button_(TOUCH_BUTTON_GPIO, 1), volume_up_button_(VOLUME_UP_BUTTON_GPIO), volume_down_button_(VOLUME_DOWN_BUTTON_GPIO), system_reset_(RESET_NVS_BUTTON_GPIO, RESET_FACTORY_BUTTON_GPIO) { diff --git a/main/boards/bread-compact-ml307/config.h b/main/boards/bread-compact-ml307/config.h index 72548c0b..46113e29 100644 --- a/main/boards/bread-compact-ml307/config.h +++ b/main/boards/bread-compact-ml307/config.h @@ -29,6 +29,7 @@ #define BUILTIN_LED_GPIO GPIO_NUM_48 #define BOOT_BUTTON_GPIO GPIO_NUM_0 +#define TOUCH_BUTTON_GPIO GPIO_NUM_45 #define VOLUME_UP_BUTTON_GPIO GPIO_NUM_40 #define VOLUME_DOWN_BUTTON_GPIO GPIO_NUM_39 #define RESET_NVS_BUTTON_GPIO GPIO_NUM_1 diff --git a/main/boards/bread-compact-wifi/compact_wifi_board.cc b/main/boards/bread-compact-wifi/compact_wifi_board.cc index f15f6d93..50798adf 100644 --- a/main/boards/bread-compact-wifi/compact_wifi_board.cc +++ b/main/boards/bread-compact-wifi/compact_wifi_board.cc @@ -17,6 +17,7 @@ class CompactWifiBoard : public WifiBoard { private: i2c_master_bus_handle_t display_i2c_bus_; Button boot_button_; + Button touch_button_; Button volume_up_button_; Button volume_down_button_; SystemReset system_reset_; @@ -43,7 +44,12 @@ private: if (app.GetChatState() == kChatStateUnknown && !WifiStation::GetInstance().IsConnected()) { ResetWifiConfiguration(); } - app.ToggleChatState(); + }); + touch_button_.OnPressDown([this]() { + Application::GetInstance().StartListening(); + }); + touch_button_.OnPressUp([this]() { + Application::GetInstance().StopListening(); }); volume_up_button_.OnClick([this]() { @@ -82,6 +88,7 @@ private: public: CompactWifiBoard() : boot_button_(BOOT_BUTTON_GPIO), + touch_button_(TOUCH_BUTTON_GPIO, 1), volume_up_button_(VOLUME_UP_BUTTON_GPIO), volume_down_button_(VOLUME_DOWN_BUTTON_GPIO), system_reset_(RESET_NVS_BUTTON_GPIO, RESET_FACTORY_BUTTON_GPIO) { diff --git a/main/boards/bread-compact-wifi/config.h b/main/boards/bread-compact-wifi/config.h index 98dd5ce2..e937197a 100644 --- a/main/boards/bread-compact-wifi/config.h +++ b/main/boards/bread-compact-wifi/config.h @@ -30,6 +30,7 @@ #define BUILTIN_LED_GPIO GPIO_NUM_48 #define BOOT_BUTTON_GPIO GPIO_NUM_0 +#define TOUCH_BUTTON_GPIO GPIO_NUM_45 #define VOLUME_UP_BUTTON_GPIO GPIO_NUM_40 #define VOLUME_DOWN_BUTTON_GPIO GPIO_NUM_39 #define RESET_NVS_BUTTON_GPIO GPIO_NUM_1 diff --git a/main/boards/common/button.cc b/main/boards/common/button.cc index 837bfd66..d111c912 100644 --- a/main/boards/common/button.cc +++ b/main/boards/common/button.cc @@ -4,7 +4,7 @@ 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) { return; } @@ -14,7 +14,7 @@ Button::Button(gpio_num_t gpio_num) : gpio_num_(gpio_num) { .short_press_time = 50, .gpio_button_config = { .gpio_num = gpio_num, - .active_level = 0 + .active_level = static_cast(active_high ? 1 : 0) } }; button_handle_ = iot_button_create(&button_config); diff --git a/main/boards/common/button.h b/main/boards/common/button.h index a43dc352..2c3a327d 100644 --- a/main/boards/common/button.h +++ b/main/boards/common/button.h @@ -7,7 +7,7 @@ class Button { public: - Button(gpio_num_t gpio_num); + Button(gpio_num_t gpio_num, bool active_high = false); ~Button(); void OnPressDown(std::function callback);