C++ 哪种变量是gps.location.lat()的结果(TinyGPSlibrary)
如何放置由C++ 哪种变量是gps.location.lat()的结果(TinyGPSlibrary),c++,arduino,gps,arduino-ide,C++,Arduino,Gps,Arduino Ide,如何放置由Serial.println(gps.location.lat(),6)打印的信息变量中的行 void loop(){ // This sketch displays information every time a new sentence is correctly encoded. while (ss.available() > 0){ gps.encode(ss.read()); if (gps.location.isUpda
Serial.println(gps.location.lat(),6)打印的信息代码>变量中的行
void loop(){
// This sketch displays information every time a new sentence is correctly encoded.
while (ss.available() > 0){
gps.encode(ss.read());
if (gps.location.isUpdated()
{
Serial.print("Latitude= ");
Serial.print( gps.location.lat(), 6);
Serial.print( " Longitude= ");
Serial.println( gps.location.lng(), 6);
}
}
}
所描述的TinyGPS++库的对象TinyGPSLocation以以下方式定义lat()
方法:
double lat();
因此,您只需将函数的结果分配给double
变量:
double Lat = gps.location.lat();
Serial.print( Lat ); /* default Serial.print for floats: two decimals*/
Serial.print(Lat, 6); /* optional second parameter to print six decimals */
/* do whatever you need with your Lat variable */
请展示完整的示例代码(如有可能,请进行编译),并了解C/C++中的术语变量
。我不明白你的问题。我按照你说的做了,但是输出是这样的纬度=27.69经度=85.27我希望输出是这样的纬度=27.695705经度=85.276679使用serial.print(Lat,6)代码>。对于浮点参数,第二个参数表示小数点的数量(如您所见,默认值为2)。