blob: ae51c3fd5cab89ee54b5abd62cfff6a927438735 (
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
|
#pragma once
#include "common/string.hpp"
#include <USBAPI.h>
#define LEONARDO_XINPUT_VID 0x045E // NOLINT(cppcoreguidelines-macro-usage)
#define LEONARDO_XINPUT_PID 0x028E // NOLINT(cppcoreguidelines-macro-usage)
class SerialStream
{
public:
SerialStream(Serial_ serial, const unsigned long &baud_rate) noexcept;
void waitReady();
void write(const char *str);
void flush();
constexpr static bool is_enabled() noexcept
{
#if USB_VID != LEONARDO_XINPUT_VID && USB_PID != LEONARDO_XINPUT_PID
return true;
#else
return false;
#endif
}
SerialStream &operator<<(const char *str);
SerialStream &operator<<(const common::String &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 *));
private:
Serial_ _serial;
};
void endl(SerialStream *serial_stream);
|