summaryrefslogtreecommitdiff
path: root/src/utils/serial.hpp
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-02-14 10:11:32 +0100
committerHampusM <hampus@hampusmat.com>2022-02-14 10:11:32 +0100
commit7892ef9d248c189be68ce7faf63230ec0a318b67 (patch)
tree7c3d07779d5ce96994f81c0cc22e8b667601ee9d /src/utils/serial.hpp
parenta03dfe959fcafd238119bdf7f27c07b92064496e (diff)
refactor: reorganize & add debugging
Diffstat (limited to 'src/utils/serial.hpp')
-rw-r--r--src/utils/serial.hpp27
1 files changed, 27 insertions, 0 deletions
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 <USBAPI.h>
+
+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);