Printing float or integer to console #320
-
Hello, In app_hello_world, let's say I wanted to print a float or integer (rather than string) to the Console. I tried this by inserting the lines: float x; But when making, I got an error. It seems that DEBUG_PRINT only accepts a string. My question is: in C#, how do I convert an integer or float to a string? (In Python, this is easy using the str() function.) Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
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 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. |
Beta Was this translation helpful? Give feedback.
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 Cprintf()
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:Note that not all the standard C format syntax will work, but the most common/simple will.