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


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

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


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

示例1: getgps

void getgps(TinyGPS &gps) {
	// To get all of the data into varialbes that you can use in your code,
	// all you need to do is define variables and query the object for the
	// data. To see the complete list of functions see keywords.txt file in
	// the TinyGPS and NewSoftSerial libs.

	// Define the variables that will be used
	float latitude, longitude;
	// Then call this function
	gps.f_get_position(&latitude, &longitude);
	// You can now print variables latitude and longitude
	Serial.print("Lat/Long: ");
	Serial.print(latitude, 5);
	Serial.print(", ");
	Serial.println(longitude, 5);

	// Same goes for date and time
	int year;
	byte month, day, hour, minute, second, hundredths;
	gps.crack_datetime(&year, &month, &day, &hour, &minute, &second, &hundredths);
	// Print data and time
	Serial.print("Date: ");
	Serial.print(month, DEC);
	Serial.print("/");
	Serial.print(day, DEC);
	Serial.print("/");
	Serial.print(year);
	Serial.print("  Time: ");
	Serial.print(hour, DEC);
	Serial.print(":");
	Serial.print(minute, DEC);
	Serial.print(":");
	Serial.print(second, DEC);
	Serial.print(".");
	Serial.println(hundredths, DEC);
	//Since month, day, hour, minute, second, and hundr

	// Here you can print the altitude and course values directly since
	// there is only one value for the function
	Serial.print("Altitude (meters): ");
	Serial.println(gps.f_altitude());
	// Same goes for course
	Serial.print("Course (degrees): ");
	Serial.println(gps.f_course());
	// And same goes for speed
	Serial.print("Speed(kmph): ");
	Serial.println(gps.f_speed_kmph());
	Serial.println();

	// Here you can print statistics on the sentences.
	unsigned long chars;
	unsigned short sentences, failed_checksum;
	gps.stats(&chars, &sentences, &failed_checksum);
	//Serial.print("Failed Checksums: ");Serial.print(failed_checksum);
	//Serial.println(); Serial.println();
}
开发者ID:RBerliner,项目名称:freeboard-server,代码行数:56,代码来源:GpsSketch.c

示例2: main

int main(void) {    
    
    Config32MHzClock(); // Setup the 32MHz Clock. Should really be using 2MHz...
    
    // Setup output and input ports.
    LEDPORT.DIRSET = 0xFF; 
    LEDPORT.OUT = 0xFF;
    AD9835_PORT.DIRCLR = 0x40;
    PORTC.DIRSET = 0x04;

    // Start up the timer.
    init_timer();
    
    sensors.begin();
    sensors.requestTemperatures();
    
    // Wait a bit before starting the AD9835.
    // It seems to take a few hundred ms to 'boot up' once power is applied.
    _delay_ms(500); 
    
    // Configure the AD9835, and start in sleep mode.
    AD9835_Setup();
    AD9835_Sleep();
    
    // Setup the AD9835 for our chosen datamode.
    TX_Setup();
    AD9835_Awake();
    
    // Broadcast a bit of carrier.
    _delay_ms(1000);
    
    TXString("Booting up...\n"); // Kind of like debug lines.
    
    // Start up the GPS RX UART.
    init_gps();
    
    // Turn Interrupts on.
    PMIC.CTRL = PMIC_HILVLEN_bm | PMIC_LOLVLEN_bm;
    sei();
    
    sendNMEA("$PUBX,00"); // Poll the UBlox5 Chip for data.
    
    //TXString("GPS Active, Interrupts On.\n");
    
    int found_sensors = sensors.getDeviceCount();
    
    //sprintf(tx_buffer,"Found %u sensors.\n",found_sensors);
   // TXString(tx_buffer);
    unsigned int counter = 0; // Init out TX counter.
    
 
    while(1){
        // Identify every few minutes
        if ((counter%30 == 0)&&(data_mode != FALLBACK)) TXString("DE VK5VZI Project Horus HAB Launch - projecthorus.org \n");
    
	    // Read ADC PortA pin 0, using differential, signed input mode. Negative input comes from pin 1, which is tied to ground. Use VCC/1.6 as ref.
	    uint16_t temp = readADC(); 
	    float bat_voltage = (float)temp * 0.001007572056668* 8.5;
        floatToString(bat_voltage,1,voltString);
   
    
    
        // Collect GPS data
        
        gps.f_get_position(&lat, &lon);
	    sats = gps.sats();
	    if(sats>2){LEDPORT.OUTCLR = 0x80;}
	    speed = gps.f_speed_kmph();
	    altitude = (long)gps.f_altitude();
	    gps.crack_datetime(0, 0, 0, &time[0], &time[1], &time[2]);
	    
	    floatToString(lat, 5, latString);
	    floatToString(lon, 5, longString);
	    
        sensors.requestTemperatures();
        _intTemp = sensors.getTempC(internal);
        _extTemp = sensors.getTempC(external);
        if (_intTemp!=85 && _intTemp!=127 && _intTemp!=-127 && _intTemp!=999) intTemp = _intTemp;
        if (_extTemp!=85 && _extTemp!=127 && _extTemp!=-127 && _extTemp!=999) extTemp = _extTemp;
	    
	    if(data_mode != FALLBACK){
	    
            // Construct our Data String
            sprintf(tx_buffer,"$$DARKSIDE,%u,%02d:%02d:%02d,%s,%s,%ld,%d,%d,%d,%d,%s",counter++,time[0], time[1], time[2],latString,longString,altitude,speed,sats,intTemp,extTemp,voltString);
            
            
            // Calculate the CRC-16 Checksum
            char checksum[10];
            snprintf(checksum, sizeof(checksum), "*%04X\n", gps_CRC16_checksum(tx_buffer));
         
            // And copy the checksum onto the end of the string.
            memcpy(tx_buffer + strlen(tx_buffer), checksum, strlen(checksum) + 1);
        }else{
            // If our battery is really low, we don't want to transmit much data, so limit what we TX to just an identifier, battery voltage, and our position.
            
            sprintf(tx_buffer, "DE VK5VZI HORUS8 %s %s %s %ld", bat_voltage, latString, longString,altitude);
        }
        
        // Blinky blinky...
        LEDPORT.OUTTGL = 0x20;
//.........这里部分代码省略.........
开发者ID:malbel,项目名称:xmega-qrp,代码行数:101,代码来源:XMega_QRP.c


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