This should be easy for anyone but me. My coding skills a pretty much limited to cobbling other peoples work together and hope to make it work. I might be using some incorrect terminology here, but bear with me please.
I'm trying to display a value "Altitude" on the LDC. It will display correctly in serial monitor, (257.XX) but I get random numbers on the LCD. I think it's got something to do with the decimal vs char. I don't need to see the decimals on the LCD. The string (dtostrf(Altitude,0,0,altitude_arr)) prints out on serial monitor with three digits and no decimal. I've got no idea how to print that out on the LCD.
Thanks,
Chris
String str_out = //combine all values and create part of NMEA data string output
String("LK8EX1"+String(",")+String(average_pressure,DEC)+ String(",")+String(dtostrf(Altitude,0,0,altitude_arr))+String(",")+
String(dtostrf((vario*100),0,0,vario_arr))+String(",")+String(my_temperature,DEC)+String(",")+String(Battery_Vcc,DEC)+String(","));
unsigned int checksum_end,ai,bi; // Calculating checksum for data string
for (checksum_end = 0, ai = 0; ai < str_out.length(); ai++)
{
bi = (unsigned char)str_out[ai];
checksum_end ^= bi;
}
// creating now NMEA serial output for LK8000. LK8EX1 protocol format:
// $LK8EX1,pressure,altitude,vario,temperature,battery,*checksum
// Serial.print(dtostrf(Altitude,0,0,altitude_arr));
// Serial.print(" ,,,, " );
[color=red] Serial.print(my_temperature); [b] // celcius, two digits. no decimal [/b][/color]
Serial.print(" , " );
[color=red] Serial.print(Altitude); [b] // meters, 257.45 [/b] [/color]
Serial.print(" , " );
[color=red] Serial.println(dtostrf(Altitude,0,0,altitude_arr)); [b] // meter 257 no decimal[/b][/color]
get_time3 = millis();
LcdClear();
gotoXY(1,1);
LcdString("TEMP C");
char buffer_t[8];
sprintf(buffer_t, "%4d", my_temperature, DEC);
[color=red] LcdString(buffer_t); [b] // TEMP reads out properly on LCD[/b][/color]
gotoXY(1,3);
LcdString("ALT M ");
char buffer_alt[8];
sprintf(buffer_alt, "%4d",Altitude, DEC );
[color=red] LcdString(buffer_alt); [b] // LCD displays random numbers positive and negative.[/b][/color]
}
}
//The End