I have those 2 similar routines, one to write an integer to the LCD and the other to write a float, the integer ones work perfectly but the very similar one for float does not work, I'm guessing that sprintf fails for a float on stm32cubemx compiler, any tips on that?
void writeInteger(LiquidCrystal *lcd, int valueToBedisplayed, uint8_t MaxLenghtOfDigitis)
{
char StringValue[MaxLenghtOfDigitis];
sprintf(StringValue, "%d", valueToBedisplayed );
size_t Lengh = strlen(StringValue);
for (uint8_t i = 0; i < Lengh; i++){
write(lcd ,*(StringValue+i));
}
}
void writefloat(LiquidCrystal *lcd, float floatToBeDisplayed, uint8_t MaxLenghtOfDigitis)
{
char StringValue[MaxLenghtOfDigitis+2];
sprintf(StringValue, "%f", floatToBeDisplayed );
size_t Lengh = strlen(StringValue);
for (uint8_t i = 0; i < Lengh; i++){
write(lcd ,*(StringValue+i));
}