summaryrefslogtreecommitdiff
path: root/src/utils/serial.hpp
blob: f97e1d887e400bd52d23ade68d2f66af727e1dd6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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);