TODOPIC
Microcontroladores PIC => Lenguaje C para microcontroladores PIC => Mensaje iniciado por: ituarte en 25 de Abril de 2012, 10:47:01
-
Hola tengo esta funcion para cambiar un dato del micro a un string para poder mostrar los datos en un LCD
void Int2Str(char *str, u32 intnum)
{
u32 Div = 1000000000;
while (intnum < Div) // Skip unsignificant zeros
Div /= 10; //
while (Div != 1) // Convert the number to string
{ //
*str++ = intnum/Div + '0'; // save a digit
intnum %= Div; //
Div /= 10; //
}
*str++ = intnum + '0'; // Save last digit
*str++ = '\n'; //new line sign for test purpose
*str = 0; // Append trailing null
}
Pero el problema es que a la salida solo me da numeros enteros, y si la temperatura es 24.3 me da 25 , algun codigo que haga lo mismo pero me devuelva como minimo un decimal??
Gracias
-
busca la funcion sprintf.
saludos
-
/**
* @brief lcd printf function
* @param string with standard defined formats
* @param
* @retval None
*/
void LCD_printf(const char *fmt, ...)
{
s32 i;
u32 text_size, letter;
static char text_buffer[32];
va_list args;
va_start(args, fmt);
text_size = vsprintf(text_buffer, fmt, args);
Como podria hacer para que me mostrara la variable tempValue (del tipo u16)
Gracias