blob: e60de6cdc56fbf03220233dccac2174df077b11d (
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
|
#include "serial.hpp"
#include "common/conversion.hpp"
SerialStream::SerialStream(Serial_ serial, const unsigned long &baud_rate)
: _serial(serial)
{
_serial.begin(baud_rate);
}
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 SerialStream::waitReady()
{
while (!_serial) {}
}
void SerialStream::write(const char *str)
{
_serial.write(str);
}
void SerialStream::flush()
{
_serial.flush();
}
void endl(SerialStream *serial_stream)
{
serial_stream->write("\n");
serial_stream->flush();
}
|