diff options
Diffstat (limited to 'src/serial.cpp')
-rw-r--r-- | src/serial.cpp | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/src/serial.cpp b/src/serial.cpp index d03f8e8..acf92fa 100644 --- a/src/serial.cpp +++ b/src/serial.cpp @@ -2,46 +2,45 @@ #include "std/conversion.hpp" -SerialStream::SerialStream(Serial_ serial, uint64_t baud_rate) : _serial(serial) +SerialStream::SerialStream(Serial_ serial, const unsigned long &baud_rate) + : _serial(serial) { - this->_serial.begin(baud_rate); - - while (!this->_serial) {} + _serial.begin(baud_rate); } SerialStream &SerialStream::operator<<(const char *str) { - this->write(str); + write(str); return *this; } SerialStream &SerialStream::operator<<(const SmartString &str) { - this->write(str.c_str); + write(str.c_str); return *this; } SerialStream &SerialStream::operator<<(const double &num) { - this->write(doubleToStr(num)->c_str); + write(doubleToStr(num)->c_str); return *this; } SerialStream &SerialStream::operator<<(const int &num) { - this->write(intToStr(num)->c_str); + write(intToStr(num)->c_str); return *this; } SerialStream &SerialStream::operator<<(const unsigned int &num) { - this->write(uintToStr(num)->c_str); + write(uintToStr(num)->c_str); return *this; } SerialStream &SerialStream::operator<<(const unsigned long &num) { - this->write(uintToStr(num)->c_str); + write(uintToStr(num)->c_str); return *this; } @@ -51,14 +50,19 @@ SerialStream &SerialStream::operator<<(void (*manipulator)(SerialStream *)) return *this; } +void SerialStream::waitReady() +{ + while (!_serial) {} +} + void SerialStream::write(const char *str) { - this->_serial.write(str); + _serial.write(str); } void SerialStream::flush() { - this->_serial.flush(); + _serial.flush(); } void endl(SerialStream *serial_stream) |