Printing RBELib

From robotics

printf

You can use the standard printf() function once you initialize RBELib with the initRBELib() function and you have your putCharDebug() function. To enable the full capability of the printf() function you need to add the following into the AVR linker options as outlined in the setup guide.

-Wl,-u,vfprintf -lprintf_flt -lm

The supported character types are in the below table if you have the additional functionality enabled.

Character Type
%d Integer
%c Character
%s String
%ld Signed long
%lu Unsigned long
%f Float

Type long long is not supported by AVR on purpose and if you use this type of datatype you are not guaranteed to get correct results!


Escape Characters

There are many escape characters that can be used in your print statements, however here are some of the ones you are more likely to need/use.

Character Purpose
\n Create a new line
\r Return the cursor to the beginning of the line
\t Tab character
\' Create a single quote
\" Create a double quote
\\ Backslash

For example, if in your print statement you wanted to create a newline, your print statement might look something like

printf("Hello\n\rThis is on a new line");


printf("%d\n\r",intvar);   //Output would be the value of intvar as a signed int on a new line.