99#include " Otto.h"
1010#include " application.h"
1111#include " audio_codecs/no_audio_codec.h"
12+ #include " button.h"
1213#include " config.h"
1314#include " display/lcd_display.h"
1415#include " iot/thing_manager.h"
16+ #include " ml307_board.h"
1517#include " power_manager.h"
1618#include " system_reset.h"
1719#include " wifi_board.h"
18-
1920#define TAG " OttoRobot"
2021
2122LV_FONT_DECLARE (font_puhui_16_4);
@@ -25,6 +26,7 @@ class OttoRobot : public WifiBoard {
2526private:
2627 LcdDisplay* display_;
2728 PowerManager* power_manager_;
29+ Button boot_button_;
2830
2931 void InitializePowerManager () {
3032 power_manager_ =
@@ -81,6 +83,17 @@ class OttoRobot : public WifiBoard {
8183 });
8284 }
8385
86+ void InitializeButtons () {
87+ boot_button_.OnClick ([this ]() {
88+ auto & app = Application::GetInstance ();
89+ if (app.GetDeviceState () == kDeviceStateStarting &&
90+ !WifiStation::GetInstance ().IsConnected ()) {
91+ ResetWifiConfiguration ();
92+ }
93+ app.ToggleChatState ();
94+ });
95+ }
96+
8497 void InitializeIot () {
8598 auto & thing_manager = iot::ThingManager::GetInstance ();
8699 thing_manager.AddThing (iot::CreateThing (" Speaker" ));
@@ -90,9 +103,10 @@ class OttoRobot : public WifiBoard {
90103 }
91104
92105public:
93- OttoRobot () : display_( nullptr ) {
106+ OttoRobot () : boot_button_(BOOT_BUTTON_GPIO ) {
94107 InitializeSpi ();
95108 InitializeLcdDisplay ();
109+ InitializeButtons ();
96110 InitializeIot ();
97111 InitializePowerManager ();
98112 if (DISPLAY_BACKLIGHT_PIN != GPIO_NUM_NC) {
0 commit comments