blob: 874d6d73028fc8eb575cd8cabae8bf7c67bdddd5 (
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
#include "serial.hpp"
#include "common/conversion.hpp"
SerialStream::SerialStream(Serial_ serial, const unsigned long &baud_rate) noexcept
: _serial(serial)
{
_serial.begin(baud_rate);
}
void SerialStream::waitReady()
{
while (!_serial) {}
}
void SerialStream::write(const char *str)
{
if (SerialStream::is_enabled())
{
_serial.write(str);
}
}
void SerialStream::flush()
{
_serial.flush();
}
SerialStream &SerialStream::operator<<(const char *str)
{
write(str);
return *this;
}
SerialStream &SerialStream::operator<<(const common::String &str)
{
write(str.c_str);
return *this;
}
SerialStream &SerialStream::operator<<(const double &num)
{
write(common::doubleToStr(num, 3U, 4U)->c_str);
return *this;
}
SerialStream &SerialStream::operator<<(const int &num)
{
write(common::intToStr(num)->c_str);
return *this;
}
SerialStream &SerialStream::operator<<(const unsigned int &num)
{
write(common::uintToStr(num)->c_str);
return *this;
}
SerialStream &SerialStream::operator<<(const unsigned long &num)
{
write(common::uintToStr(num)->c_str);
return *this;
}
SerialStream &SerialStream::operator<<(void (*manipulator)(SerialStream *))
{
manipulator(this);
return *this;
}
void endl(SerialStream *serial_stream)
{
serial_stream->write("\n");
serial_stream->flush();
}
|