当前位置: 首页>>代码示例>>C++>>正文


C++ TinyGPS::encode方法代码示例

本文整理汇总了C++中TinyGPS::encode方法的典型用法代码示例。如果您正苦于以下问题:C++ TinyGPS::encode方法的具体用法?C++ TinyGPS::encode怎么用?C++ TinyGPS::encode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TinyGPS的用法示例。


在下文中一共展示了TinyGPS::encode方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: loop

void loop() {
	bool newData = false;
	unsigned long start = millis();
	while (millis() - start < 1000) {
		while (nss.available()) {
			if (gps.encode(nss.read()))
				newData = true;
		}
	}

	if (newData) {
		if (gps.hdop() < MAX_HDOP)
			signal_fixed_status();
		else
			signal_instable_status();

		if (!gps_filename) {
			gps_filename = create_gps_file();
		}

		String line = create_gps_line();
		gps_filename.println(line);
		gps_filename.flush();

		Serial.println(line);
	} else {
		signal_unavailable_status();
	}
}
开发者ID:leandroxk,项目名称:arduino,代码行数:29,代码来源:gps_logger.cpp

示例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;
    }
  }
}
开发者ID:Overtuner,项目名称:open360tracker,代码行数:25,代码来源:gps.cpp

示例3: gps_get_data

char gps_get_data() {
    float lat, lon = 0.0;
    unsigned long fixAge = 0;
    char uart_buffer[512] = {};
    int ctr = 0;

    uart_init(9600);// The default baud rate for this GPS device is 9600

    uart_read(uart_buffer, sizeof(uart_buffer));
    while (uart_buffer[ctr] != NULL){
        char charRead = uart_buffer[ctr];
        GPSDevice.encode(charRead);
        if ((charRead == ',') && (GPSDevice._term_number == 1)) {
            itsAGPRMCMessage = !GPSDevice.gpsstrcmp(GPSDevice._term, _GPRMC_TERM);
        }

        if ((charRead == 'A' || charRead == 'V') && itsAGPRMCMessage) {
            dataStatus = charRead;
            itsAGPRMCMessage = 0;
        }
        ctr++;
    }
    GPSDevice.f_get_position(&lat, &lon, &fixAge);
    printf("lat: %.4f\t", lat);
    printf("lon: %.4f\t", lon);
    printf("alt: %.1f\t", GPSDevice.f_altitude());
    printf("sta: %c\n", dataStatus);

    return dataStatus;
}
开发者ID:masantana,项目名称:MakersCasco,代码行数:30,代码来源:GPS.cpp

示例4:

void MXS2201::get_info(float *latitude, float *longitude, float *altitude,float *speed_mps,int *year, byte *month, byte *day,
		byte *hour, byte *minute, byte *second,byte *hundredths,unsigned long *fix_age)
{
	bool newData = false;


	// For one second we parse GPS data and report some key values
	for (unsigned long start = millis(); millis() - start < 1500;)
	{
		while (_mySerial.available())
		{
			char c = _mySerial.read();
			if (gps.encode(c)) // Did a new valid sentence come in?
				newData = true;
		}
	}

	if (newData)
	{
		gps.f_get_position(latitude,longitude,fix_age);
		gps.crack_datetime(year, month, day,
				hour, minute, second,hundredths,fix_age );
		*altitude=gps.f_altitude();
		*speed_mps=gps.f_speed_mps();
		return;
	}
}
开发者ID:cherishyou,项目名称:ArduinoLib-SMeshlink,代码行数:27,代码来源:MXS2201.cpp

示例5: 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();
         }
      } 
   }
}
开发者ID:trainman419,项目名称:dagny_firmware,代码行数:26,代码来源:gps.cpp

示例6: gps_readable

//Check if we can read new GPS data (keep check for about 0.5 seconds) and return true or false.
bool gps_readable() {
    bool new_data = false;
    for (unsigned long start = time(NULL); time(NULL) - start < 0.5;) {
        while (gps_ser.readable()) {
            char c = gps_ser.getc();
            //printf("%c",c);
            if (gps.encode(c)) new_data = true;
        }
    }
    return new_data;
}
开发者ID:bharad6,项目名称:arm_hab_controller,代码行数:12,代码来源:main.cpp

示例7: 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);
    }
  }
}
开发者ID:space-concordia-robotics,项目名称:robotics-rover,代码行数:13,代码来源:GPS.cpp

示例8: gps_update

void gps_update(float *latitude, float *longitude, unsigned long *time) {
	static const int cum_days[] = {
		0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334
	};

	int year;
	unsigned long age;
	byte month, day, hour, minute, second, centisecond;

	while(Serial1.available())
		gps.encode(Serial1.read());

	gps.f_get_position(latitude,longitude);
	gps.crack_datetime(&year,&month,&day,&hour,&minute,&second,
		&centisecond,&age);

	*time = ((((year - 1970)*365 + cum_days[month])*24 + hour)*60
		+ minute)*60 + second + (10*centisecond + age)/1000;
}
开发者ID:kevinriehm,项目名称:evt-black-box,代码行数:19,代码来源:gps.cpp

示例9: 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;
    }
  }
}
开发者ID:SamuelBrucksch,项目名称:open360tracker,代码行数:22,代码来源:gps.cpp

示例10: 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;
	}
}
开发者ID:kevinriehm,项目名称:evt-black-box,代码行数:22,代码来源:gps_test.cpp

示例11: loop

void loop() {
	int delayMillis = 10000;
	for (int i = 0; i < baudRates.length(); i++) {
		uart_gps.begin(baudRates[i]);
		int startMillis = millis();
		while ((millis() - startMillis) < delayMillis) {
			while (uart_gps.available()) // While there is data on the RX pin...
			{
				int c = uart_gps.read(); // load the data into a variable...
				Serial.print("baud = ");
				Serial.print(baudRates[i], DEC);
				Serial.print(" ");
				Serial.print(c);
				Serial.println();
				if (gps.encode(c)) // if there is a new valid sentence...
				{
					getgps(gps); // then grab the data.
				}
			}
		}
	}
}
开发者ID:RBerliner,项目名称:freeboard-server,代码行数:22,代码来源:GpsSketch.c

示例12: check_gps

char check_gps()
{
  newData=false;
  unsigned long chars;
  unsigned short sentences, failed;

  // For one second we parse GPS data and report some key values
  for (unsigned long start = millis(); millis() - start < 1000;)
  {
    while (Serial2.available())
    {
      char c = Serial2.read();
      // Serial.write(c); // uncomment this line if you want to see the GPS data flowing
      if (gps.encode(c)) // Did a new valid sentence come in?
        newData = true;
    }
  }

  if (newData)
  {
    float flat, flon;
    unsigned long age;
    int _year;
    byte _month, _day,_hour,_minute,_second,_hundredths;        
    gps.f_get_position(&flat, &flon, &age);
        gps.crack_datetime(&_year,&_month,&_day,&_hour,&_minute,&_second,&_hundredths,&age);
        flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6;
        flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6;
    dtostrf(flat, 11, 6, gps_lat); 
    dtostrf(flon, 10, 6, gps_lon); 
        
        strcpy(gps_sms,"lat:");
        strcat(gps_sms,gps_lat);
        strcat(gps_sms,"\n");
        strcat(gps_sms,"lon:");
        strcat(gps_sms,gps_lon);
        strcat(gps_sms,"\n");
        strcat(gps_sms,"time:");
        
    itoa(_year,gps_year,10);
    strcat(gps_sms,gps_year);
        
    itoa(_month,gps_mon,10);
    if(strlen(gps_mon)==1)
      strcat(gps_sms,"0");
    strcat(gps_sms,gps_mon);
        
    itoa(_day,gps_day,10);
        if(strlen(gps_day)==1)
      strcat(gps_sms,"0");
    strcat(gps_sms,gps_day);
        
    itoa(_hour,gps_hour,10);
        if(strlen(gps_hour)==1)
      strcat(gps_sms,"0");
    strcat(gps_sms,gps_hour);
        
    itoa(_minute,gps_min,10);
        if(strlen(gps_min)==1)
      strcat(gps_sms,"0");
    strcat(gps_sms,gps_min);
        
    itoa(_second,gps_sec,10);
        if(strlen(gps_sec)==1)
      strcat(gps_sms,"0");
    strcat(gps_sms,gps_sec);        
        
    Serial.println(gps_sms);


  }
  



}
开发者ID:wetnt,项目名称:Arduino_public,代码行数:76,代码来源:SIM908a.c


注:本文中的TinyGPS::encode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。