Files
BlindCane/Core/App/Center/common_center.hpp
chauyin 17d298c782
All checks were successful
Build and Upload Artifact / build and upload-artifact (push) Successful in 19m59s
新增 Hc05 类,支持 HC-05 蓝牙模块的串口通信,增加串口设置波特率函数
2025-05-12 21:57:21 +08:00

56 lines
1.6 KiB
C++

#pragma once
#include "../Common/can_mv.hpp"
#include "../Common/df_player.hpp"
#include "../Common/hc05.hpp"
#include "../Common/ultrasonic.hpp"
#include "../config.hpp"
#include "Common/serial_port.hpp"
class CommonCenter {
public:
static Ultrasonic& GetUltrasonic() {
static Ultrasonic* instance = nullptr;
if (instance == nullptr) {
instance = new Ultrasonic(
Config::kCaptureConfig.trigger, Config::kCaptureConfig.timer, Config::kCaptureConfig.channel);
}
return *instance;
}
static DfPlayer& GetDfPlayer() {
static DfPlayer* instance = nullptr;
if (instance == nullptr) {
instance = new DfPlayer(Config::kDfPlayerUart);
}
return *instance;
}
static CanMv& GetCanMv() {
static CanMv* instance = nullptr;
if (instance == nullptr) {
instance = new CanMv(Config::kCanMvUart);
}
return *instance;
}
static Hc05& GetHc05() {
static Hc05* instance = nullptr;
if (instance == nullptr) {
instance = new Hc05(Config::kHc05Uart);
}
return *instance;
}
static SerialPort& GetDebugSerialPort() {
static constexpr auto kBaudRate = 115200;
static constexpr auto kLength = 256;
static constexpr auto kTimeout = 1000;
static SerialPort* instance = nullptr;
if (instance == nullptr) {
instance = new SerialPort(Config::kDebugUart, kBaudRate, kLength, kTimeout);
}
return *instance;
}
};