mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/sta-core.git
synced 2025-08-06 10:27:34 +00:00
Renamed some variables because Arduino.h is terrible as always
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
|
||||
namespace sta
|
||||
{
|
||||
void Printable::printf(const char * fmt, ...)
|
||||
void BasePrintable::printf(const char * fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start (args, fmt);
|
||||
@@ -28,116 +28,116 @@ namespace sta
|
||||
int n = vsnprintf(temp, 1, fmt, args);
|
||||
|
||||
va_start (args, fmt);
|
||||
char str[n];
|
||||
vsnprintf(str, n, fmt, args);
|
||||
char str[n+1];
|
||||
vsnprintf(str, n+1, fmt, args);
|
||||
STA_ASSERT(n > 0);
|
||||
|
||||
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;
|
||||
@@ -147,14 +147,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<uint32_t>(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];
|
||||
@@ -179,7 +179,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];
|
||||
|
Reference in New Issue
Block a user