From 5e04b2cfcb2790f957a7599f5df3214069edc2b7 Mon Sep 17 00:00:00 2001 From: Dario Date: Sat, 15 Jul 2023 16:11:07 +0100 Subject: [PATCH] Added printable prinf and template printable --- .../sta/debug/printing/printable_printf.hpp | 2 -- .../sta/devices/template/custom_printable.hpp | 34 +++++++++++++++++++ src/devices/template/custom_printable.cpp | 18 ++++++++++ 3 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 include/sta/devices/template/custom_printable.hpp create mode 100644 src/devices/template/custom_printable.cpp diff --git a/include/sta/debug/printing/printable_printf.hpp b/include/sta/debug/printing/printable_printf.hpp index 0d51f04..2ef9ed6 100644 --- a/include/sta/debug/printing/printable_printf.hpp +++ b/include/sta/debug/printing/printable_printf.hpp @@ -23,6 +23,4 @@ namespace sta }; } // namespace sta - - #endif // STA_CORE_PRINTABLE_PRINTF_HPP \ No newline at end of file diff --git a/include/sta/devices/template/custom_printable.hpp b/include/sta/devices/template/custom_printable.hpp new file mode 100644 index 0000000..594ba31 --- /dev/null +++ b/include/sta/devices/template/custom_printable.hpp @@ -0,0 +1,34 @@ +#ifndef STA_CORE_YOUR_DEVICE_CUSTOM_PRINTABLE_HPP +#define STA_CORE_YOUR_DEVICE_CUSTOM_PRINTABLE_HPP + +#include + +#if defined(STA_PLATFORM_YOUR_DEVICE) || defined(DOXYGEN) + +#include + +namespace sta +{ + class CustomPrintable : public Printable + { + public: + /** + * @brief Constructor for your custom printable. + * + * Delete if not needed. + */ + CustomPrintable(/* YOUR ARGMENTS */); + + /** + * @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_YOUR_DEVICE + +#endif // STA_CORE_YOUR_DEVICE_CUSTOM_PRINTABLE_HPP \ No newline at end of file diff --git a/src/devices/template/custom_printable.cpp b/src/devices/template/custom_printable.cpp new file mode 100644 index 0000000..590859a --- /dev/null +++ b/src/devices/template/custom_printable.cpp @@ -0,0 +1,18 @@ +#include + +#ifdef STA_PLATFORM_YOUR_DEVICE + +#include + +namespace sta +{ + void CustomPrintable::print(const char * str, size_t length) + { + STA_ASSERT(str != nullptr); + STA_ASSERT(length > 0); + + // YOUR CODE HERE + } +} // namespace sta + +#endif // STA_PLATFORM_YOUR_DEVICE