Cypress Perform

Home > Support & Community
support.cypress.com     Bookmark and Share
Support & Community

Knowledge Base Article



Displaying a Floating Point Number

Last Updated: 06/27/2011

How to display a floating point number on the LCD when using the PSoC C-compiler?

A floating point number can be converted to ascii using the ftoa function and then displayed on an LCD using the LCD_PrString function.  An example code snippet is shown below.

#include "stdlib.h"

#include "string.h"

void main(void)
{
   float MyFloat;
   int Status;
   char* buf;

   MyFloat = 1.2345;
   buf = ftoa(MyFloat, &Status);
   LCD_Position(0,0);
   LCD_PrString(buf);
}

The same approach may be used to convert a float to ascii and send it over UART.  Instead of the LCD_PrString function, UART_PutString function should be used.


Related Categories: PSoC® 1


Provide feedback on this article

Did this article help you solve your problem?

Yes

No

Maybe

Additional comments:

To protect your privacy, do not include contact information in your feedback.

 Help us improve by taking a brief survey
Sunset Owner: KXP; Secondary Owner: VWA; Sunset Date: 06/15/20
Spec No: None; Sunset Owner: KXP; Secondary Owner: VWA; Sunset Date: 06/15/20