Merged debug-printf into arduino-support

This commit is contained in:
dario
2023-11-23 09:02:04 +01:00
3 changed files with 40 additions and 5 deletions

View File

@@ -4,17 +4,37 @@
# include <inttypes.h>
# include <string.h>
# include <stdio.h>
# include <stdint.h>
#else
# include <cinttypes>
# include <cstring>
# include <cstdio>
# include <cstdint>
#endif // STA_PLATFORM_ARDUINO
#include <stdarg.h>
#include <sta/debug/assert.hpp>
#include <sta/lang.hpp>
namespace sta
{
void Printable::printf(const char * fmt, ...)
{
va_list args;
va_start (args, fmt);
char temp[1];
int n = vsnprintf(temp, 1, fmt, args);
va_start (args, fmt);
char str[n];
vsnprintf(str, n, fmt, args);
STA_ASSERT(n > 0);
println(str);
}
void Printable::print(char c)
{
print(&c, 1);
@@ -188,4 +208,4 @@ namespace sta
print(buffer, digits);
}
} // namespace sta
} // namespace sta