forked from arduino-libraries/Arduino_AVRSTL
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArduino_AVRSTL.h
56 lines (43 loc) · 1019 Bytes
/
Arduino_AVRSTL.h
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
/*---------------------
*
* ArduinoSTL Core Library
*
* This header has some glue to make STL and Streams work from a sketch.
*
*/
#ifndef ARDUINOSTL_M_H
#define ARDUINOSTL_M_H
#include <Arduino.h>
#include <serstream>
// Create cout and cin.. there doesn't seem to be a way
// to control what serial device at runtime. Grr.
namespace std
{
extern ohserialstream cout;
extern ihserialstream cin;
}
#if defined(ARDUINO_ARCH_AVR)
class ArduinoSTL_STDIO {
public:
// Initialize STDIO using a pointer to whatever Serial is.
// Serial.begin() must be called at some point.
ArduinoSTL_STDIO(Stream *u) : file(NULL) {
connect(u);
}
ArduinoSTL_STDIO(Stream &u) : file(NULL) {
connect(u);
}
Stream *getUart() {
return uart;
}
void connect(Stream *u);
inline void connect(Stream &u) {
connect(static_cast<Stream*>(&u));
}
private:
Stream *uart;
FILE *file;
};
extern ArduinoSTL_STDIO ArduinoSTL_Serial;
#endif // ARDUINO_ARCH_AVR
#endif // ARDUINOSTL_M_H