summaryrefslogtreecommitdiff
path: root/src/serial.hpp
blob: f32ca63f9afc1e56e6bc01164472a597688c7197 (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
28
29
30
31
#pragma once

#include "std/smart_string.hpp"

#include <USBAPI.h>

class SerialStream
{
public:
	SerialStream(Serial_ serial, const unsigned long &baud_rate);

	SerialStream &operator<<(const char *str);
	SerialStream &operator<<(const SmartString &str);
	SerialStream &operator<<(const double &num);
	SerialStream &operator<<(const int &num);
	SerialStream &operator<<(const unsigned int &num);
	SerialStream &operator<<(const unsigned long &num);

	SerialStream &operator<<(void (*manipulator)(SerialStream *));

	void waitReady();

	void write(const char *str);

	void flush();

private:
	Serial_ _serial;
};

void endl(SerialStream *serial_stream);