add iot speaker for boards

This commit is contained in:
Terrence
2024-12-07 06:19:59 +08:00
parent d31901e9e5
commit 051a0ba483
6 changed files with 58 additions and 14 deletions

View File

@@ -5,6 +5,7 @@
#include "button.h"
#include "led.h"
#include "config.h"
#include "iot/thing_manager.h"
#include <esp_log.h>
#include <driver/i2c_master.h>
@@ -39,10 +40,17 @@ private:
});
}
// 物联网初始化,添加对 AI 可见设备
void InitializeIot() {
auto& thing_manager = iot::ThingManager::GetInstance();
thing_manager.AddThing(iot::CreateThing("Speaker"));
}
public:
EspBox3Board() : boot_button_(BOOT_BUTTON_GPIO) {
InitializeI2c();
InitializeButtons();
InitializeIot();
}
virtual Led* GetBuiltinLed() override {

View File

@@ -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 {

View File

@@ -6,6 +6,7 @@
#include "led.h"
#include "config.h"
#include "axp2101.h"
#include "iot/thing_manager.h"
#include <esp_log.h>
#include <esp_spiffs.h>
@@ -13,7 +14,7 @@
#include <driver/i2c_master.h>
#include <esp_timer.h>
static const char *TAG = "KevinBoxBoard";
#define TAG "KevinBoxBoard"
class KevinBoxBoard : public Ml307Board {
private:
@@ -136,8 +137,7 @@ private:
});
volume_up_button_.OnLongPress([this]() {
auto codec = GetAudioCodec();
codec->SetOutputVolume(100);
GetAudioCodec()->SetOutputVolume(100);
GetDisplay()->ShowNotification("最大音量");
});
@@ -152,12 +152,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),
@@ -172,6 +177,7 @@ public:
InitializeButtons();
InitializePowerSaveTimer();
InitializeIot();
}
virtual Led* GetBuiltinLed() override {

View File

@@ -4,6 +4,7 @@
#include "button.h"
#include "led.h"
#include "config.h"
#include "iot/thing_manager.h"
#include <wifi_station.h>
#include <esp_log.h>
@@ -48,10 +49,17 @@ private:
});
}
// 物联网初始化,添加对 AI 可见设备
void InitializeIot() {
auto& thing_manager = iot::ThingManager::GetInstance();
thing_manager.AddThing(iot::CreateThing("Speaker"));
}
public:
KevinBoxBoard() : boot_button_(BOOT_BUTTON_GPIO) {
InitializeCodecI2c();
InitializeButtons();
InitializeIot();
}
virtual Led* GetBuiltinLed() override {

View File

@@ -6,6 +6,7 @@
#include "led.h"
#include "config.h"
#include "i2c_device.h"
#include "iot/thing_manager.h"
#include <esp_log.h>
#include <esp_lcd_panel_vendor.h>
@@ -119,12 +120,19 @@ 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"));
}
public:
LichuangDevBoard() : boot_button_(BOOT_BUTTON_GPIO) {
InitializeI2c();
InitializeSpi();
InitializeSt7789Display();
InitializeButtons();
InitializeIot();
}
virtual Led* GetBuiltinLed() override {