mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/sta-core.git
synced 2025-06-12 01:25:59 +00:00
Add floating-point print
This commit is contained in:
parent
b2ae487b76
commit
ae460b69f6
@ -38,6 +38,12 @@ namespace sta
|
|||||||
* @param b Boolean value
|
* @param b Boolean value
|
||||||
*/
|
*/
|
||||||
void print(bool b);
|
void print(bool b);
|
||||||
|
/**
|
||||||
|
* @brief Print floating point value.
|
||||||
|
*
|
||||||
|
* @param d Floating point value
|
||||||
|
*/
|
||||||
|
void print(double d);
|
||||||
/**
|
/**
|
||||||
* @brief Print integer in selected base.
|
* @brief Print integer in selected base.
|
||||||
*
|
*
|
||||||
@ -97,6 +103,12 @@ namespace sta
|
|||||||
* @param b Boolean value
|
* @param b Boolean value
|
||||||
*/
|
*/
|
||||||
void println(bool b);
|
void println(bool b);
|
||||||
|
/**
|
||||||
|
* @brief Print floating point value followed by a new-line.
|
||||||
|
*
|
||||||
|
* @param d Floating point value
|
||||||
|
*/
|
||||||
|
void println(double d);
|
||||||
/**
|
/**
|
||||||
* @brief Print integer in selected base followed by a new-line.
|
* @brief Print integer in selected base followed by a new-line.
|
||||||
*
|
*
|
||||||
|
13
src/uart.cpp
13
src/uart.cpp
@ -16,6 +16,13 @@ namespace sta
|
|||||||
print(b ? "true" : "false");
|
print(b ? "true" : "false");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UART::print(double d)
|
||||||
|
{
|
||||||
|
char buffer[64];
|
||||||
|
snprintf(buffer, sizeof(buffer), "%f", d);
|
||||||
|
print(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
void UART::print(uint8_t num, IntegerBase base /* = IntegerBase::DEC */)
|
void UART::print(uint8_t num, IntegerBase base /* = IntegerBase::DEC */)
|
||||||
{
|
{
|
||||||
printBase(num, base, "%u", sizeof(num));
|
printBase(num, base, "%u", sizeof(num));
|
||||||
@ -64,6 +71,12 @@ namespace sta
|
|||||||
println();
|
println();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UART::println(double d)
|
||||||
|
{
|
||||||
|
print(d);
|
||||||
|
println();
|
||||||
|
}
|
||||||
|
|
||||||
void UART::println(uint8_t num, IntegerBase base /* = IntegerBase::DEC */)
|
void UART::println(uint8_t num, IntegerBase base /* = IntegerBase::DEC */)
|
||||||
{
|
{
|
||||||
print(num, base);
|
print(num, base);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user