mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-03 11:24:10 +01:00
Some fixing/cleanup:
- Swap fix type and satelite count in UI. - Use QString for the packet signal, if it ever happens to be multithreaded signal/slot this will be better (And char* should perish :) ) - Make QString in the slots const and by reference, that seems to be preferred (const = safer, reference = faster). - Don't use 'new' QStrings in the nmea parser, not sot sure if that causes memory leakage, but it wouldn't surprise me. - Emit fix type updates from the (Serial) nmea parser. git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1550 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
609d215749
commit
c87ff38039
@ -105,7 +105,7 @@ void GpsDisplayGadget::loadConfiguration(IUAVGadgetConfiguration* config)
|
||||
connect(parser, SIGNAL(position(double,double,double)), m_widget,SLOT(setPosition(double,double,double)));
|
||||
connect(parser, SIGNAL(speedheading(double,double)), m_widget,SLOT(setSpeedHeading(double,double)));
|
||||
connect(parser, SIGNAL(datetime(double,double)), m_widget,SLOT(setDateTime(double,double)));
|
||||
connect(parser, SIGNAL(packet(char*)), m_widget, SLOT(dumpPacket(char*)));
|
||||
connect(parser, SIGNAL(packet(QString)), m_widget, SLOT(dumpPacket(QString)));
|
||||
connect(parser, SIGNAL(satellite(int,int,int,int,int)), m_widget->gpsSky, SLOT(updateSat(int,int,int,int,int)));
|
||||
connect(parser, SIGNAL(fixtype(QString)), m_widget, SLOT(setFixType(QString)));
|
||||
connect(parser, SIGNAL(dop(double,double,double)), m_widget, SLOT(setDOP(double,double,double)));
|
||||
|
@ -82,14 +82,24 @@ void GpsDisplayWidget::setDateTime(double date, double time)
|
||||
time_value->setText(dstring1 + " " + dstring2 + " GMT");
|
||||
}
|
||||
|
||||
void GpsDisplayWidget::setFixType(QString fixtype)
|
||||
void GpsDisplayWidget::setFixType(const QString &fixtype)
|
||||
{
|
||||
fix_value->setText(fixtype);
|
||||
if(fixtype =="NoGPS") {
|
||||
fix_value->setText("No GPS");
|
||||
} else if (fixtype == "NoFix") {
|
||||
fix_value->setText("Fix not available");
|
||||
} else if (fixtype == "Fix2D") {
|
||||
fix_value->setText("2D");
|
||||
} else if (fixtype =="Fix3D") {
|
||||
fix_value->setText("3D");
|
||||
} else {
|
||||
fix_value->setText("Unknown");
|
||||
}
|
||||
}
|
||||
|
||||
void GpsDisplayWidget::dumpPacket(char *packet)
|
||||
void GpsDisplayWidget::dumpPacket(const QString &packet)
|
||||
{
|
||||
textBrowser->append(QString(packet));
|
||||
textBrowser->append(packet);
|
||||
}
|
||||
|
||||
void GpsDisplayWidget::setSVs(int sv)
|
||||
|
@ -51,8 +51,8 @@ private slots:
|
||||
void setPosition(double, double, double);
|
||||
void setDateTime(double, double);
|
||||
void setSpeedHeading(double, double);
|
||||
void dumpPacket(char*);
|
||||
void setFixType(QString fixtype);
|
||||
void dumpPacket(const QString &packet);
|
||||
void setFixType(const QString &fixtype);
|
||||
void setDOP(double hdop, double vdop, double pdop);
|
||||
|
||||
private:
|
||||
|
@ -251,7 +251,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="fix_value">
|
||||
<widget class="QLabel" name="status_value">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
@ -281,7 +281,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="status_value">
|
||||
<widget class="QLabel" name="fix_value">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
|
@ -32,7 +32,6 @@
|
||||
#include <QtCore>
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
class GPSParser: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -48,9 +47,9 @@ signals:
|
||||
void position(double,double,double); // Lat, Lon, Alt
|
||||
void datetime(double,double); // Date then time
|
||||
void speedheading(double,double);
|
||||
void packet(char*); // Raw NMEA Packet (or just info)
|
||||
void packet(QString); // Raw NMEA Packet (or just info)
|
||||
void satellite(int,int,int,int,int); // Index, PRN, Elevation, Azimuth, SNR
|
||||
void fixtype(QString); // Type of fix (none, 2D, 3D, etc).
|
||||
void fixtype(QString); // Type of fix: "NoGPS", "NoFix", "Fix2D", "Fix3D".
|
||||
void dop(double, double, double); // HDOP, VDOP, PDOP
|
||||
|
||||
};
|
||||
|
@ -208,7 +208,7 @@ uint8_t NMEAParser::nmeaProcess(cBuffer* rxBuffer)
|
||||
#ifdef NMEA_DEBUG_PKT
|
||||
qDebug() << NmeaPacket;
|
||||
#endif
|
||||
emit packet(NmeaPacket);
|
||||
emit packet(QString(NmeaPacket));
|
||||
// found a packet
|
||||
// done with this processing session
|
||||
foundpacket = NMEA_UNKNOWN;
|
||||
@ -284,8 +284,8 @@ void NMEAParser::nmeaProcessGPGSV(char *packet)
|
||||
}
|
||||
nmeaTerminateAtChecksum(packet);
|
||||
|
||||
QString* nmeaString = new QString( packet );
|
||||
QStringList tokenslist = nmeaString->split(",");
|
||||
QString nmeaString( packet );
|
||||
QStringList tokenslist = nmeaString.split(",");
|
||||
|
||||
|
||||
// Officially there should be a max of three sentences (12 sats), some gps receivers do more..
|
||||
@ -333,8 +333,8 @@ void NMEAParser::nmeaProcessGPGGA(char* packet)
|
||||
}
|
||||
nmeaTerminateAtChecksum(packet);
|
||||
|
||||
QString* nmeaString = new QString( packet );
|
||||
QStringList tokenslist = nmeaString->split(",");
|
||||
QString nmeaString( packet );
|
||||
QStringList tokenslist = nmeaString.split(",");
|
||||
GpsData.GPStime = tokenslist.at(1).toDouble();
|
||||
GpsData.Latitude = tokenslist.at(2).toDouble();
|
||||
int deg = (int)GpsData.Latitude/100;
|
||||
@ -380,8 +380,8 @@ void NMEAParser::nmeaProcessGPRMC(char* packet)
|
||||
}
|
||||
nmeaTerminateAtChecksum(packet);
|
||||
|
||||
QString* nmeaString = new QString( packet );
|
||||
QStringList tokenslist = nmeaString->split(",");
|
||||
QString nmeaString( packet );
|
||||
QStringList tokenslist = nmeaString.split(",");
|
||||
GpsData.GPStime = tokenslist.at(1).toDouble();
|
||||
GpsData.Groundspeed = tokenslist.at(7).toDouble();
|
||||
GpsData.Groundspeed = GpsData.Groundspeed*0.51444;
|
||||
@ -410,8 +410,8 @@ void NMEAParser::nmeaProcessGPVTG(char* packet)
|
||||
}
|
||||
nmeaTerminateAtChecksum(packet);
|
||||
|
||||
QString* nmeaString = new QString( packet );
|
||||
QStringList tokenslist = nmeaString->split(",");
|
||||
QString nmeaString( packet );
|
||||
QStringList tokenslist = nmeaString.split(",");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -432,28 +432,26 @@ void NMEAParser::nmeaProcessGPGSA(char* packet)
|
||||
}
|
||||
nmeaTerminateAtChecksum(packet);
|
||||
|
||||
QString* nmeaString = new QString( packet );
|
||||
QStringList tokenslist = nmeaString->split(",");
|
||||
QString nmeaString( packet );
|
||||
QStringList tokenslist = nmeaString.split(",");
|
||||
// next field: Mode
|
||||
// Mode: 1=Fix not available, 2=2D, 3=3D
|
||||
int mode = tokenslist.at(2).toInt();
|
||||
/*if (mode == 1)
|
||||
if (mode == 1)
|
||||
{
|
||||
GpsData.Status = POSITIONACTUAL_STATUS_NOFIX;
|
||||
emit fixtype(QString("NoFix"));
|
||||
}
|
||||
else if (mode == 2)
|
||||
{
|
||||
GpsData.Status = POSITIONACTUAL_STATUS_FIX2D;
|
||||
emit fixtype(QString("Fix2D"));
|
||||
}
|
||||
else if (mode == 3)
|
||||
{
|
||||
GpsData.Status = POSITIONACTUAL_STATUS_FIX3D;
|
||||
}*/
|
||||
emit fixtype(QString("Fix3D"));
|
||||
}
|
||||
|
||||
GpsData.PDOP = tokenslist.at(15).toDouble();
|
||||
GpsData.HDOP = tokenslist.at(16).toDouble();
|
||||
GpsData.VDOP = tokenslist.at(17).toDouble();
|
||||
emit dop(GpsData.HDOP, GpsData.VDOP, GpsData.PDOP);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user