Files
BlindCane/Core/App/Center/common_center.hpp
chauyin a7485fca40
Some checks failed
Build and Upload Artifact / build and upload-artifact (push) Has been cancelled
新增 DebugSerialPort 支持,CommonCenter、CanMv 和 DfPlayer 改用智能指针
2025-05-12 13:17:44 +08:00

46 lines
1.3 KiB
C++

#pragma once
#include "../Common/can_mv.hpp"
#include "../Common/df_player.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 SerialPort& GetDebugSerialPort() {
static constexpr auto kLength = 256;
static constexpr auto kTimeout = 1000;
static SerialPort* instance = nullptr;
if (instance == nullptr) {
instance = new SerialPort(Config::kDebugUart, kLength, kTimeout);
}
return *instance;
}
};