I am running the following example arduino-1.8.12\examples\08.Strings\StringConstructors StringConstructors.ino file. I am programming to an Artemis Apollo 3 mcu provided from sparkfun (lora things plus explorable). For some reason floats will not print right , and i cannot figure out why it is not working. Here is the line of code that is not working:
// using a float and the right decimal places:
stringOne = String(5.698, 3);
Serial.println(stringOne);
// using a float and less decimal places to use rounding:
stringOne = String(5.698, 2);
Serial.println(stringOne);
Here is the output on the serial monitor:
%5.3f
%4.2f
I cannot figure out why it is printing the format of the value and not the value itself???
I tried on an ESP32 and it also gives the expected result.
Could you check what you get from:
// using a float and the right decimal places:
stringOne = String(5.698, 3);
Serial.println(stringOne.c_str());
// using a float and less decimal places to use rounding:
stringOne = String(5.698, 2);
Serial.println(stringOne.c_str());
I would suspect the mbedOS and core conflicting in some way (may be some printf replacement stuff )
(never played with Artemis Apollo 3 mcu - so can't say)
Do you mean the "SparkFun Edge Development Board - Apollo3 Blue"? Or is it a different "SparkFun Apollo 3" board? I ask because I don't see any Arduino support for the "SparkFun Edge Development Board - Apollo3 Blue".
Not yet, i did a bunch of researching and found these references:
Sounds like that is my exact issue, Do you know where i need to make the change ("platform.minimal-printf-enable-floating-point": true) ?
I found mbed_app.json filename in multiple directories. I am guessing this is the correct one, however adding the line did not seem to work?
\AppData\Local\Arduino15\packages\SparkFun\hardware\apollo3\2.0.5\cores\mbed-os\tools\test\config\app_override_libs
Well i tried a bunch of changes to compiler flags e.g. adding --specs=nano.specs -u _printf_float , turnning off optimization etc. However it does not seem that the libraries are being recompiled with these changes, as the output says this during compilation:
Using previously compiled file:
C"\ .......\AppData\Local\Temp\arduino_build_441533\core\mbed-bridge\core-api\api\Print.cpp.o
Is there a way to force recompilation of the libraries?
Yea it is recompiling it still getting the same result. Not sure what is going wrong. ive added the -u _printf_float to the compiler ld flags, and have also tried deleting nano.specs all together and get the same result