diff options
author | HampusM <hampus@hampusmat.com> | 2022-02-14 18:18:38 +0100 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-02-14 18:18:38 +0100 |
commit | 01ce0af940bd69c94a2fac8b65219262845cca98 (patch) | |
tree | 97c443782ce1cfba90b205183c8aab1e3edb0bb3 /src/utils/serial.cpp | |
parent | cb7a167c7dee2fa1a19bd09ede3bae8b140e79da (diff) |
refactor: clean sewage
Diffstat (limited to 'src/utils/serial.cpp')
-rw-r--r-- | src/utils/serial.cpp | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/src/utils/serial.cpp b/src/utils/serial.cpp index 11be550..8e4194f 100644 --- a/src/utils/serial.cpp +++ b/src/utils/serial.cpp @@ -2,20 +2,13 @@ #include "general.hpp" -SerialStream::SerialStream(Serial_ serial, unsigned long baud_rate) +SerialStream::SerialStream(Serial_ serial, uint64_t baud_rate) : _serial(serial) { - this->_serial = serial; - this->_serial.begin(baud_rate); while (!this->_serial) {} } -SerialStream::~SerialStream() -{ - Serial.end(); -} - SerialStream &SerialStream::operator<<(const char *str) { this->write(str); @@ -28,9 +21,27 @@ SerialStream &SerialStream::operator<<(const SmartString &str) return *this; } -SerialStream &SerialStream::operator<<(const float num) +SerialStream &SerialStream::operator<<(const double &num) +{ + this->write(doubleToStr(num)->c_str); + return *this; +} + +SerialStream &SerialStream::operator<<(const int &num) +{ + this->write(intToStr(num)->c_str); + return *this; +} + +SerialStream &SerialStream::operator<<(const unsigned int &num) +{ + this->write(uintToStr(num)->c_str); + return *this; +} + +SerialStream &SerialStream::operator<<(const uint32_t &num) { - this->write(floatToStr(num)->c_str); + this->write(uintToStr(num)->c_str); return *this; } |