mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-20 10:54:14 +01:00
gpswidget outputs now something to the gui
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1229 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
516815807c
commit
d9d42ff068
@ -5,23 +5,23 @@ include(../../openpilotgcsplugin.pri)
|
|||||||
include(../../plugins/coreplugin/coreplugin.pri)
|
include(../../plugins/coreplugin/coreplugin.pri)
|
||||||
include(gpsdisplay_dependencies.pri)
|
include(gpsdisplay_dependencies.pri)
|
||||||
include(../../libs/qwt/qwt.pri)
|
include(../../libs/qwt/qwt.pri)
|
||||||
HEADERS += gpsdisplayplugin.h \
|
HEADERS += gpsdisplayplugin.h
|
||||||
buffer.h \
|
HEADERS += buffer.h
|
||||||
nmeaparser.h
|
HEADERS += nmeaparser.h
|
||||||
HEADERS += gpsdisplaygadget.h
|
HEADERS += gpsdisplaygadget.h
|
||||||
HEADERS += gpsdisplaywidget.h
|
HEADERS += gpsdisplaywidget.h
|
||||||
HEADERS += gpsdisplaygadgetfactory.h
|
HEADERS += gpsdisplaygadgetfactory.h
|
||||||
HEADERS += gpsdisplaygadgetconfiguration.h
|
HEADERS += gpsdisplaygadgetconfiguration.h
|
||||||
HEADERS += gpsdisplaygadgetoptionspage.h
|
HEADERS += gpsdisplaygadgetoptionspage.h
|
||||||
SOURCES += gpsdisplayplugin.cpp \
|
SOURCES += gpsdisplayplugin.cpp
|
||||||
buffer.cpp \
|
SOURCES += buffer.cpp
|
||||||
nmeaparser.cpp
|
SOURCES += nmeaparser.cpp
|
||||||
SOURCES += gpsdisplaygadget.cpp
|
SOURCES += gpsdisplaygadget.cpp
|
||||||
SOURCES += gpsdisplaygadgetfactory.cpp
|
SOURCES += gpsdisplaygadgetfactory.cpp
|
||||||
SOURCES += gpsdisplaywidget.cpp
|
SOURCES += gpsdisplaywidget.cpp
|
||||||
SOURCES += gpsdisplaygadgetconfiguration.cpp
|
SOURCES += gpsdisplaygadgetconfiguration.cpp
|
||||||
SOURCES += gpsdisplaygadgetoptionspage.cpp
|
SOURCES += gpsdisplaygadgetoptionspage.cpp
|
||||||
OTHER_FILES += GpsDisplayGadget.pluginspec
|
OTHER_FILES += GpsDisplayGadget.pluginspec
|
||||||
FORMS += gpsdisplaygadgetoptionspage.ui \
|
FORMS += gpsdisplaygadgetoptionspage.ui
|
||||||
gpsdisplaywidget.ui
|
FORMS += gpsdisplaywidget.ui
|
||||||
RESOURCES += widgetresources.qrc
|
RESOURCES += widgetresources.qrc
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
#include "uavobjects/uavobjectmanager.h"
|
#include "uavobjects/uavobjectmanager.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <QtGui/QFileDialog>
|
#include <QtGui>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include "nmeaparser.h"
|
#include "nmeaparser.h"
|
||||||
@ -44,12 +44,11 @@ public:
|
|||||||
QextSerialPort *port;
|
QextSerialPort *port;
|
||||||
NMEAParser *parser;
|
NMEAParser *parser;
|
||||||
void setPort(QextSerialPort* port);
|
void setPort(QextSerialPort* port);
|
||||||
|
void setParser(NMEAParser* parser);
|
||||||
void processInputStream();
|
void processInputStream();
|
||||||
void run();
|
void run();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize the widget
|
* Initialize the widget
|
||||||
*/
|
*/
|
||||||
@ -77,9 +76,12 @@ GpsDisplayWidget::GpsDisplayWidget(QWidget *parent) : QWidget(parent)
|
|||||||
widget->gpsWorld->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
|
widget->gpsWorld->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
|
||||||
world->setScale(factor);
|
world->setScale(factor);
|
||||||
|
|
||||||
|
|
||||||
connect(widget->connectButton, SIGNAL(clicked(bool)),
|
connect(widget->connectButton, SIGNAL(clicked(bool)),
|
||||||
this,SLOT(connectButtonClicked()));
|
this,SLOT(connectButtonClicked()));
|
||||||
|
parser=new NMEAParser();
|
||||||
|
connect(parser,SIGNAL(sv(int)),this,SLOT(setSVs(int)));
|
||||||
|
connect(parser,SIGNAL(position(double,double,double)),this,SLOT(setPosition(double,double,double)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GpsDisplayWidget::~GpsDisplayWidget()
|
GpsDisplayWidget::~GpsDisplayWidget()
|
||||||
@ -87,6 +89,24 @@ GpsDisplayWidget::~GpsDisplayWidget()
|
|||||||
delete widget;
|
delete widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GpsDisplayWidget::setSVs(int sv)
|
||||||
|
{
|
||||||
|
QString temp = "FIX: ";
|
||||||
|
temp.append(QString::number(sv));
|
||||||
|
widget->label_2->setText(temp);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GpsDisplayWidget::setPosition(double lat, double lon, double alt)
|
||||||
|
{
|
||||||
|
QString temp = "Position: ";
|
||||||
|
temp.append(QString::number(lat));
|
||||||
|
temp.append(" ");
|
||||||
|
temp.append(QString::number(lon));
|
||||||
|
temp.append(" ");
|
||||||
|
temp.append(QString::number(alt));
|
||||||
|
widget->label->setText(temp);
|
||||||
|
widget->textBrowser->append(temp);
|
||||||
|
}
|
||||||
|
|
||||||
void GpsDisplayWidget::setPort(QextSerialPort* port)
|
void GpsDisplayWidget::setPort(QextSerialPort* port)
|
||||||
{
|
{
|
||||||
@ -96,26 +116,35 @@ void GpsDisplayWidget::setPort(QextSerialPort* port)
|
|||||||
|
|
||||||
void GpsDisplayWidget::connectButtonClicked() {
|
void GpsDisplayWidget::connectButtonClicked() {
|
||||||
GpsDisplayThread* gpsThread = new GpsDisplayThread();
|
GpsDisplayThread* gpsThread = new GpsDisplayThread();
|
||||||
|
widget->textBrowser->append(QString("Connecting to GPS ...\n"));
|
||||||
gpsThread->setPort(port);
|
gpsThread->setPort(port);
|
||||||
|
gpsThread->setParser(parser);
|
||||||
gpsThread->start();
|
gpsThread->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void GpsDisplayThread::setPort(QextSerialPort* port)
|
void GpsDisplayThread::setPort(QextSerialPort* port)
|
||||||
{
|
{
|
||||||
|
|
||||||
this->port=port;
|
this->port=port;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GpsDisplayThread::setParser(NMEAParser* parser)
|
||||||
|
{
|
||||||
|
|
||||||
|
this->parser=parser;
|
||||||
|
}
|
||||||
|
|
||||||
void GpsDisplayThread::run()
|
void GpsDisplayThread::run()
|
||||||
{
|
{
|
||||||
|
|
||||||
qDebug() << "Opening.";
|
qDebug() << "Opening.";
|
||||||
|
|
||||||
qDebug() << port->portName();
|
qDebug() << port->portName();
|
||||||
|
|
||||||
bool isOpen = port->open(QIODevice::ReadWrite);
|
bool isOpen = port->open(QIODevice::ReadWrite);
|
||||||
qDebug() << "Open: " << isOpen;
|
qDebug() << "Open: " << isOpen;
|
||||||
parser=new NMEAParser();
|
|
||||||
|
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
char c;
|
char c;
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
#include "nmeaparser.h"
|
||||||
|
|
||||||
class Ui_GpsDisplayWidget;
|
class Ui_GpsDisplayWidget;
|
||||||
|
|
||||||
@ -49,13 +50,17 @@ public:
|
|||||||
|
|
||||||
// void setMode(QString mode); // Either UAVTalk or serial port
|
// void setMode(QString mode); // Either UAVTalk or serial port
|
||||||
void setPort(QextSerialPort* port);
|
void setPort(QextSerialPort* port);
|
||||||
|
void setParser(NMEAParser *parser);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void connectButtonClicked();
|
void connectButtonClicked();
|
||||||
|
void setSVs(int);
|
||||||
|
void setPosition(double, double, double);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui_GpsDisplayWidget* widget;
|
Ui_GpsDisplayWidget* widget;
|
||||||
QextSerialPort *port;
|
QextSerialPort *port;
|
||||||
|
NMEAParser *parser;
|
||||||
bool connected;
|
bool connected;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -33,12 +33,21 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>10</x>
|
<x>10</x>
|
||||||
<y>10</y>
|
<y>10</y>
|
||||||
<width>46</width>
|
<width>251</width>
|
||||||
<height>13</height>
|
<height>16</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Position:</string>
|
<string>Position: </string>
|
||||||
|
</property>
|
||||||
|
<property name="indent">
|
||||||
|
<number>-1</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLabel" name="label_2">
|
<widget class="QLabel" name="label_2">
|
||||||
@ -46,12 +55,18 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>10</x>
|
<x>10</x>
|
||||||
<y>30</y>
|
<y>30</y>
|
||||||
<width>46</width>
|
<width>61</width>
|
||||||
<height>13</height>
|
<height>16</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Fix:</string>
|
<string>Fix: </string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLabel" name="label_3">
|
<widget class="QLabel" name="label_3">
|
||||||
@ -59,8 +74,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>10</x>
|
<x>10</x>
|
||||||
<y>50</y>
|
<y>50</y>
|
||||||
<width>46</width>
|
<width>111</width>
|
||||||
<height>13</height>
|
<height>16</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -72,8 +87,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>150</x>
|
<x>150</x>
|
||||||
<y>50</y>
|
<y>50</y>
|
||||||
<width>46</width>
|
<width>111</width>
|
||||||
<height>13</height>
|
<height>16</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -85,8 +100,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>90</x>
|
<x>90</x>
|
||||||
<y>30</y>
|
<y>30</y>
|
||||||
<width>46</width>
|
<width>161</width>
|
||||||
<height>13</height>
|
<height>16</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -98,8 +113,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>10</x>
|
<x>10</x>
|
||||||
<y>70</y>
|
<y>70</y>
|
||||||
<width>46</width>
|
<width>121</width>
|
||||||
<height>13</height>
|
<height>16</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -27,6 +27,13 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "nmeaparser.h"
|
#include "nmeaparser.h"
|
||||||
|
#include <iostream>
|
||||||
|
#include <math.h>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QStringList>
|
||||||
|
#include <QtGui/QWidget>
|
||||||
|
#include <QtGui/QVBoxLayout>
|
||||||
|
#include <QtGui/QPushButton>
|
||||||
|
|
||||||
// Message Codes
|
// Message Codes
|
||||||
#define NMEA_NODATA 0 // No data. Packet not available, bad, or not decoded
|
#define NMEA_NODATA 0 // No data. Packet not available, bad, or not decoded
|
||||||
@ -56,12 +63,17 @@
|
|||||||
/**
|
/**
|
||||||
* Initialize the parser
|
* Initialize the parser
|
||||||
*/
|
*/
|
||||||
NMEAParser::NMEAParser()
|
NMEAParser::NMEAParser(QObject *parent):QObject(parent)
|
||||||
{
|
{
|
||||||
bufferInit(&gpsRxBuffer, (unsigned char *)gpsRxData, 512);
|
bufferInit(&gpsRxBuffer, (unsigned char *)gpsRxData, 512);
|
||||||
gpsRxOverflow=0;
|
gpsRxOverflow=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NMEAParser::~NMEAParser()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called each time there are data in the input buffer
|
* Called each time there are data in the input buffer
|
||||||
*/
|
*/
|
||||||
@ -251,10 +263,12 @@ void NMEAParser::nmeaProcessGPGGA(char* packet)
|
|||||||
|
|
||||||
QString* nmeaString = new QString( packet );
|
QString* nmeaString = new QString( packet );
|
||||||
QStringList tokenslist = nmeaString->split(",");
|
QStringList tokenslist = nmeaString->split(",");
|
||||||
GpsData.Latitude = tokenslist.at(2).toFloat();
|
GpsData.Latitude = tokenslist.at(2).toDouble();
|
||||||
GpsData.Longitude = tokenslist.at(4).toFloat();
|
GpsData.Longitude = tokenslist.at(4).toDouble();
|
||||||
GpsData.Altitude = tokenslist.at(9).toFloat();
|
GpsData.Altitude = tokenslist.at(9).toDouble();
|
||||||
GpsData.SV = tokenslist.at(7).toInt();
|
GpsData.SV = tokenslist.at(7).toInt();
|
||||||
|
emit position(GpsData.Latitude,GpsData.Longitude,GpsData.Altitude);
|
||||||
|
emit sv(GpsData.SV);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -276,7 +290,7 @@ void NMEAParser::nmeaProcessGPRMC(char* packet)
|
|||||||
|
|
||||||
QString* nmeaString = new QString( packet );
|
QString* nmeaString = new QString( packet );
|
||||||
QStringList tokenslist = nmeaString->split(",");
|
QStringList tokenslist = nmeaString->split(",");
|
||||||
GpsData.Groundspeed = tokenslist.at(7).toFloat();
|
GpsData.Groundspeed = tokenslist.at(7).toDouble();
|
||||||
GpsData.Groundspeed = GpsData.Groundspeed*0.51444;
|
GpsData.Groundspeed = GpsData.Groundspeed*0.51444;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#ifndef NMEAPARSER_H
|
#ifndef NMEAPARSER_H
|
||||||
#define NMEAPARSER_H
|
#define NMEAPARSER_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
#include <QtCore>
|
#include <QtCore>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "buffer.h"
|
#include "buffer.h"
|
||||||
@ -37,10 +38,10 @@
|
|||||||
|
|
||||||
typedef struct struct_GpsData
|
typedef struct struct_GpsData
|
||||||
{
|
{
|
||||||
float Latitude;
|
double Latitude;
|
||||||
float Longitude;
|
double Longitude;
|
||||||
float Altitude;
|
double Altitude;
|
||||||
float Groundspeed;
|
double Groundspeed;
|
||||||
int SV;
|
int SV;
|
||||||
uint8_t channel;
|
uint8_t channel;
|
||||||
uint8_t value_h;
|
uint8_t value_h;
|
||||||
@ -48,10 +49,12 @@ typedef struct struct_GpsData
|
|||||||
uint8_t sum;
|
uint8_t sum;
|
||||||
}GpsData_t;
|
}GpsData_t;
|
||||||
|
|
||||||
class NMEAParser
|
class NMEAParser: public QObject
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
NMEAParser();
|
NMEAParser(QObject *parent = 0);
|
||||||
|
~NMEAParser();
|
||||||
void processInputStream(char c);
|
void processInputStream(char c);
|
||||||
char* nmeaGetPacketBuffer(void);
|
char* nmeaGetPacketBuffer(void);
|
||||||
char nmeaChecksum(char* gps_buffer);
|
char nmeaChecksum(char* gps_buffer);
|
||||||
@ -67,6 +70,10 @@ public:
|
|||||||
uint32_t numUpdates;
|
uint32_t numUpdates;
|
||||||
uint32_t numErrors;
|
uint32_t numErrors;
|
||||||
int32_t gpsRxOverflow;
|
int32_t gpsRxOverflow;
|
||||||
|
signals:
|
||||||
|
void sv(int);
|
||||||
|
void position(double,double,double);
|
||||||
|
private slots:
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // NMEAPARSER_H
|
#endif // NMEAPARSER_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user