From 01ce0af940bd69c94a2fac8b65219262845cca98 Mon Sep 17 00:00:00 2001 From: HampusM Date: Mon, 14 Feb 2022 18:18:38 +0100 Subject: refactor: clean sewage --- src/utils/serial.cpp | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'src/utils/serial.cpp') 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; } -- cgit v1.2.3-18-g5258