新增 Hc05 类,支持 HC-05 蓝牙模块的串口通信,增加串口设置波特率函数
All checks were successful
Build and Upload Artifact / build and upload-artifact (push) Successful in 19m59s

This commit is contained in:
chauyin
2025-05-12 21:57:21 +08:00
parent c3e0edd72d
commit 17d298c782
9 changed files with 119 additions and 18 deletions

View File

@@ -2,6 +2,7 @@
#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"
@@ -33,12 +34,21 @@ public:
return *instance;
}
static SerialPort& GetDebugSerialPort() {
static constexpr auto kLength = 256;
static constexpr auto kTimeout = 1000;
static SerialPort* instance = nullptr;
static Hc05& GetHc05() {
static Hc05* instance = nullptr;
if (instance == nullptr) {
instance = new SerialPort(Config::kDebugUart, kLength, kTimeout);
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;
}