forked from xiaozhi/xiaozhi-esp32
v1.8.0: Audio 代码重构与低功耗优化 (#943)
* Reconstruct Audio Code * Remove old IoT implementation * Add MQTT-UDP documentation * OTA升级失败时,可以继续使用
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
#include "wifi_board.h"
|
||||
#include "display/lcd_display.h"
|
||||
#include "audio_codecs/es8311_audio_codec.h"
|
||||
#include "codecs/es8311_audio_codec.h"
|
||||
#include "application.h"
|
||||
#include "button.h"
|
||||
#include "led/single_led.h"
|
||||
#include "iot/thing_manager.h"
|
||||
#include "config.h"
|
||||
#include "power_save_timer.h"
|
||||
#include "font_awesome_symbols.h"
|
||||
@@ -103,6 +102,14 @@ private:
|
||||
},
|
||||
};
|
||||
ESP_ERROR_CHECK(i2c_new_master_bus(&i2c_bus_cfg, &codec_i2c_bus_));
|
||||
|
||||
// Print I2C bus info
|
||||
if (i2c_master_probe(codec_i2c_bus_, 0x18, 1000) != ESP_OK) {
|
||||
while (true) {
|
||||
ESP_LOGE(TAG, "Failed to probe I2C bus, please check if you have installed the correct firmware");
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void InitializeButtons() {
|
||||
@@ -165,25 +172,17 @@ private:
|
||||
DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_OFFSET_X, DISPLAY_OFFSET_Y, DISPLAY_MIRROR_X, DISPLAY_MIRROR_Y, DISPLAY_SWAP_XY);
|
||||
}
|
||||
|
||||
// 物联网初始化,添加对 AI 可见设备
|
||||
void InitializeIot() {
|
||||
auto& thing_manager = iot::ThingManager::GetInstance();
|
||||
thing_manager.AddThing(iot::CreateThing("Speaker"));
|
||||
thing_manager.AddThing(iot::CreateThing("Screen"));
|
||||
}
|
||||
|
||||
public:
|
||||
magiclick_c3() : boot_button_(BOOT_BUTTON_GPIO) {
|
||||
// 把 ESP32C3 的 VDD SPI 引脚作为普通 GPIO 口使用
|
||||
esp_efuse_write_field_bit(ESP_EFUSE_VDD_SPI_AS_GPIO);
|
||||
|
||||
InitializeCodecI2c();
|
||||
InitializeButtons();
|
||||
InitializePowerSaveTimer();
|
||||
InitializeSpi();
|
||||
InitializeNv3023Display();
|
||||
InitializeIot();
|
||||
GetBacklight()->RestoreBrightness();
|
||||
|
||||
// 把 ESP32C3 的 VDD SPI 引脚作为普通 GPIO 口使用
|
||||
esp_efuse_write_field_bit(ESP_EFUSE_VDD_SPI_AS_GPIO);
|
||||
}
|
||||
|
||||
virtual Led* GetLed() override {
|
||||
|
||||
Reference in New Issue
Block a user