Double click BOOT to switch 4G/Wi-Fi

This commit is contained in:
Terrence
2025-05-07 17:11:26 +08:00
parent ee0df3470c
commit b6489a3456
15 changed files with 98 additions and 325 deletions

View File

@@ -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);
}
};