I can not use %f

Hello, I use Keil studio mbed OS6.13 and make project with blink LED example.
I try to use Buffered print like

        num = sprintf(buf, "ch%d: %.2f  ",i, v[i]);
        serial_port.write(buf, num);

but, it’s not work.

And I found this one

but, there is no “mbed_app.json”.

Then I try to modify mbed_config.h like below
#define MBED_CONF_PLATFORM_MINIMAL_PRINTF_ENABLE_64_BIT 1
#define MBED_CONF_PLATFORM_MINIMAL_PRINTF_ENABLE_FLOATING_POINT 1
#define MBED_CONF_PLATFORM_MINIMAL_PRINTF_SET_FLOATING_POINT_MAX_DECIMALS 6

It still not work.
Anyone know how to use %f on Keil studio?

Hello,

you are close, but it is not related to KeilStudio but to MbedOS configuration system

  1. if the mbed_app.json is not already in your project, then should be created in root folder of your project - for more take a look to The configuration system - Program setup | Mbed OS 6 Documentation

  2. Never modified mbed_config.h because it has no effect.
    Line 18-19 of mbed_config.h file says -

    // Automatically generated configuration file.
    // DO NOT EDIT, content will be overwritten.

BR, Jan

Thank you! It works!