Displaying a Floating Point Number

Question: 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);

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.