Line data Source code
1 : /** 2 : * @brief [PrintStream library](https://github.com/tttapa/Arduino-PrintStream/blob/6a9e0d365be0b3d84187daa2a8a7bda8d541472e/src/PrintStream.h) 3 : */ 4 : 5 : #ifndef PrintStream_h 6 : #define PrintStream_h 7 : 8 : #include <Arduino.h> 9 : typedef Print &manipulator(Print &); 10 : 11 : Print &endl(Print &printer); 12 : Print &flush(Print &printer); 13 : Print &hex(Print &printer); 14 : Print &bin(Print &printer); 15 : Print &dec(Print &printer); 16 : /* Print &oct(Print &printer); */ 17 : Print &boolalpha(Print &printer); 18 : Print &noboolalpha(Print &printer); 19 : Print &leadingzeros(Print &printer); 20 : Print &noleadingzeros(Print &printer); 21 : Print &uppercase(Print &printer); 22 : Print &nouppercase(Print &printer); 23 : Print &showbase(Print &printer); 24 : Print &noshowbase(Print &printer); 25 : 26 : Print &operator<<(Print &printer, const __FlashStringHelper *s); 27 : #ifdef ARDUINO 28 : Print &operator<<(Print &printer, const String &s); 29 : #endif 30 : Print &operator<<(Print &printer, const char s[]); 31 : Print &operator<<(Print &printer, char c); 32 : Print &operator<<(Print &printer, unsigned char c); 33 : Print &operator<<(Print &printer, int i); 34 : Print &operator<<(Print &printer, unsigned int i); 35 : Print &operator<<(Print &printer, int8_t i); 36 : Print &operator<<(Print &printer, long i); 37 : Print &operator<<(Print &printer, unsigned long i); 38 : Print &operator<<(Print &printer, double d); 39 : Print &operator<<(Print &printer, const Printable &p); 40 : Print &operator<<(Print &printer, bool b); 41 : 42 : Print &operator<<(Print &printer, manipulator pf); 43 : 44 : struct Setbase { uint8_t M_base; }; 45 : Setbase setbase(uint8_t base); 46 : Print &operator<<(Print &printer, Setbase f); 47 : 48 : struct Setprecision { int M_n; }; 49 : Setprecision setprecision(int n); 50 : Print &operator<<(Print &printer, Setprecision f); 51 : 52 : struct Setbytesep { char M_bytesep; }; 53 : Setbytesep setbytesep(char bytesep); 54 : Print &operator<<(Print &printer, Setbytesep f); 55 : 56 : 57 : #ifndef ARDUINO 58 : 59 : #include <iostream> 60 : #include <iomanip> 61 : 62 : // TODO: check conflicts between Arduino version and C++ STL version 63 : using std::endl; 64 : // using std::setbase; 65 : // using std::setprecision; 66 : using std::dec; 67 : using std::hex; 68 : using std::flush; 69 : using std::boolalpha; 70 : using std::noboolalpha; 71 : using std::uppercase; 72 : using std::nouppercase; 73 : using std::showbase; 74 : using std::noshowbase; 75 : 76 4 : inline std::ostream &operator<<(std::ostream &os, uint8_t u) { 77 : // I'm lazy, I should probably implement one for uint8_t to get the leading 78 : // zeros right 79 4 : return os << (unsigned short)u; 80 : } 81 : 82 : #endif 83 : 84 : #endif // PrintStream_h