Arduino IDE 2.0.3 sprintf floating point

Hi Guys, is floating point available to use with sprintf() in the Arduino IDE 2.0.3 ? or maybe there is a way to enable it? (I've read bits & pieces about a platform.txt in older versions of the IDE)
Using Board: Arduino UNO

String sometxt = "Pie =";
double pie = 3.142;

char buf[50];


void setup()
{
  Serial.begin(115200);
  delay(250);
  Serial.flush();
  Serial.println("Use sprintf() with a floating point number");
}

void loop()
{
  sprintf(buf, "Pie = %f", pie);
  Serial.println(buf);
  delay(1000);
}

I'm new to sprintf(),,,

also trying to figure out why I can't do

String sometxt = "Pie =";
double pie = 3.142;

char buf[50];


void setup()
{
  Serial.begin(115200);
  delay(250);
  Serial.flush();
  Serial.println("Use sprintf() with a floating point number");
}

void loop()
{
  sprintf(buf, "%s %f", sometxt, pie);
  Serial.println(buf);
  delay(1000);
}

Am doing my best to read through cplusplus sprintf & tutorialspoint c_function_sprintf

%s is a null-terminated char array, not a String. You could use sometxt.c_str(), but would be much simpler to make sometxt a char array to begin with.

You can use dtostrf() to convert the float to a char array, then use that array with sprintf.

Doubtful you will find much information on the c++ references, since the lack of floating point support is not a language problem, but a decision made to reduce code size on the arduino.

Here is a helpful video.

Thanks for the reply David,

char sometxt[] = {'P','i','e',' ','='};
double pie = 3.142;

char buf[50];

void setup()
{
  Serial.begin(115200);
  delay(250);
  Serial.flush();
  Serial.println("Use sprintf() with a floating point number");
}

void loop()
{
  sprintf(buf, "%s %f", sometxt, pie);
  Serial.println(buf);
  delay(1000);
}

It does work like this now, many thanks. I was hoping do something like this Using the sprintf function around post #10. I can't seem to locate a platform.txt under the Arduino 2.0 install folder or the /local/appdata/ folder. Was hoping for that checkbox to turn it on / off in the 2.0.3 version.

The results of the serial monitor shows

Pie = ?

Thanks xfpd.

Maybe for my specific case it would be worth me doing the dtostrf() into a character array, then adding that to the sprintf().

char sometxt[] = "Pie =";
double pie = PI;

char buf[50];
char tempArray[12];


void setup()
{
  Serial.begin(115200);
  delay(250);
  Serial.flush();
  Serial.println("Use sprintf() with a floating point number");
  Serial.println(pie, 6);
}

void loop()
{
  dtostrf(pie,4,6,tempArray);
  sprintf(buf, "%s %s", sometxt, tempArray);
  Serial.println(buf);
  delay(1000);
}

Output on Serial Monitor is

Pie = 3.141593

sometxt is not a c-string but a character array; a c-string is an character array terminated with a '\0'.

Use one of the below

char sometxt[] =  "Pie=";
char sometxt[] = {'P','i','e','=','\0'};

Why did you butcher Pi's name? Did you find it in your oven?
There are no doubles on an UNO, only floats.

The Serial.println() will print a 'float'. You will end up with a bunch of lines with Serial.print() instead of a single sprintf().

void setup() 
{
  Serial.begin(115200);
  Serial.print(F("Pi = "));
  Serial.println(M_PI,4);
}

void loop() {}

Yes, this is a complete and working sketch.

You need to understand this is not related to the Arduino IDE version. Each boards platform defines its own toolchain and compilation commands. The author of one platform might choose to add something like the -lprintf_flt flag to their compilation commands, while another might decide that is inappropriate. It would be quite annoying if Arduino IDE forced a flag like that onto the platform developers. Some compilers might not have the flag. Some microcontrollers (e.g., ATtiny) might have too limited of memory to make it feasible.

So you need to be asking whether the specific version (e.g., 1.8.6) of the platform of your board (e.g., "Arduino AVR Boards") has it available, not whether the IDE version has it available.

Unlike Arduino IDE 1.x, the Arduino IDE 2.x installation does not come with a bundled copy of the "Arduino AVR Boards" platform. So it is normal and expected that you will not find the platform configuration files under the Arduino IDE installation folder.

Now this part is unexpected. If it is not already present, Arduino IDE 2.0.3 automatically installs the latest version of the "Arduino AVR Boards" platform the first time you run it after a fresh install. So unless you uninstalled it, it is definitely expected that you would find it there. At this location specifically:

C:\Users\<user name>\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\platform.txt

(where <user name> is your Windows user name)

Are you certain it is not there? If looking for it with your file browser or command line, note that the C:\Users\<user name>\AppData folder is hidden by default, which can give the impression it is missing entirely. On Windows "File Explorer", you can make it visible by opening the "View" menu, then checking the box next to "☐ Hidden items".

Such a thing would never be added to the official Arduino IDE codebase because the GUI would soon be swamped with checkboxes for each obscure compiler flag some user decides should be added optionally.

However, something even better was added since the time of that forum thread. It is now possible for the boards platform to add custom menus under the Tools menu. A platform developer could definitely add one of those to control whether or not the necessary flags are inserted into the compilation command for your Uno.

In case you are interested in learning the boring details about how the "custom boards options" feature works, see this:

https://arduino.github.io/arduino-cli/latest/platform-specification/#custom-board-options

custom menu capability is not new.
It could be done with the 1.x IDE as well in the boards.txt file and has been possible for MANY years.
In fact some of the 3rd party cores did and still do this for various board options.
The ESP platform has many configurable options that are handled this way.

It would be nice if the Arduino.cc AVR boards included a menu option in the board menu to enable AVR xxprintf() floating point support.

--- bill

1 Like

Many thanks for your reply ptillisch, I now have a bit better understanding of IDE Vs platform tool chain. I do in fact have platform.txt under avr\1.8.6\ I was assuming it to be under avr\2.0.3\ so all good on that one. (lack of knowledge / understanding on my part)

I did read your link regarding the boring details on custom board options, I found it interesting & my understanding is growing by the day.

I love using the IDE 2.0.3, took me a while to sort out the custom auto format but now that's sorted I full steam ahead learning all sorts of coding.

Thanks again for taking the time to explain all this to me,

Regards,

Skip.

Put this in boards.local.txt and you'll have it. Also scanf.

################################

menu.printf=AVR printf Version
menu.scanf=AVR scanf Version

################################


yun.printf=default
yun.menu.printf.default=Default printf
yun.menu.printf.default.avr_printf_flags=
yun.menu.printf.full=Full printf
yun.menu.printf.full.avr_printf_flags=-Wl,-u,vfprintf -lprintf_flt
yun.menu.printf.minimal=Minimal printf
yun.menu.printf.minimal.avr_printf_flags=-Wl,-u,vfprintf -lprintf_min

yun.scanf=default
yun.menu.scanf.default=Default scanf
yun.menu.scanf.default.avr_scanf_flags=
yun.menu.scanf.full=Full scanf
yun.menu.scanf.full.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_flt
yun.menu.scanf.minimal=Minimal scanf
yun.menu.scanf.minimal.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_min

yun.compiler.c.elf.extra_flags={avr_printf_flags} {avr_scanf_flags}


uno.printf=default
uno.menu.printf.default=Default printf
uno.menu.printf.default.avr_printf_flags=
uno.menu.printf.full=Full printf
uno.menu.printf.full.avr_printf_flags=-Wl,-u,vfprintf -lprintf_flt
uno.menu.printf.minimal=Minimal printf
uno.menu.printf.minimal.avr_printf_flags=-Wl,-u,vfprintf -lprintf_min

uno.scanf=default
uno.menu.scanf.default=Default scanf
uno.menu.scanf.default.avr_scanf_flags=
uno.menu.scanf.full=Full scanf
uno.menu.scanf.full.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_flt
uno.menu.scanf.minimal=Minimal scanf
uno.menu.scanf.minimal.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_min

uno.compiler.c.elf.extra_flags={avr_printf_flags} {avr_scanf_flags}


unomini.printf=default
unomini.menu.printf.default=Default printf
unomini.menu.printf.default.avr_printf_flags=
unomini.menu.printf.full=Full printf
unomini.menu.printf.full.avr_printf_flags=-Wl,-u,vfprintf -lprintf_flt
unomini.menu.printf.minimal=Minimal printf
unomini.menu.printf.minimal.avr_printf_flags=-Wl,-u,vfprintf -lprintf_min

unomini.scanf=default
unomini.menu.scanf.default=Default scanf
unomini.menu.scanf.default.avr_scanf_flags=
unomini.menu.scanf.full=Full scanf
unomini.menu.scanf.full.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_flt
unomini.menu.scanf.minimal=Minimal scanf
unomini.menu.scanf.minimal.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_min

unomini.compiler.c.elf.extra_flags={avr_printf_flags} {avr_scanf_flags}


diecimila.printf=default
diecimila.menu.printf.default=Default printf
diecimila.menu.printf.default.avr_printf_flags=
diecimila.menu.printf.full=Full printf
diecimila.menu.printf.full.avr_printf_flags=-Wl,-u,vfprintf -lprintf_flt
diecimila.menu.printf.minimal=Minimal printf
diecimila.menu.printf.minimal.avr_printf_flags=-Wl,-u,vfprintf -lprintf_min

diecimila.scanf=default
diecimila.menu.scanf.default=Default scanf
diecimila.menu.scanf.default.avr_scanf_flags=
diecimila.menu.scanf.full=Full scanf
diecimila.menu.scanf.full.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_flt
diecimila.menu.scanf.minimal=Minimal scanf
diecimila.menu.scanf.minimal.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_min

diecimila.compiler.c.elf.extra_flags={avr_printf_flags} {avr_scanf_flags}


nano.printf=default
nano.menu.printf.default=Default printf
nano.menu.printf.default.avr_printf_flags=
nano.menu.printf.full=Full printf
nano.menu.printf.full.avr_printf_flags=-Wl,-u,vfprintf -lprintf_flt
nano.menu.printf.minimal=Minimal printf
nano.menu.printf.minimal.avr_printf_flags=-Wl,-u,vfprintf -lprintf_min

nano.scanf=default
nano.menu.scanf.default=Default scanf
nano.menu.scanf.default.avr_scanf_flags=
nano.menu.scanf.full=Full scanf
nano.menu.scanf.full.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_flt
nano.menu.scanf.minimal=Minimal scanf
nano.menu.scanf.minimal.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_min

nano.compiler.c.elf.extra_flags={avr_printf_flags} {avr_scanf_flags}


mega.printf=default
mega.menu.printf.default=Default printf
mega.menu.printf.default.avr_printf_flags=
mega.menu.printf.full=Full printf
mega.menu.printf.full.avr_printf_flags=-Wl,-u,vfprintf -lprintf_flt
mega.menu.printf.minimal=Minimal printf
mega.menu.printf.minimal.avr_printf_flags=-Wl,-u,vfprintf -lprintf_min

mega.scanf=default
mega.menu.scanf.default=Default scanf
mega.menu.scanf.default.avr_scanf_flags=
mega.menu.scanf.full=Full scanf
mega.menu.scanf.full.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_flt
mega.menu.scanf.minimal=Minimal scanf
mega.menu.scanf.minimal.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_min

mega.compiler.c.elf.extra_flags={avr_printf_flags} {avr_scanf_flags}


megaADK.printf=default
megaADK.menu.printf.default=Default printf
megaADK.menu.printf.default.avr_printf_flags=
megaADK.menu.printf.full=Full printf
megaADK.menu.printf.full.avr_printf_flags=-Wl,-u,vfprintf -lprintf_flt
megaADK.menu.printf.minimal=Minimal printf
megaADK.menu.printf.minimal.avr_printf_flags=-Wl,-u,vfprintf -lprintf_min

megaADK.scanf=default
megaADK.menu.scanf.default=Default scanf
megaADK.menu.scanf.default.avr_scanf_flags=
megaADK.menu.scanf.full=Full scanf
megaADK.menu.scanf.full.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_flt
megaADK.menu.scanf.minimal=Minimal scanf
megaADK.menu.scanf.minimal.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_min

megaADK.compiler.c.elf.extra_flags={avr_printf_flags} {avr_scanf_flags}


leonardo.printf=default
leonardo.menu.printf.default=Default printf
leonardo.menu.printf.default.avr_printf_flags=
leonardo.menu.printf.full=Full printf
leonardo.menu.printf.full.avr_printf_flags=-Wl,-u,vfprintf -lprintf_flt
leonardo.menu.printf.minimal=Minimal printf
leonardo.menu.printf.minimal.avr_printf_flags=-Wl,-u,vfprintf -lprintf_min

leonardo.scanf=default
leonardo.menu.scanf.default=Default scanf
leonardo.menu.scanf.default.avr_scanf_flags=
leonardo.menu.scanf.full=Full scanf
leonardo.menu.scanf.full.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_flt
leonardo.menu.scanf.minimal=Minimal scanf
leonardo.menu.scanf.minimal.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_min

leonardo.compiler.c.elf.extra_flags={avr_printf_flags} {avr_scanf_flags}


leonardoeth.printf=default
leonardoeth.menu.printf.default=Default printf
leonardoeth.menu.printf.default.avr_printf_flags=
leonardoeth.menu.printf.full=Full printf
leonardoeth.menu.printf.full.avr_printf_flags=-Wl,-u,vfprintf -lprintf_flt
leonardoeth.menu.printf.minimal=Minimal printf
leonardoeth.menu.printf.minimal.avr_printf_flags=-Wl,-u,vfprintf -lprintf_min

leonardoeth.scanf=default
leonardoeth.menu.scanf.default=Default scanf
leonardoeth.menu.scanf.default.avr_scanf_flags=
leonardoeth.menu.scanf.full=Full scanf
leonardoeth.menu.scanf.full.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_flt
leonardoeth.menu.scanf.minimal=Minimal scanf
leonardoeth.menu.scanf.minimal.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_min

leonardoeth.compiler.c.elf.extra_flags={avr_printf_flags} {avr_scanf_flags}


micro.printf=default
micro.menu.printf.default=Default printf
micro.menu.printf.default.avr_printf_flags=
micro.menu.printf.full=Full printf
micro.menu.printf.full.avr_printf_flags=-Wl,-u,vfprintf -lprintf_flt
micro.menu.printf.minimal=Minimal printf
micro.menu.printf.minimal.avr_printf_flags=-Wl,-u,vfprintf -lprintf_min

micro.scanf=default
micro.menu.scanf.default=Default scanf
micro.menu.scanf.default.avr_scanf_flags=
micro.menu.scanf.full=Full scanf
micro.menu.scanf.full.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_flt
micro.menu.scanf.minimal=Minimal scanf
micro.menu.scanf.minimal.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_min

micro.compiler.c.elf.extra_flags={avr_printf_flags} {avr_scanf_flags}


esplora.printf=default
esplora.menu.printf.default=Default printf
esplora.menu.printf.default.avr_printf_flags=
esplora.menu.printf.full=Full printf
esplora.menu.printf.full.avr_printf_flags=-Wl,-u,vfprintf -lprintf_flt
esplora.menu.printf.minimal=Minimal printf
esplora.menu.printf.minimal.avr_printf_flags=-Wl,-u,vfprintf -lprintf_min

esplora.scanf=default
esplora.menu.scanf.default=Default scanf
esplora.menu.scanf.default.avr_scanf_flags=
esplora.menu.scanf.full=Full scanf
esplora.menu.scanf.full.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_flt
esplora.menu.scanf.minimal=Minimal scanf
esplora.menu.scanf.minimal.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_min

esplora.compiler.c.elf.extra_flags={avr_printf_flags} {avr_scanf_flags}


mini.printf=default
mini.menu.printf.default=Default printf
mini.menu.printf.default.avr_printf_flags=
mini.menu.printf.full=Full printf
mini.menu.printf.full.avr_printf_flags=-Wl,-u,vfprintf -lprintf_flt
mini.menu.printf.minimal=Minimal printf
mini.menu.printf.minimal.avr_printf_flags=-Wl,-u,vfprintf -lprintf_min

mini.scanf=default
mini.menu.scanf.default=Default scanf
mini.menu.scanf.default.avr_scanf_flags=
mini.menu.scanf.full=Full scanf
mini.menu.scanf.full.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_flt
mini.menu.scanf.minimal=Minimal scanf
mini.menu.scanf.minimal.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_min

mini.compiler.c.elf.extra_flags={avr_printf_flags} {avr_scanf_flags}


ethernet.printf=default
ethernet.menu.printf.default=Default printf
ethernet.menu.printf.default.avr_printf_flags=
ethernet.menu.printf.full=Full printf
ethernet.menu.printf.full.avr_printf_flags=-Wl,-u,vfprintf -lprintf_flt
ethernet.menu.printf.minimal=Minimal printf
ethernet.menu.printf.minimal.avr_printf_flags=-Wl,-u,vfprintf -lprintf_min

ethernet.scanf=default
ethernet.menu.scanf.default=Default scanf
ethernet.menu.scanf.default.avr_scanf_flags=
ethernet.menu.scanf.full=Full scanf
ethernet.menu.scanf.full.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_flt
ethernet.menu.scanf.minimal=Minimal scanf
ethernet.menu.scanf.minimal.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_min

ethernet.compiler.c.elf.extra_flags={avr_printf_flags} {avr_scanf_flags}


fio.printf=default
fio.menu.printf.default=Default printf
fio.menu.printf.default.avr_printf_flags=
fio.menu.printf.full=Full printf
fio.menu.printf.full.avr_printf_flags=-Wl,-u,vfprintf -lprintf_flt
fio.menu.printf.minimal=Minimal printf
fio.menu.printf.minimal.avr_printf_flags=-Wl,-u,vfprintf -lprintf_min

fio.scanf=default
fio.menu.scanf.default=Default scanf
fio.menu.scanf.default.avr_scanf_flags=
fio.menu.scanf.full=Full scanf
fio.menu.scanf.full.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_flt
fio.menu.scanf.minimal=Minimal scanf
fio.menu.scanf.minimal.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_min

fio.compiler.c.elf.extra_flags={avr_printf_flags} {avr_scanf_flags}


bt.printf=default
bt.menu.printf.default=Default printf
bt.menu.printf.default.avr_printf_flags=
bt.menu.printf.full=Full printf
bt.menu.printf.full.avr_printf_flags=-Wl,-u,vfprintf -lprintf_flt
bt.menu.printf.minimal=Minimal printf
bt.menu.printf.minimal.avr_printf_flags=-Wl,-u,vfprintf -lprintf_min

bt.scanf=default
bt.menu.scanf.default=Default scanf
bt.menu.scanf.default.avr_scanf_flags=
bt.menu.scanf.full=Full scanf
bt.menu.scanf.full.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_flt
bt.menu.scanf.minimal=Minimal scanf
bt.menu.scanf.minimal.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_min

bt.compiler.c.elf.extra_flags={avr_printf_flags} {avr_scanf_flags}


LilyPadUSB.printf=default
LilyPadUSB.menu.printf.default=Default printf
LilyPadUSB.menu.printf.default.avr_printf_flags=
LilyPadUSB.menu.printf.full=Full printf
LilyPadUSB.menu.printf.full.avr_printf_flags=-Wl,-u,vfprintf -lprintf_flt
LilyPadUSB.menu.printf.minimal=Minimal printf
LilyPadUSB.menu.printf.minimal.avr_printf_flags=-Wl,-u,vfprintf -lprintf_min

LilyPadUSB.scanf=default
LilyPadUSB.menu.scanf.default=Default scanf
LilyPadUSB.menu.scanf.default.avr_scanf_flags=
LilyPadUSB.menu.scanf.full=Full scanf
LilyPadUSB.menu.scanf.full.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_flt
LilyPadUSB.menu.scanf.minimal=Minimal scanf
LilyPadUSB.menu.scanf.minimal.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_min

LilyPadUSB.compiler.c.elf.extra_flags={avr_printf_flags} {avr_scanf_flags}


lilypad.printf=default
lilypad.menu.printf.default=Default printf
lilypad.menu.printf.default.avr_printf_flags=
lilypad.menu.printf.full=Full printf
lilypad.menu.printf.full.avr_printf_flags=-Wl,-u,vfprintf -lprintf_flt
lilypad.menu.printf.minimal=Minimal printf
lilypad.menu.printf.minimal.avr_printf_flags=-Wl,-u,vfprintf -lprintf_min

lilypad.scanf=default
lilypad.menu.scanf.default=Default scanf
lilypad.menu.scanf.default.avr_scanf_flags=
lilypad.menu.scanf.full=Full scanf
lilypad.menu.scanf.full.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_flt
lilypad.menu.scanf.minimal=Minimal scanf
lilypad.menu.scanf.minimal.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_min

lilypad.compiler.c.elf.extra_flags={avr_printf_flags} {avr_scanf_flags}


pro.printf=default
pro.menu.printf.default=Default printf
pro.menu.printf.default.avr_printf_flags=
pro.menu.printf.full=Full printf
pro.menu.printf.full.avr_printf_flags=-Wl,-u,vfprintf -lprintf_flt
pro.menu.printf.minimal=Minimal printf
pro.menu.printf.minimal.avr_printf_flags=-Wl,-u,vfprintf -lprintf_min

pro.scanf=default
pro.menu.scanf.default=Default scanf
pro.menu.scanf.default.avr_scanf_flags=
pro.menu.scanf.full=Full scanf
pro.menu.scanf.full.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_flt
pro.menu.scanf.minimal=Minimal scanf
pro.menu.scanf.minimal.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_min

pro.compiler.c.elf.extra_flags={avr_printf_flags} {avr_scanf_flags}


atmegang.printf=default
atmegang.menu.printf.default=Default printf
atmegang.menu.printf.default.avr_printf_flags=
atmegang.menu.printf.full=Full printf
atmegang.menu.printf.full.avr_printf_flags=-Wl,-u,vfprintf -lprintf_flt
atmegang.menu.printf.minimal=Minimal printf
atmegang.menu.printf.minimal.avr_printf_flags=-Wl,-u,vfprintf -lprintf_min

atmegang.scanf=default
atmegang.menu.scanf.default=Default scanf
atmegang.menu.scanf.default.avr_scanf_flags=
atmegang.menu.scanf.full=Full scanf
atmegang.menu.scanf.full.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_flt
atmegang.menu.scanf.minimal=Minimal scanf
atmegang.menu.scanf.minimal.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_min

atmegang.compiler.c.elf.extra_flags={avr_printf_flags} {avr_scanf_flags}


robotControl.printf=default
robotControl.menu.printf.default=Default printf
robotControl.menu.printf.default.avr_printf_flags=
robotControl.menu.printf.full=Full printf
robotControl.menu.printf.full.avr_printf_flags=-Wl,-u,vfprintf -lprintf_flt
robotControl.menu.printf.minimal=Minimal printf
robotControl.menu.printf.minimal.avr_printf_flags=-Wl,-u,vfprintf -lprintf_min

robotControl.scanf=default
robotControl.menu.scanf.default=Default scanf
robotControl.menu.scanf.default.avr_scanf_flags=
robotControl.menu.scanf.full=Full scanf
robotControl.menu.scanf.full.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_flt
robotControl.menu.scanf.minimal=Minimal scanf
robotControl.menu.scanf.minimal.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_min

robotControl.compiler.c.elf.extra_flags={avr_printf_flags} {avr_scanf_flags}


robotMotor.printf=default
robotMotor.menu.printf.default=Default printf
robotMotor.menu.printf.default.avr_printf_flags=
robotMotor.menu.printf.full=Full printf
robotMotor.menu.printf.full.avr_printf_flags=-Wl,-u,vfprintf -lprintf_flt
robotMotor.menu.printf.minimal=Minimal printf
robotMotor.menu.printf.minimal.avr_printf_flags=-Wl,-u,vfprintf -lprintf_min

robotMotor.scanf=default
robotMotor.menu.scanf.default=Default scanf
robotMotor.menu.scanf.default.avr_scanf_flags=
robotMotor.menu.scanf.full=Full scanf
robotMotor.menu.scanf.full.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_flt
robotMotor.menu.scanf.minimal=Minimal scanf
robotMotor.menu.scanf.minimal.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_min

robotMotor.compiler.c.elf.extra_flags={avr_printf_flags} {avr_scanf_flags}


gemma.printf=default
gemma.menu.printf.default=Default printf
gemma.menu.printf.default.avr_printf_flags=
gemma.menu.printf.full=Full printf
gemma.menu.printf.full.avr_printf_flags=-Wl,-u,vfprintf -lprintf_flt
gemma.menu.printf.minimal=Minimal printf
gemma.menu.printf.minimal.avr_printf_flags=-Wl,-u,vfprintf -lprintf_min

gemma.scanf=default
gemma.menu.scanf.default=Default scanf
gemma.menu.scanf.default.avr_scanf_flags=
gemma.menu.scanf.full=Full scanf
gemma.menu.scanf.full.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_flt
gemma.menu.scanf.minimal=Minimal scanf
gemma.menu.scanf.minimal.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_min

gemma.compiler.c.elf.extra_flags={avr_printf_flags} {avr_scanf_flags}


circuitplay32u4cat.printf=default
circuitplay32u4cat.menu.printf.default=Default printf
circuitplay32u4cat.menu.printf.default.avr_printf_flags=
circuitplay32u4cat.menu.printf.full=Full printf
circuitplay32u4cat.menu.printf.full.avr_printf_flags=-Wl,-u,vfprintf -lprintf_flt
circuitplay32u4cat.menu.printf.minimal=Minimal printf
circuitplay32u4cat.menu.printf.minimal.avr_printf_flags=-Wl,-u,vfprintf -lprintf_min

circuitplay32u4cat.scanf=default
circuitplay32u4cat.menu.scanf.default=Default scanf
circuitplay32u4cat.menu.scanf.default.avr_scanf_flags=
circuitplay32u4cat.menu.scanf.full=Full scanf
circuitplay32u4cat.menu.scanf.full.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_flt
circuitplay32u4cat.menu.scanf.minimal=Minimal scanf
circuitplay32u4cat.menu.scanf.minimal.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_min

circuitplay32u4cat.compiler.c.elf.extra_flags={avr_printf_flags} {avr_scanf_flags}


yunmini.printf=default
yunmini.menu.printf.default=Default printf
yunmini.menu.printf.default.avr_printf_flags=
yunmini.menu.printf.full=Full printf
yunmini.menu.printf.full.avr_printf_flags=-Wl,-u,vfprintf -lprintf_flt
yunmini.menu.printf.minimal=Minimal printf
yunmini.menu.printf.minimal.avr_printf_flags=-Wl,-u,vfprintf -lprintf_min

yunmini.scanf=default
yunmini.menu.scanf.default=Default scanf
yunmini.menu.scanf.default.avr_scanf_flags=
yunmini.menu.scanf.full=Full scanf
yunmini.menu.scanf.full.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_flt
yunmini.menu.scanf.minimal=Minimal scanf
yunmini.menu.scanf.minimal.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_min

yunmini.compiler.c.elf.extra_flags={avr_printf_flags} {avr_scanf_flags}


chiwawa.printf=default
chiwawa.menu.printf.default=Default printf
chiwawa.menu.printf.default.avr_printf_flags=
chiwawa.menu.printf.full=Full printf
chiwawa.menu.printf.full.avr_printf_flags=-Wl,-u,vfprintf -lprintf_flt
chiwawa.menu.printf.minimal=Minimal printf
chiwawa.menu.printf.minimal.avr_printf_flags=-Wl,-u,vfprintf -lprintf_min

chiwawa.scanf=default
chiwawa.menu.scanf.default=Default scanf
chiwawa.menu.scanf.default.avr_scanf_flags=
chiwawa.menu.scanf.full=Full scanf
chiwawa.menu.scanf.full.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_flt
chiwawa.menu.scanf.minimal=Minimal scanf
chiwawa.menu.scanf.minimal.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_min

chiwawa.compiler.c.elf.extra_flags={avr_printf_flags} {avr_scanf_flags}


one.printf=default
one.menu.printf.default=Default printf
one.menu.printf.default.avr_printf_flags=
one.menu.printf.full=Full printf
one.menu.printf.full.avr_printf_flags=-Wl,-u,vfprintf -lprintf_flt
one.menu.printf.minimal=Minimal printf
one.menu.printf.minimal.avr_printf_flags=-Wl,-u,vfprintf -lprintf_min

one.scanf=default
one.menu.scanf.default=Default scanf
one.menu.scanf.default.avr_scanf_flags=
one.menu.scanf.full=Full scanf
one.menu.scanf.full.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_flt
one.menu.scanf.minimal=Minimal scanf
one.menu.scanf.minimal.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_min

one.compiler.c.elf.extra_flags={avr_printf_flags} {avr_scanf_flags}


unowifi.printf=default
unowifi.menu.printf.default=Default printf
unowifi.menu.printf.default.avr_printf_flags=
unowifi.menu.printf.full=Full printf
unowifi.menu.printf.full.avr_printf_flags=-Wl,-u,vfprintf -lprintf_flt
unowifi.menu.printf.minimal=Minimal printf
unowifi.menu.printf.minimal.avr_printf_flags=-Wl,-u,vfprintf -lprintf_min

unowifi.scanf=default
unowifi.menu.scanf.default=Default scanf
unowifi.menu.scanf.default.avr_scanf_flags=
unowifi.menu.scanf.full=Full scanf
unowifi.menu.scanf.full.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_flt
unowifi.menu.scanf.minimal=Minimal scanf
unowifi.menu.scanf.minimal.avr_scanf_flags=-Wl,-u,vfscanf -lscanf_min

unowifi.compiler.c.elf.extra_flags={avr_printf_flags} {avr_scanf_flags}
1 Like

The "checkbox" mentioned previously in this thread was a modification applied to Arduino IDE 1.0.5:

Arduino IDE 1.0.x did not have the custom board options feature.

I think it would be more appropriate to do that in a 3rd party platform targeted to more advanced users. If one doesn't exist already, such a platform could be created with only a few files thanks to the referencing feature.

Nice! I also find this stuff very interesting, but expect that not everyone will share that opinion.

The board menu capability is great.
It wasn't that I didn't know how to do it. (I've actually done something similar in the past), I was just commenting that it would be nice if this came "out of the box" on the Arduino.cc AVR boards as users have been asking to have the ability to be able to configure AVR floating point support from the IDE GUI for over 10 years.

--- bill

blah blah blah, yeah there always seems to be an excuse against providing better support for xxprintf() functionality in the arduino.cc supplied platforms.

For whatever reason the arduino.cc team has always been adverse to xxprintf() support. This goes all the way to some of the Arduino founders saying that xxprintf formatting strings are just "too scary" for Arduino users.
This includes the refusal of adding a printf() method to the Print class which has been asked for for more than 10 years.

documentation and tutorials for printf() and xxprintf() formatting strings can easily be found given it has been around now for over 50 years in C and has been ported to many other language over the decades.

And if you didn't already know, every other 3rd party platform now includes a printf() method in their Print class. It is only the arduino.cc platforms that don't have it due to their continuous objection to supporting it.
i.e. on all the 3rd party platforms, like Teensy, chipkit, ESP8266, STM, ESP32, you can do things like Serial.printf() or lcd.printf() so you don't have to go through the hoops of using sprintf() or dtostrf()

The Arduino.cc platforms are the odd man out when it comes to this.

If users don't want to use it, that is perfectly ok and there is no penalty to their code if they don't use it.
But for users that want to do xxprintf() output formatting on the boards in Arduino.cc provided platforms, they have to jump through hoops. Particularly if they want to use floating point on the AVR platforms.

This thread is a great example of the continued issue related to xxprintf() support.
If there was a printf() method in the Print class() and if the Arduino.cc AVR platform let the user turn on xxprintf() floating point support by having board menu options, this thread would likely never have been started and we wouldn't be having this extended conversation.
But if a user simply didn't know about the printf() method in the Print class or how to enable floating point support, then it would be a simple response to tell them how to use it.

I just don't get the continual arduino.cc team objection to better supporting xxprintf() and adding a printf() method to the Print class and having GUI option to enable AVR floating point support in the xxprintf() code for the AVR based boards.

--- bill

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.