From 3150ad000b283ef17c607b0251b23a41761f2ca0 Mon Sep 17 00:00:00 2001 From: dario Date: Sun, 26 Nov 2023 18:37:50 +0100 Subject: [PATCH] added debug printing for arduino --- .../sta/debug/printing/printable_serial.hpp | 29 +++++++++++++++++++ src/debug/printing/printable_serial.cpp | 21 ++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 include/sta/debug/printing/printable_serial.hpp create mode 100644 src/debug/printing/printable_serial.cpp diff --git a/include/sta/debug/printing/printable_serial.hpp b/include/sta/debug/printing/printable_serial.hpp new file mode 100644 index 0000000..af7966a --- /dev/null +++ b/include/sta/debug/printing/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 sta::BasePrintable + { + 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/debug/printing/printable_serial.cpp b/src/debug/printing/printable_serial.cpp new file mode 100644 index 0000000..db37e62 --- /dev/null +++ b/src/debug/printing/printable_serial.cpp @@ -0,0 +1,21 @@ +#include + +#ifdef STA_PLATFORM_ARDUINO + +#include + +namespace sta +{ + PrintableSerial::PrintableSerial(unsigned long baud) + : BasePrintable() + { + 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