#include "serial.hpp" #include "std/conversion.hpp" SerialStream::SerialStream(Serial_ serial, const unsigned long &baud_rate) : _serial(serial) { _serial.begin(baud_rate); } SerialStream &SerialStream::operator<<(const char *str) { write(str); return *this; } SerialStream &SerialStream::operator<<(const SmartString &str) { write(str.c_str); return *this; } SerialStream &SerialStream::operator<<(const double &num) { write(doubleToStr(num)->c_str); return *this; } SerialStream &SerialStream::operator<<(const int &num) { write(intToStr(num)->c_str); return *this; } SerialStream &SerialStream::operator<<(const unsigned int &num) { write(uintToStr(num)->c_str); return *this; } SerialStream &SerialStream::operator<<(const unsigned long &num) { write(uintToStr(num)->c_str); return *this; } SerialStream &SerialStream::operator<<(void (*manipulator)(SerialStream *)) { manipulator(this); return *this; } void SerialStream::waitReady() { while (!_serial) {} } void SerialStream::write(const char *str) { _serial.write(str); } void SerialStream::flush() { _serial.flush(); } void endl(SerialStream *serial_stream) { serial_stream->write("\n"); serial_stream->flush(); }