forked from xiaozhi/xiaozhi-esp32
Double click BOOT to switch 4G/Wi-Fi
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#include "ml307_board.h"
|
||||
#include "dual_network_board.h"
|
||||
#include "audio_codecs/no_audio_codec.h"
|
||||
#include "display/lcd_display.h"
|
||||
#include "system_reset.h"
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
#include <esp_log.h>
|
||||
#include <esp_lcd_panel_vendor.h>
|
||||
#include <wifi_station.h>
|
||||
|
||||
#include <driver/rtc_io.h>
|
||||
#include <esp_sleep.h>
|
||||
@@ -23,7 +24,7 @@ LV_FONT_DECLARE(font_puhui_20_4);
|
||||
LV_FONT_DECLARE(font_awesome_20_4);
|
||||
|
||||
|
||||
class XINGZHI_CUBE_1_54TFT_ML307 : public Ml307Board {
|
||||
class XINGZHI_CUBE_1_54TFT_ML307 : public DualNetworkBoard {
|
||||
private:
|
||||
Button boot_button_;
|
||||
Button volume_up_button_;
|
||||
@@ -88,8 +89,21 @@ private:
|
||||
boot_button_.OnClick([this]() {
|
||||
power_save_timer_->WakeUp();
|
||||
auto& app = Application::GetInstance();
|
||||
if (GetNetworkType() == NetworkType::WIFI) {
|
||||
if (app.GetDeviceState() == kDeviceStateStarting && !WifiStation::GetInstance().IsConnected()) {
|
||||
// cast to WifiBoard
|
||||
auto& wifi_board = static_cast<WifiBoard&>(GetCurrentBoard());
|
||||
wifi_board.ResetWifiConfiguration();
|
||||
}
|
||||
}
|
||||
app.ToggleChatState();
|
||||
});
|
||||
boot_button_.OnDoubleClick([this]() {
|
||||
auto& app = Application::GetInstance();
|
||||
if (app.GetDeviceState() == kDeviceStateStarting || app.GetDeviceState() == kDeviceStateWifiConfiguring) {
|
||||
SwitchNetworkType();
|
||||
}
|
||||
});
|
||||
|
||||
volume_up_button_.OnClick([this]() {
|
||||
power_save_timer_->WakeUp();
|
||||
@@ -172,7 +186,7 @@ private:
|
||||
|
||||
public:
|
||||
XINGZHI_CUBE_1_54TFT_ML307() :
|
||||
Ml307Board(ML307_TX_PIN, ML307_RX_PIN, 4096),
|
||||
DualNetworkBoard(ML307_TX_PIN, ML307_RX_PIN, 4096),
|
||||
boot_button_(BOOT_BUTTON_GPIO),
|
||||
volume_up_button_(VOLUME_UP_BUTTON_GPIO),
|
||||
volume_down_button_(VOLUME_DOWN_BUTTON_GPIO) {
|
||||
@@ -216,7 +230,7 @@ public:
|
||||
if (!enabled) {
|
||||
power_save_timer_->WakeUp();
|
||||
}
|
||||
Ml307Board::SetPowerSaveMode(enabled);
|
||||
DualNetworkBoard::SetPowerSaveMode(enabled);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user