Sprintf and the Arduino IDE

I’ve had to recompile the Arduino IDE to change the linking process in order to enable true “float” or “double” compatibility when using sprintf() or printf(). These functions are fantastically useful when looking to create a final string that can be sent to a display for example. Unfortunately the main Arduino IDE builds available link against a pared down version of the function that replaces floats with a nasty ‘?’. The recompiled build increases the final sketch build size for all sketches but it is worth it if you need float-related string parsing. For example, I am using the float-enabled sprintf function to place dynamic text (such as temperature or a raw value) in a fixed (predetermined) statement. Because my display is limited in character space, I need to manage display real-estate and can set fixed widths for things such as strings or temperatures etc.

If you wish to use my compiled version of the Arduino IDE, it can be downloaded here: http://josh.to/E2nS (OSX Only).

Leave a Reply