forked from xiaozhi/xiaozhi-esp32
ESP32 Wifi And 4G Merge In All (#1219)
This commit is contained in:
@@ -34,6 +34,8 @@
|
|||||||
#define ASR_BUTTON_GPIO GPIO_NUM_19
|
#define ASR_BUTTON_GPIO GPIO_NUM_19
|
||||||
#define BUILTIN_LED_GPIO GPIO_NUM_2
|
#define BUILTIN_LED_GPIO GPIO_NUM_2
|
||||||
|
|
||||||
|
#define ML307_RX_PIN GPIO_NUM_16
|
||||||
|
#define ML307_TX_PIN GPIO_NUM_17
|
||||||
|
|
||||||
#ifdef CONFIG_LCD_ST7789_240X240_7PIN
|
#ifdef CONFIG_LCD_ST7789_240X240_7PIN
|
||||||
#define DISPLAY_BACKLIGHT_PIN GPIO_NUM_22
|
#define DISPLAY_BACKLIGHT_PIN GPIO_NUM_22
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "wifi_board.h"
|
#include "dual_network_board.h"
|
||||||
#include "codecs/no_audio_codec.h"
|
#include "codecs/no_audio_codec.h"
|
||||||
#include "display/lcd_display.h"
|
#include "display/lcd_display.h"
|
||||||
#include "system_reset.h"
|
#include "system_reset.h"
|
||||||
@@ -58,7 +58,7 @@ static const gc9a01_lcd_init_cmd_t gc9107_lcd_init_cmds[] = {
|
|||||||
|
|
||||||
#define TAG "ESP32-LCD-MarsbearSupport"
|
#define TAG "ESP32-LCD-MarsbearSupport"
|
||||||
|
|
||||||
class CompactWifiBoardLCD : public WifiBoard {
|
class CompactWifiBoardLCD : public DualNetworkBoard {
|
||||||
private:
|
private:
|
||||||
Button boot_button_;
|
Button boot_button_;
|
||||||
Button touch_button_;
|
Button touch_button_;
|
||||||
@@ -137,13 +137,25 @@ private:
|
|||||||
|
|
||||||
boot_button_.OnClick([this]() {
|
boot_button_.OnClick([this]() {
|
||||||
auto& app = Application::GetInstance();
|
auto& app = Application::GetInstance();
|
||||||
if (app.GetDeviceState() == kDeviceStateStarting && !WifiStation::GetInstance().IsConnected()) {
|
if (GetNetworkType() == NetworkType::WIFI) {
|
||||||
ResetWifiConfiguration();
|
if (app.GetDeviceState() == kDeviceStateStarting && !WifiStation::GetInstance().IsConnected()) {
|
||||||
|
// cast to WifiBoard
|
||||||
|
auto& wifi_board = static_cast<WifiBoard&>(GetCurrentBoard());
|
||||||
|
wifi_board.ResetWifiConfiguration();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
gpio_set_level(BUILTIN_LED_GPIO, 1);
|
gpio_set_level(BUILTIN_LED_GPIO, 1);
|
||||||
app.ToggleChatState();
|
app.ToggleChatState();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
boot_button_.OnDoubleClick([this]() {
|
||||||
|
auto& app = Application::GetInstance();
|
||||||
|
if (app.GetDeviceState() == kDeviceStateStarting || app.GetDeviceState() == kDeviceStateWifiConfiguring) {
|
||||||
|
SwitchNetworkType();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
asr_button_.OnClick([this]() {
|
asr_button_.OnClick([this]() {
|
||||||
std::string wake_word="你好小智";
|
std::string wake_word="你好小智";
|
||||||
Application::GetInstance().WakeWordInvoke(wake_word);
|
Application::GetInstance().WakeWordInvoke(wake_word);
|
||||||
@@ -163,6 +175,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
CompactWifiBoardLCD() :
|
CompactWifiBoardLCD() :
|
||||||
|
DualNetworkBoard(ML307_TX_PIN, ML307_RX_PIN),
|
||||||
boot_button_(BOOT_BUTTON_GPIO), touch_button_(TOUCH_BUTTON_GPIO), asr_button_(ASR_BUTTON_GPIO) {
|
boot_button_(BOOT_BUTTON_GPIO), touch_button_(TOUCH_BUTTON_GPIO), asr_button_(ASR_BUTTON_GPIO) {
|
||||||
InitializeSpi();
|
InitializeSpi();
|
||||||
InitializeLcdDisplay();
|
InitializeLcdDisplay();
|
||||||
|
|||||||
@@ -33,6 +33,9 @@
|
|||||||
#define ASR_BUTTON_GPIO GPIO_NUM_19
|
#define ASR_BUTTON_GPIO GPIO_NUM_19
|
||||||
#define BUILTIN_LED_GPIO GPIO_NUM_2
|
#define BUILTIN_LED_GPIO GPIO_NUM_2
|
||||||
|
|
||||||
|
#define ML307_RX_PIN GPIO_NUM_16
|
||||||
|
#define ML307_TX_PIN GPIO_NUM_17
|
||||||
|
|
||||||
#define DISPLAY_SDA_PIN GPIO_NUM_4
|
#define DISPLAY_SDA_PIN GPIO_NUM_4
|
||||||
#define DISPLAY_SCL_PIN GPIO_NUM_15
|
#define DISPLAY_SCL_PIN GPIO_NUM_15
|
||||||
#define DISPLAY_WIDTH 128
|
#define DISPLAY_WIDTH 128
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "wifi_board.h"
|
#include "dual_network_board.h"
|
||||||
#include "codecs/no_audio_codec.h"
|
#include "codecs/no_audio_codec.h"
|
||||||
#include "system_reset.h"
|
#include "system_reset.h"
|
||||||
#include "application.h"
|
#include "application.h"
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
#define TAG "ESP32-MarsbearSupport"
|
#define TAG "ESP32-MarsbearSupport"
|
||||||
|
|
||||||
class CompactWifiBoard : public WifiBoard {
|
class CompactWifiBoard : public DualNetworkBoard {
|
||||||
private:
|
private:
|
||||||
Button boot_button_;
|
Button boot_button_;
|
||||||
Button touch_button_;
|
Button touch_button_;
|
||||||
@@ -105,13 +105,25 @@ private:
|
|||||||
|
|
||||||
boot_button_.OnClick([this]() {
|
boot_button_.OnClick([this]() {
|
||||||
auto& app = Application::GetInstance();
|
auto& app = Application::GetInstance();
|
||||||
if (app.GetDeviceState() == kDeviceStateStarting && !WifiStation::GetInstance().IsConnected()) {
|
if (GetNetworkType() == NetworkType::WIFI) {
|
||||||
ResetWifiConfiguration();
|
if (app.GetDeviceState() == kDeviceStateStarting && !WifiStation::GetInstance().IsConnected()) {
|
||||||
|
// cast to WifiBoard
|
||||||
|
auto& wifi_board = static_cast<WifiBoard&>(GetCurrentBoard());
|
||||||
|
wifi_board.ResetWifiConfiguration();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
gpio_set_level(BUILTIN_LED_GPIO, 1);
|
gpio_set_level(BUILTIN_LED_GPIO, 1);
|
||||||
app.ToggleChatState();
|
app.ToggleChatState();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
boot_button_.OnDoubleClick([this]() {
|
||||||
|
auto& app = Application::GetInstance();
|
||||||
|
if (app.GetDeviceState() == kDeviceStateStarting || app.GetDeviceState() == kDeviceStateWifiConfiguring) {
|
||||||
|
SwitchNetworkType();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
asr_button_.OnClick([this]() {
|
asr_button_.OnClick([this]() {
|
||||||
std::string wake_word="你好小智";
|
std::string wake_word="你好小智";
|
||||||
Application::GetInstance().WakeWordInvoke(wake_word);
|
Application::GetInstance().WakeWordInvoke(wake_word);
|
||||||
@@ -133,7 +145,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CompactWifiBoard() : boot_button_(BOOT_BUTTON_GPIO), touch_button_(TOUCH_BUTTON_GPIO), asr_button_(ASR_BUTTON_GPIO)
|
CompactWifiBoard() : DualNetworkBoard(ML307_TX_PIN, ML307_RX_PIN), boot_button_(BOOT_BUTTON_GPIO), touch_button_(TOUCH_BUTTON_GPIO), asr_button_(ASR_BUTTON_GPIO)
|
||||||
{
|
{
|
||||||
InitializeDisplayI2c();
|
InitializeDisplayI2c();
|
||||||
InitializeSsd1306Display();
|
InitializeSsd1306Display();
|
||||||
|
|||||||
Reference in New Issue
Block a user