本文整理汇总了C++中TinyGPS::get_position方法的典型用法代码示例。如果您正苦于以下问题:C++ TinyGPS::get_position方法的具体用法?C++ TinyGPS::get_position怎么用?C++ TinyGPS::get_position使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TinyGPS
的用法示例。
在下文中一共展示了TinyGPS::get_position方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: gps_spinOnce
/* GPS listen thread */
void gps_spinOnce(void) {
if(rx_ready(gps_port)) {
gps_input = rx_byte(gps_port);
if(gps.encode(gps_input)) {
gps.get_position(&lat, &lon);
if( gps_pub.reset() ) {
gps_pub.append(lat);
gps_pub.append(lon);
// TODO: fill in rest of GPS message
gps_pub.append(gps.altitude());
gps_pub.append(gps.hdop());
gps_pub.finish();
}
if( gps_pub2.reset() ) {
gps_pub2.append(lat);
gps_pub2.append(lon);
// TODO: fill in rest of GPS message
gps_pub2.finish();
}
}
}
}
示例2: encodeTargetData
void encodeTargetData(uint8_t c){
if (gps.encode(c)){
float flat, flon;
unsigned long fix_age;
gps.f_get_position(&flat, &flon, &fix_age);
if (fix_age == TinyGPS::GPS_INVALID_AGE){
hasFix = false;
}
else if (fix_age > 5000){
hasFix = false;
}
else{
gps.get_position(&lat,&lon);
hasFix = true;
}
if(gps.altitude() != TinyGPS::GPS_INVALID_ALTITUDE) {
alt = (int16_t)gps.altitude();
hasAlt = true;
}else{
hasAlt = false;
}
}
}
示例3: read_gps
void read_gps(long lon, long lat)
{
while (Serial2.available())
{
TinyGPS gps;
int c = Serial2.read();
if (gps.encode(c))
{
unsigned long fix;
gps.get_position(&lat,&lon,&fix);
}
}
}
示例4: encodeTargetData
void encodeTargetData(uint8_t c) {
if (remoteGps.encode(c)) {
unsigned long fix_age;
remoteGps.get_position(&lat, &lon, &fix_age);
if (fix_age == TinyGPS::GPS_INVALID_AGE) {
HAS_FIX = false;
} else if (fix_age > 5000) {
HAS_FIX = false;
} else {
//TODO valid data
lat = lat / 10;
lon = lon / 10;
if (remoteGps.altitude() != TinyGPS::GPS_INVALID_ALTITUDE) {
alt = int16_t(remoteGps.altitude() / 100);
HAS_ALT = true;
}
HAS_FIX = true;
}
}
}
示例5: loop
void loop() {
static TinyGPS gps;
static unsigned long nextdisplay = millis();
if(Serial1.available()) {
gps.encode(Serial1.read());
}
if(millis() > nextdisplay) {
long lat, lon;
gps.get_position(&lat,&lon);
Serial.print(lat);
Serial.print(", ");
Serial.print(lon);
Serial.println();
nextdisplay = millis() + 1000;
}
}