diff --git a/include/sta/config.hpp b/include/sta/config.hpp index ee160b7..6864f86 100644 --- a/include/sta/config.hpp +++ b/include/sta/config.hpp @@ -1,4 +1,5 @@ #include #define STA_PRINTF_USE_STDLIB -#define STA_STDLIB_DISABLE \ No newline at end of file +#define STA_STDLIB_DISABLE +#define STA_DEBUGGING_ENABLED \ No newline at end of file diff --git a/include/sta/debug/debug.hpp b/include/sta/debug/debug.hpp index 7a09609..cf7cbd1 100644 --- a/include/sta/debug/debug.hpp +++ b/include/sta/debug/debug.hpp @@ -8,7 +8,7 @@ namespace sta { - extern Printable * Debug; + extern BasePrintable * Debug; } // namespace sta diff --git a/include/sta/debug/printing/printable.hpp b/include/sta/debug/printing/printable.hpp index bcf3e36..af17199 100644 --- a/include/sta/debug/printing/printable.hpp +++ b/include/sta/debug/printing/printable.hpp @@ -23,9 +23,9 @@ namespace sta */ enum class IntegerBase { - DEC, /**< Decimal */ - BIN, /**< Binary */ - HEX /**< Hexadecimal */ + BASE_DEC, /**< Decimal */ + BASE_BIN, /**< Binary */ + BASE_HEX /**< Hexadecimal */ }; /** @@ -69,7 +69,7 @@ namespace sta * @param num 8-bit unsigned integer * @param base Integer base */ - void print(uint8_t num, IntegerBase base = IntegerBase::DEC); + void print(uint8_t num, IntegerBase base = IntegerBase::BASE_DEC); /** * @brief Print integer in selected base. @@ -77,7 +77,7 @@ namespace sta * @param num 16-bit unsigned integer * @param base Integer base */ - void print(uint16_t num, IntegerBase base = IntegerBase::DEC); + void print(uint16_t num, IntegerBase base = IntegerBase::BASE_DEC); /** * @brief Print integer in selected base. @@ -85,7 +85,7 @@ namespace sta * @param num 32-bit unsigned integer * @param base Integer base */ - void print(uint32_t num, IntegerBase base = IntegerBase::DEC); + void print(uint32_t num, IntegerBase base = IntegerBase::BASE_DEC); /** * @brief Print c-string. @@ -134,7 +134,7 @@ namespace sta * @param num 8-bit unsigned integer * @param base Integer base */ - void println(uint8_t num, IntegerBase base = IntegerBase::DEC); + void println(uint8_t num, IntegerBase base = IntegerBase::BASE_DEC); /** * @brief Print integer in selected base followed by a new-line. @@ -142,7 +142,7 @@ namespace sta * @param num 16-bit unsigned integer * @param base Integer base */ - void println(uint16_t num, IntegerBase base = IntegerBase::DEC); + void println(uint16_t num, IntegerBase base = IntegerBase::BASE_DEC); /** * @brief Print integer in selected base followed by a new-line. @@ -150,7 +150,7 @@ namespace sta * @param num 32-bit unsigned integer * @param base Integer base */ - void println(uint32_t num, IntegerBase base = IntegerBase::DEC); + void println(uint32_t num, IntegerBase base = IntegerBase::BASE_DEC); /** * @brief Print c-string followed by a new-line. diff --git a/include/sta/debug/printing/printable_uart.hpp b/include/sta/debug/printing/printable_uart.hpp index d6ea375..85eac01 100644 --- a/include/sta/debug/printing/printable_uart.hpp +++ b/include/sta/debug/printing/printable_uart.hpp @@ -25,7 +25,7 @@ namespace sta * * @ingroup sta_core */ - class PrintableUART : public Printable + class PrintableUART : public BasePrintable { public: /** diff --git a/src/debug/printing/printable.cpp b/src/debug/printing/printable.cpp index af54a75..89bc169 100644 --- a/src/debug/printing/printable.cpp +++ b/src/debug/printing/printable.cpp @@ -17,7 +17,7 @@ namespace sta { - void Printable::printf(const char * fmt, ...) + void BasePrintable::printf(const char * fmt, ...) { va_list args; va_start (args, fmt); @@ -33,109 +33,109 @@ namespace sta println(str); } - void Printable::print(char c) + void BasePrintable::print(char c) { print(&c, 1); } - void Printable::print(bool b) + void BasePrintable::print(bool b) { print(b ? "true" : "false"); } - void Printable::print(double d) + void BasePrintable::print(double d) { char buffer[64]; snprintf(buffer, sizeof(buffer), "%f", d); print(buffer); } - void Printable::print(uint8_t num, IntegerBase base) + void BasePrintable::print(uint8_t num, IntegerBase base) { printBase(num, base, "%" PRIu8, sizeof(num)); } - void Printable::print(uint16_t num, IntegerBase base) + void BasePrintable::print(uint16_t num, IntegerBase base) { printBase(num, base, "%" PRIu16, sizeof(num)); } - void Printable::print(uint32_t num, IntegerBase base) + void BasePrintable::print(uint32_t num, IntegerBase base) { printBase(num, base, "%" PRIu32, sizeof(num)); } - void Printable::print(const char * str) + void BasePrintable::print(const char * str) { print(str, strlen(str)); } - void Printable::println() + void BasePrintable::println() { print("\r\n", 2); } - void Printable::println(char c) + void BasePrintable::println(char c) { print(&c, 1); println(); } - void Printable::println(bool b) + void BasePrintable::println(bool b) { print(b); println(); } - void Printable::println(double d) + void BasePrintable::println(double d) { print(d); println(); } - void Printable::println(uint8_t num, IntegerBase base) + void BasePrintable::println(uint8_t num, IntegerBase base) { print(num, base); println(); } - void Printable::println(uint16_t num, IntegerBase base) + void BasePrintable::println(uint16_t num, IntegerBase base) { print(num, base); println(); } - void Printable::println(uint32_t num, IntegerBase base) + void BasePrintable::println(uint32_t num, IntegerBase base) { print(num, base); println(); } - void Printable::println(const char * str) + void BasePrintable::println(const char * str) { println(str, strlen(str)); } - void Printable::println(const char * str, size_t length) + void BasePrintable::println(const char * str, size_t length) { print(str, length); println(); } - void Printable::printBase(uintmax_t num, IntegerBase base, const char * fmt, size_t size) + void BasePrintable::printBase(uintmax_t num, IntegerBase base, const char * fmt, size_t size) { switch (base) { - case IntegerBase::DEC: + case IntegerBase::BASE_DEC: printDec(num, fmt); break; - case IntegerBase::BIN: + case IntegerBase::BASE_BIN: // Digits in base 2 = size in bytes * 8 printBin(num, size * 8); break; - case IntegerBase::HEX: + case IntegerBase::BASE_HEX: // Digits in base 16 = size in bytes * 2 printHex(num, size * 2); break; @@ -145,14 +145,14 @@ namespace sta } } - void Printable::printDec(uintmax_t num, const char * fmt) + void BasePrintable::printDec(uintmax_t num, const char * fmt) { char buffer[64]; snprintf(buffer, sizeof(buffer), fmt, static_cast(num)); print(buffer); } - void Printable::printBin(uintmax_t value, size_t digits) + void BasePrintable::printBin(uintmax_t value, size_t digits) { // Need 8 digits for every byte char buffer[sizeof(value) * 8]; @@ -177,7 +177,7 @@ namespace sta print(buffer, digits); } - void Printable::printHex(uintmax_t value, size_t digits) + void BasePrintable::printHex(uintmax_t value, size_t digits) { // Need 2 digits for every byte char buffer[sizeof(value) * 2];