I'm working with psoc creator, and I'm trying to print a float between -1 and 1 to an I2C OLED.
To get this working I'm using the function sprintf. I added the following flag to my linker -u _printf_float
because I'm using newlib-nano and it omits float handling code if not requested. (my problem might have to do something with this.. maybe?)
For testing purposes I wrote the lines:
char stringbuffer[20];
sprintf(stringbuffer, "(%1.1f, %1.1f)", 1.1, 1.1);
While debugging I noticed that every non-zero float I try to print is printed as garbage, with a null character up front. Actually every non-zero float is replaced by the following 3 bytes. If I replace all the values with 0.0 then it is printed perfectly fine.
0x00 '\000'
0x2E '.'
0x80 '\200'
The integers that I'm trying to print in the following line are behaving as expected.
Anyone that ran into a similar problem?