Beispiel #1
0
//*****************************************************************************
//
//! This is the Pulse Per Second (PPS) interrupt handler.
//! The updateCounter is incremented on each Pulse per second call, if equal to
//! the update rate, the GPS data is parsed and logged.
//
//*****************************************************************************
void PortKIntHandler(void) {
    uint32_t intStatus = 0;

    //
    // Get the current interrupt status for Port K
    //
    intStatus = GPIOIntStatus(GPIO_PORTK_BASE,true);

    //
    // Clear the set interrupts for Port K
    //
    GPIOIntClear(GPIO_PORTK_BASE,intStatus);

    //
    // Execute code for PK2 interrupt
    //
    if((intStatus & GPIO_INT_PIN_2) == GPIO_INT_PIN_2){
        if (updateRate == updateCounter++) {
            GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_1, 0x02);
            gpsData();
            GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_1, 0x00);
            updateCounter = 0;

            //
            // Disable PPS interrupt after one read if in low power mode
            //
            if (lowPowerOn == 1) {
                IntDisable(INT_GPIOK);
                logComplete = 1;
            }
        }
    }
} // End function PortKIntHandler
Beispiel #2
0
int GPSWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: gpsData((*reinterpret_cast< QGeoCoordinate(*)>(_a[1]))); break;
        case 1: positionUpdated((*reinterpret_cast< QGeoPositionInfo(*)>(_a[1]))); break;
        case 2: areaEntered((*reinterpret_cast< const QGeoPositionInfo(*)>(_a[1]))); break;
        case 3: areaExited((*reinterpret_cast< const QGeoPositionInfo(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 4;
    }
    return _id;
}
Beispiel #3
0
void GPSWidget::positionUpdated(QGeoPositionInfo geoPositionInfo)
{
    //qWarning("positionUpdated");
    if (geoPositionInfo.isValid())
    {
        // Stop regular position updates, because a valid position has been
        // obtained
        locationDataSource->stopUpdates();

        // Get the current location as latitude and longitude
        geoCoordinate_ = geoPositionInfo.coordinate();


        emit gpsData(geoCoordinate_);

        locationDataSource->startUpdates();// chamówa

    }
}
Beispiel #4
0
bool GPSDataParser::loadGPXFile(const KUrl& url)
{
    QFile gpxfile(url.path());

    if (!gpxfile.open(QIODevice::ReadOnly))
        return false;

    QDomDocument gpxDoc("gpx");
    if (!gpxDoc.setContent(&gpxfile))
        return false;

    QDomElement gpxDocElem = gpxDoc.documentElement();
    if (gpxDocElem.tagName()!="gpx")
        return false;

    for (QDomNode nTrk = gpxDocElem.firstChild();
         !nTrk.isNull(); nTrk = nTrk.nextSibling())
    {
        QDomElement trkElem = nTrk.toElement();
        if (trkElem.isNull()) continue;
        if (trkElem.tagName() != "trk") continue;

        for (QDomNode nTrkseg = trkElem.firstChild();
            !nTrkseg.isNull(); nTrkseg = nTrkseg.nextSibling())
        {
            QDomElement trksegElem = nTrkseg.toElement();
            if (trksegElem.isNull()) continue;
            if (trksegElem.tagName() != "trkseg") continue;

            for (QDomNode nTrkpt = trksegElem.firstChild();
                !nTrkpt.isNull(); nTrkpt = nTrkpt.nextSibling())
            {
                QDomElement trkptElem = nTrkpt.toElement();
                if (trkptElem.isNull()) continue;
                if (trkptElem.tagName() != "trkpt") continue;

                QDateTime ptDateTime;
                double    ptAltitude  = 0.0;
                double    ptLatitude  = 0.0;
                double    ptLongitude = 0.0;

                // Get GPS position. If not available continue to next point.
                QString lat = trkptElem.attribute("lat");
                QString lon = trkptElem.attribute("lon");
                if (lat.isEmpty() || lon.isEmpty()) continue;

                ptLatitude  = lat.toDouble();
                ptLongitude = lon.toDouble();

                // Get metadata of track point (altitude and time stamp)
                for (QDomNode nTrkptMeta = trkptElem.firstChild();
                    !nTrkptMeta.isNull(); nTrkptMeta = nTrkptMeta.nextSibling())
                {
                    QDomElement trkptMetaElem = nTrkptMeta.toElement();
                    if (trkptMetaElem.isNull()) continue;
                    if (trkptMetaElem.tagName() == QString("time"))
                    {
                        // Get GPS point time stamp. If not available continue to next point.
                        QString time = trkptMetaElem.text();
                        if (time.isEmpty()) continue;
                        ptDateTime = QDateTime::fromString(time, Qt::ISODate);
                    }
                    if (trkptMetaElem.tagName() == QString("ele"))
                    {
                        // Get GPS point altitude. If not available continue to next point.
                        QString ele = trkptMetaElem.text();
                        if (!ele.isEmpty())
                            ptAltitude  = ele.toDouble();
                    }
                }

                if (ptDateTime.isNull())
                    continue;

                GPSDataContainer gpsData(ptAltitude, ptLatitude, ptLongitude, false);
                m_GPSDataMap.insert( ptDateTime, gpsData );
            }
        }
    }

    kDebug( 51001 ) << "GPX File " << url.fileName()
                    << " parsed with " << numPoints()
                    << " points extracted" << endl;
    return true;
}
void readGPS()
{
	while(Serial.available() > 0)
	{
		char inChar = Serial.read();
		if(inChar == '$')
			counter = 0;
		NMEA[counter++] = inChar;
		//TODO: Calculate the checksum by using XOR and matching it?
		if(NMEA[5] == 'C' && NMEA[counter - 3] == '*')
		{
			GPS gpsData(NMEA);
			//print(gpsData);
			if(gpsData.isConnected())
			{
				if(deviceStatus == GPS_VIEW)
				{
					LCD.clear();
					//Draw Date
					if(gpsData.getMonth() < 10)
					{
						LCD.tText(0, 0, WHITE, "0");
						LCD.tText(1, 0, WHITE, gpsData.getMonth());
					}
					else
						LCD.tText(0, 0, WHITE, gpsData.getMonth());
					LCD.tText(2, 0, WHITE, "/");
					if(gpsData.getDay() < 10)
					{
						LCD.tText(3, 0, WHITE, "0");
						LCD.tText(4, 0, WHITE, gpsData.getDay());
					}
					else
						LCD.tText(3, 0, WHITE, gpsData.getDay());
					
					LCD.tText(5, 0, WHITE, "/");
					LCD.tText(6, 0, WHITE, 20);
					LCD.tText(8, 0, WHITE, gpsData.getYear());
					
					//Draw Time
					if(gpsData.getHour() < 10)
					{
						LCD.tText(0, 1, WHITE, "0");
						LCD.tText(1, 1, WHITE, gpsData.getHour());
					}
					else
						LCD.tText(0, 1, WHITE, gpsData.getHour());
					LCD.tText(2, 1, WHITE, ":");
					
					if(gpsData.getMinute() < 10)
					{
						LCD.tText(3, 1, WHITE, "0");
						LCD.tText(4, 1, WHITE, gpsData.getMinute());
					}
					else
						LCD.tText(3, 1, WHITE, gpsData.getMinute());
					LCD.tText(5, 1, WHITE, ":");
					
					if(gpsData.getSecond() < 10)
					{
						LCD.tText(6, 1, WHITE, "0");
						LCD.tText(7, 1, WHITE, gpsData.getSecond());
					}
					else
						LCD.tText(6, 1, WHITE, gpsData.getSecond());
					
					//Draw Latitude
					if(gpsData.getLatDegrees() < 10)
					{
						LCD.tText(0, 2, WHITE, "0");
						LCD.tText(0, 2, WHITE, gpsData.getLatDegrees());
					}
					else
						LCD.tText(0, 2, WHITE, gpsData.getLatDegrees());
					LCD.tText(2, 2, WHITE, "*");
					LCD.tText(5, 2, WHITE, gpsData.getLatMinutes());
					LCD.tText(10, 2, WHITE, "'");
					LCD.tText(11, 2, WHITE, gpsData.getLatHeading());
					
					//Draw Longitude
					if(gpsData.getLongDegrees() < 100)
					{
						if(gpsData.getLongDegrees() < 10)
						{
							LCD.tText(0, 3, WHITE, "00");
							LCD.tText(2, 3, WHITE, gpsData.getLongDegrees());
						}
						else
						{
							LCD.tText(0, 3, WHITE, "0");
							LCD.tText(1, 3, WHITE, gpsData.getLongDegrees());
						}
					}
					else
						LCD.tText(0, 3, WHITE, gpsData.getLongDegrees());
					LCD.tText(3, 3, WHITE, "*");
					LCD.tText(5, 3, WHITE, gpsData.getLongMinutes());
					LCD.tText(10, 3, WHITE, "'");
					LCD.tText(11, 3, WHITE, gpsData.getLongHeading());
				}
				
				if(writeToSD)
				{
					haveGPSData = true;
					String toWrite = gpsData.getMonth();
					LCD.appendString2File("Data", toWrite);
					toWrite = "/";
					LCD.appendString2File("Data", toWrite);
					toWrite = gpsData.getDay();
					LCD.appendString2File("Data", toWrite);
					toWrite = "/";
					LCD.appendString2File("Data", toWrite);
					toWrite = gpsData.getYear();
					LCD.appendString2File("Data", toWrite);
					toWrite = "\t";
					
					LCD.appendString2File("Data", toWrite);
					
					toWrite = gpsData.getHour();
					LCD.appendString2File("Data", toWrite);
					toWrite = ":";
					LCD.appendString2File("Data", toWrite);
					toWrite = gpsData.getMinute();
					LCD.appendString2File("Data", toWrite);
					toWrite = ":";
					LCD.appendString2File("Data", toWrite);
					toWrite = gpsData.getSecond();
					LCD.appendString2File("Data", toWrite);
					toWrite = "\t";
					LCD.appendString2File("Data", toWrite);
					
					toWrite = gpsData.getLongDegrees();
					LCD.appendString2File("Data", toWrite);
					toWrite = ".";
					LCD.appendString2File("Data", toWrite);
					toWrite = (long) (gpsData.getLongMinutes() / 60 * 1000000);
					LCD.appendString2File("Data", toWrite);
					toWrite = gpsData.getLongHeading();
					LCD.appendString2File("Data", toWrite);
					toWrite = "\t";
					LCD.appendString2File("Data", toWrite);
					
					toWrite = gpsData.getLatDegrees();
					LCD.appendString2File("Data", toWrite);
					toWrite = ".";
					LCD.appendString2File("Data", toWrite);
					toWrite = (long) (gpsData.getLatMinutes() / 60 * 1000000);
					LCD.appendString2File("Data", toWrite);
					toWrite = gpsData.getLatHeading();
					LCD.appendString2File("Data", toWrite);
					toWrite = "\t";
					LCD.appendString2File("Data", toWrite);
				}
			}
			else if(deviceStatus == GPS_VIEW)
			{
				LCD.tText(7, 7, WHITE, "NO GPS SIGNAL");
				haveGPSData = false;
			}
			else
				haveGPSData = false;
		}
		else if(counter >= 75)
			counter = 0;
	}
}