generated from Template/H563ZI-HAL-CMake-Template
新增 DebugSerialPort 支持,CommonCenter、CanMv 和 DfPlayer 改用智能指针
Some checks failed
Build and Upload Artifact / build and upload-artifact (push) Has been cancelled
Some checks failed
Build and Upload Artifact / build and upload-artifact (push) Has been cancelled
This commit is contained in:
@@ -1,16 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
||||
#include "../Common/serial_port.hpp"
|
||||
|
||||
class DfPlayer {
|
||||
public:
|
||||
explicit DfPlayer(UART_HandleTypeDef* uart) : serialPort(new SerialPort(uart, kLength, kTimeout)) {}
|
||||
explicit DfPlayer(UART_HandleTypeDef* uart) : serialPort(std::make_unique<SerialPort>(uart, kLength, kTimeout)) {}
|
||||
|
||||
~DfPlayer() {
|
||||
delete serialPort;
|
||||
}
|
||||
~DfPlayer() = default;
|
||||
|
||||
void Play();
|
||||
void Stop();
|
||||
@@ -52,7 +51,7 @@ private:
|
||||
|
||||
static constexpr uint32_t kLength = 128;
|
||||
static constexpr uint32_t kTimeout = 10;
|
||||
SerialPort* serialPort;
|
||||
std::unique_ptr<SerialPort> serialPort;
|
||||
|
||||
void SendCommand(Command cmd, uint16_t param = 0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user