From 00e9eae43a836c5a23880e75299d07b13d0f07e6 Mon Sep 17 00:00:00 2001 From: dario Date: Mon, 12 Feb 2024 13:23:25 +0100 Subject: [PATCH] Moved pprintable serial to arduino directory. --- .../sta/devices/arduino/printable_serial.hpp | 29 +++++++++++++++++++ src/devices/arduino/printable_serial.cpp | 21 ++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 include/sta/devices/arduino/printable_serial.hpp create mode 100644 src/devices/arduino/printable_serial.cpp diff --git a/include/sta/devices/arduino/printable_serial.hpp b/include/sta/devices/arduino/printable_serial.hpp new file mode 100644 index 0000000..bbe713d --- /dev/null +++ b/include/sta/devices/arduino/printable_serial.hpp @@ -0,0 +1,29 @@ +#ifndef STA_CORE_PRINTABLE_SERIAL_HPP +#define STA_CORE_PRINTABLE_SERIAL_HPP + +#include +#ifdef STA_PLATFORM_ARDUINO + +namespace sta +{ + class PrintableSerial: public Printable + { + public: + /** + * @brief Construct a new Printable Serial object + */ + PrintableSerial(unsigned long baud); + + /** + * @brief Print string. + * + * @param str String buffer + * @param length String length + */ + void print(const char * str, size_t length) override; + }; +} // namespace sta + +#endif // STA_PLATFORM_ARDUINO + +#endif // STA_CORE_PRINTABLE_SERIAL_HPP \ No newline at end of file diff --git a/src/devices/arduino/printable_serial.cpp b/src/devices/arduino/printable_serial.cpp new file mode 100644 index 0000000..ae74fe7 --- /dev/null +++ b/src/devices/arduino/printable_serial.cpp @@ -0,0 +1,21 @@ +#include + +#ifdef STA_PLATFORM_ARDUINO + +#include + +namespace sta +{ + PrintableSerial::PrintableSerial(unsigned long baud) + : Printable{} + { + Serial.begin(baud); + } + + void PrintableSerial::print(const char * str, size_t length) + { + Serial.write(str); + } +} // namespace sta + +#endif // STA_PLATFORM_ARDUINO \ No newline at end of file