Skip to content

Printing float or integer to console #320

Answered by ataffanel
Pandagineer asked this question in Q&A
Discussion options

You must be logged in to vote

Hi!

First of all, the Crazyflie firmware is not written in C# but in C. The difference can be quite big between the two languages.

The DEBUG_PRINT() macro is emulating the standard C printf() fonction. The first argument is a format string and then a variable amount of arguments for the data. Your (expanded) example can be implemented by:

float x;
x = 3.0;
int y;
y = 42;
DEBUG_PRINT("%f %d", (double)x, y);   // This will print "3.0 42"

Note that not all the standard C format syntax will work, but the most common/simple will.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Pandagineer
Comment options

Answer selected by Pandagineer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
2 participants