forked from xiaozhi/xiaozhi-esp32
add iot speaker for boards
This commit is contained in:
@@ -5,13 +5,14 @@
|
||||
#include "button.h"
|
||||
#include "led.h"
|
||||
#include "config.h"
|
||||
#include "iot/thing_manager.h"
|
||||
|
||||
#include <esp_log.h>
|
||||
#include <esp_spiffs.h>
|
||||
#include <driver/gpio.h>
|
||||
#include <driver/i2c_master.h>
|
||||
|
||||
static const char *TAG = "KevinBoxBoard";
|
||||
#define TAG "KevinBoxBoard"
|
||||
|
||||
class KevinBoxBoard : public Ml307Board {
|
||||
private:
|
||||
@@ -95,8 +96,7 @@ private:
|
||||
});
|
||||
|
||||
volume_up_button_.OnLongPress([this]() {
|
||||
auto codec = GetAudioCodec();
|
||||
codec->SetOutputVolume(100);
|
||||
GetAudioCodec()->SetOutputVolume(100);
|
||||
GetDisplay()->ShowNotification("最大音量");
|
||||
});
|
||||
|
||||
@@ -111,12 +111,17 @@ private:
|
||||
});
|
||||
|
||||
volume_down_button_.OnLongPress([this]() {
|
||||
auto codec = GetAudioCodec();
|
||||
codec->SetOutputVolume(0);
|
||||
GetAudioCodec()->SetOutputVolume(0);
|
||||
GetDisplay()->ShowNotification("已静音");
|
||||
});
|
||||
}
|
||||
|
||||
// 物联网初始化,添加对 AI 可见设备
|
||||
void InitializeIot() {
|
||||
auto& thing_manager = iot::ThingManager::GetInstance();
|
||||
thing_manager.AddThing(iot::CreateThing("Speaker"));
|
||||
}
|
||||
|
||||
public:
|
||||
KevinBoxBoard() : Ml307Board(ML307_TX_PIN, ML307_RX_PIN, 4096),
|
||||
boot_button_(BOOT_BUTTON_GPIO),
|
||||
@@ -128,6 +133,7 @@ public:
|
||||
Enable4GModule();
|
||||
|
||||
InitializeButtons();
|
||||
InitializeIot();
|
||||
}
|
||||
|
||||
virtual Led* GetBuiltinLed() override {
|
||||
|
||||
Reference in New Issue
Block a user