diff options
author | HampusM <hampus@hampusmat.com> | 2022-03-21 13:00:36 +0100 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-03-21 13:00:36 +0100 |
commit | 757a29d0137b974fff6ddcc945d76e69ae120ecb (patch) | |
tree | 1fff46951e30eeae0402e99070e60901bd104eea /src/serial.cpp | |
parent | 12e3713e7705e4353d306ae2ec03abfe8fcd5f55 (diff) |
Diffstat (limited to 'src/serial.cpp')
-rw-r--r-- | src/serial.cpp | 75 |
1 files changed, 0 insertions, 75 deletions
diff --git a/src/serial.cpp b/src/serial.cpp deleted file mode 100644 index 874d6d7..0000000 --- a/src/serial.cpp +++ /dev/null @@ -1,75 +0,0 @@ -#include "serial.hpp" - -#include "common/conversion.hpp" - -SerialStream::SerialStream(Serial_ serial, const unsigned long &baud_rate) noexcept - : _serial(serial) -{ - _serial.begin(baud_rate); -} - -void SerialStream::waitReady() -{ - while (!_serial) {} -} - -void SerialStream::write(const char *str) -{ - if (SerialStream::is_enabled()) - { - _serial.write(str); - } -} - -void SerialStream::flush() -{ - _serial.flush(); -} - -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 endl(SerialStream *serial_stream) -{ - serial_stream->write("\n"); - serial_stream->flush(); -} |