LV_SPRINTF_USE_FLOAT missed in the LVGL 9.0

Hi,

I have a code in LVGL 8.3 that uses lv_label_set_text_fmt to show a float number in a Label object.

up to LVGL 8.3, I was enabling the #define LV_SPRINTF_USE_FLOAT 1 in the lv_conf.h, however there is nothing like this in the config file of the LVGL-9.0, what should I do?

I fixed this. we should search for the float in the config

only find float in lv_conf_template.h and lv_conf_internal.h. I set it to 1
I still get f

Version would be v9.1.0

It’s missing in config but in code too ?

I m on V9.3, lv_snprintf is not using float, even with #define LV_SPRINTF_USE_FLOAT 1

Strange, just need to enable this in lv_conf.h

#define LV_USE_FLOAT            1

Have checked code and have found
#define PRINTF_DISABLE_SUPPORT_FLOAT (!LV_USE_FLOAT)

// support for the floating point type (%f)
// default: activated
#if !PRINTF_DISABLE_SUPPORT_FLOAT
    #define PRINTF_SUPPORT_FLOAT
#endif

So it need to be the same thing, but not working.

lv_snprintf(t, 10, "%.1f", i["Temp"].as<float>());

Here the minimal code I m using (working fine on V8)

            char *t = (char*)malloc(10);
            lv_snprintf(t, 10, "%.1f", 0.5f);
            Serial.println(t);

Have as result “f”

In my test, using v9.5, the only thing required was to change the LV_USE_FLOAT define #define LV_USE_FLOAT 1 in lv_conf.h, no more code changes where required.

If I do that, and open the file lvgl\src\stdlib\builtin\lv_sprintf_builtin.c on lines 776~794 i see in the IDE that the code is no longer “disabled” and lv_label_set_text_fmt works with %f ov lv_snprintf.

Do you have this enabled in lv_conf, to use the builtin implementation?

If using the standard lib, make sure you have enabled float support on compiler definition, since it may be optional depending on the compiler library in use…

I guess, a quick “hack” would be to change:

#define PRINTF_DISABLE_SUPPORT_FLOAT    (!LV_USE_FLOAT)

to

#define PRINTF_DISABLE_SUPPORT_FLOAT    1

to have support for floats just in printf functions…

Ok, so I have just changed the LVGL V9 version to the same than you (I m using platformio)

lvgl/lvgl@^9.5.0

And all is working now, so the problem was limited to 9.3 version (or something bad in cache, haven’t cleared the project on each tries)