From 7892ef9d248c189be68ce7faf63230ec0a318b67 Mon Sep 17 00:00:00 2001 From: HampusM Date: Mon, 14 Feb 2022 10:11:32 +0100 Subject: refactor: reorganize & add debugging --- src/utils/serial.hpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/utils/serial.hpp (limited to 'src/utils/serial.hpp') diff --git a/src/utils/serial.hpp b/src/utils/serial.hpp new file mode 100644 index 0000000..f97e1d8 --- /dev/null +++ b/src/utils/serial.hpp @@ -0,0 +1,27 @@ +#pragma once + +#include "smart_string.hpp" + +#include + +class SerialStream +{ +public: + SerialStream(Serial_ serial, unsigned long baud_rate); + ~SerialStream(); + + SerialStream &operator<<(const char *str); + SerialStream &operator<<(const SmartString &str); + SerialStream &operator<<(const float num); + + SerialStream &operator<<(void (*manipulator)(SerialStream *)); + + void write(const char *str); + + void flush(); + +private: + Serial_ _serial; +}; + +void endl(SerialStream *serial_stream); -- cgit v1.2.3-18-g5258