Does anybody knows if sprintf still works on float numbers to print on LCD?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
VaCe_2419971
Level 2
Level 2

I know there were discussions in the past related to sprintf, yet I cannot accomplish a simple task: to print on LCD a float using sprintf.

I use CY8CKIT-059 Kit and a Character LCD. The LCD displays everything but it fails to display a float number. For clarity I attach the bundle.

Is there something not right with stdio, or the sprintf... I ran out of ideas and the code looks so simple:

#include <project.h>

#include <stdio.h>

int main() 

{

  char str[16];

  float Numb3r = 3.1416;

  LCD_Start();

  LCD_Position(0,0);

  sprintf(str, "Pi = %1.4f...", Numb3r ); 

  LCD_PrintString(str);

}

Is there a known bug, or anyone knows an workaround...

Thanks.

0 Likes
1 Solution

Yes, follow Michel's hints and set in system view the heap space to 200.

Bob

View solution in original post

0 Likes
3 Replies
MiKO_283856
Level 4
Level 4
50 replies posted 25 replies posted 10 replies posted

Hello,

For sure, it works for me.

Check your Build settings, I'm using these ones :

Capture.PNG

Michel

0 Likes

Yes, follow Michel's hints and set in system view the heap space to 200.

Bob

0 Likes

It works as a charm, and the "Correct answer" should be shared with you too.

Thanks a lot to both user_2432504 AND.

Regards.

0 Likes