22 changed files with 16 additions and 1648 deletions
@ -1,53 +0,0 @@
@@ -1,53 +0,0 @@
|
||||
/*=====================================================================
|
||||
|
||||
APM_PLANNER Open Source Ground Control Station |
||||
|
||||
(c) 2013, Bill Bonney <billbonney@communistech.com> |
||||
|
||||
This file is part of the APM_PLANNER project |
||||
|
||||
APM_PLANNER is free software: you can redistribute it and/or modify |
||||
it under the terms of the GNU General Public License as published by |
||||
the Free Software Foundation, either version 3 of the License, or |
||||
(at your option) any later version. |
||||
|
||||
APM_PLANNER is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU General Public License for more details. |
||||
|
||||
You should have received a copy of the GNU General Public License |
||||
along with APM_PLANNER. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
======================================================================*/ |
||||
|
||||
/**
|
||||
* @file |
||||
* @brief APM Highligther for ArduPilot Console. |
||||
* |
||||
* @author Bill Bonney <billbonney@communistech.com> |
||||
* |
||||
*/ |
||||
|
||||
#include "ApmHighlighter.h" |
||||
|
||||
APMHighlighter::APMHighlighter(QObject *parent) : |
||||
QSyntaxHighlighter(parent) |
||||
{ |
||||
} |
||||
|
||||
void APMHighlighter::highlightBlock(const QString &text) |
||||
{ |
||||
QTextCharFormat myClassFormat; |
||||
myClassFormat.setFontWeight(QFont::Bold); |
||||
myClassFormat.setForeground(Qt::darkMagenta); |
||||
QString pattern = "^\\Ardu[A-Za-z]+\\b"; |
||||
|
||||
QRegExp expression(pattern); |
||||
int index = text.indexOf(expression); |
||||
while (index >= 0) { |
||||
int length = expression.matchedLength(); |
||||
setFormat(index, length, myClassFormat); |
||||
index = text.indexOf(expression, index + length); |
||||
} |
||||
} |
@ -1,51 +0,0 @@
@@ -1,51 +0,0 @@
|
||||
/*=====================================================================
|
||||
|
||||
APM_PLANNER Open Source Ground Control Station |
||||
|
||||
(c) 2013, Bill Bonney <billbonney@communistech.com> |
||||
|
||||
This file is part of the APM_PLANNER project |
||||
|
||||
APM_PLANNER is free software: you can redistribute it and/or modify |
||||
it under the terms of the GNU General Public License as published by |
||||
the Free Software Foundation, either version 3 of the License, or |
||||
(at your option) any later version. |
||||
|
||||
APM_PLANNER is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU General Public License for more details. |
||||
|
||||
You should have received a copy of the GNU General Public License |
||||
along with APM_PLANNER. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
======================================================================*/ |
||||
|
||||
/**
|
||||
* @file |
||||
* @brief APM Highligther for ArduPilot Console. |
||||
* |
||||
* @author Bill Bonney <billbonney@communistech.com> |
||||
* |
||||
*/ |
||||
|
||||
#ifndef APMHIGHLIGHTER_H |
||||
#define APMHIGHLIGHTER_H |
||||
|
||||
#include "ApmHighlighter.h" |
||||
#include <QSyntaxHighlighter> |
||||
|
||||
class APMHighlighter : public QSyntaxHighlighter |
||||
{ |
||||
Q_OBJECT |
||||
public: |
||||
explicit APMHighlighter(QObject *parent = 0); |
||||
void highlightBlock(const QString &text); |
||||
|
||||
signals: |
||||
|
||||
public slots: |
||||
|
||||
}; |
||||
|
||||
#endif // APMHIGHLIGHTER_H
|
@ -1,143 +0,0 @@
@@ -1,143 +0,0 @@
|
||||
#include "ParamWidget.h" |
||||
|
||||
ParamWidget::ParamWidget(QString param,QWidget *parent) : QWidget(parent) |
||||
{ |
||||
ui.setupUi(this); |
||||
m_param = param; |
||||
|
||||
connect(ui.doubleSpinBox,SIGNAL(editingFinished()),this,SLOT(doubleSpinEditFinished())); |
||||
connect(ui.intSpinBox,SIGNAL(editingFinished()),this,SLOT(intSpinEditFinished())); |
||||
connect(ui.valueComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(comboIndexChanged(int))); |
||||
connect(ui.valueSlider,SIGNAL(sliderReleased()),this,SLOT(valueSliderReleased())); |
||||
} |
||||
void ParamWidget::doubleSpinEditFinished() |
||||
{ |
||||
ui.valueSlider->setValue(((ui.doubleSpinBox->value() - m_min) / (m_max - m_min)) * 100.0); |
||||
emit doubleValueChanged(m_param,ui.doubleSpinBox->value()); |
||||
} |
||||
|
||||
void ParamWidget::intSpinEditFinished() |
||||
{ |
||||
ui.valueSlider->setValue(((ui.intSpinBox->value() - m_min) / (m_max - m_min)) * 100.0); |
||||
emit intValueChanged(m_param,ui.intSpinBox->value()); |
||||
} |
||||
|
||||
void ParamWidget::comboIndexChanged(int index) |
||||
{ |
||||
emit intValueChanged(m_param,m_valueList[index].first); |
||||
} |
||||
|
||||
void ParamWidget::valueSliderReleased() |
||||
{ |
||||
//Set the spin box, and emit a signal.
|
||||
if (type == INT) |
||||
{ |
||||
ui.intSpinBox->setValue(((ui.valueSlider->value() / 100.0) * (m_max - m_min)) + m_min); |
||||
emit intValueChanged(m_param,ui.intSpinBox->value()); |
||||
} |
||||
else if (type == DOUBLE) |
||||
{ |
||||
ui.doubleSpinBox->setValue(((ui.valueSlider->value() / 100.0) * (m_max - m_min)) + m_min); |
||||
emit doubleValueChanged(m_param,ui.doubleSpinBox->value()); |
||||
} |
||||
} |
||||
|
||||
ParamWidget::~ParamWidget() |
||||
{ |
||||
} |
||||
|
||||
void ParamWidget::setupInt(QString title,QString description,int value,int min,int max) |
||||
{ |
||||
Q_UNUSED(value); |
||||
|
||||
type = INT; |
||||
ui.titleLabel->setText("<h3>" + title + "</h3>"); |
||||
ui.descriptionLabel->setText(description); |
||||
ui.valueComboBox->hide(); |
||||
ui.valueSlider->show(); |
||||
ui.intSpinBox->show(); |
||||
ui.doubleSpinBox->hide(); |
||||
if (min == 0 && max == 0) |
||||
{ |
||||
m_min = 0; |
||||
m_max = 65535; |
||||
} |
||||
else |
||||
{ |
||||
m_min = min; |
||||
m_max = max; |
||||
} |
||||
ui.intSpinBox->setMinimum(m_min); |
||||
ui.intSpinBox->setMaximum(m_max); |
||||
} |
||||
|
||||
void ParamWidget::setupDouble(QString title,QString description,double value,double min,double max) |
||||
{ |
||||
Q_UNUSED(value); |
||||
|
||||
type = DOUBLE; |
||||
ui.titleLabel->setText("<h3>" + title + "</h3>"); |
||||
ui.descriptionLabel->setText(description); |
||||
ui.valueComboBox->hide(); |
||||
ui.valueSlider->show(); |
||||
ui.intSpinBox->hide(); |
||||
ui.doubleSpinBox->show(); |
||||
if (min == 0 && max == 0) |
||||
{ |
||||
m_min = 0; |
||||
m_max = 65535; |
||||
} |
||||
else |
||||
{ |
||||
m_min = min; |
||||
m_max = max; |
||||
} |
||||
ui.doubleSpinBox->setMinimum(m_min); |
||||
ui.doubleSpinBox->setMaximum(m_max); |
||||
} |
||||
|
||||
void ParamWidget::setupCombo(QString title,QString description,QList<QPair<int,QString> > list) |
||||
{ |
||||
type = COMBO; |
||||
ui.titleLabel->setText("<h3>" + title + "</h3>"); |
||||
ui.descriptionLabel->setText(description); |
||||
ui.valueComboBox->show(); |
||||
ui.valueSlider->hide(); |
||||
ui.intSpinBox->hide(); |
||||
ui.doubleSpinBox->hide(); |
||||
m_valueList = list; |
||||
ui.valueComboBox->clear(); |
||||
disconnect(ui.valueComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(comboIndexChanged(int))); |
||||
for (int i=0;i<m_valueList.size();i++) |
||||
{ |
||||
ui.valueComboBox->addItem(m_valueList[i].second); |
||||
} |
||||
connect(ui.valueComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(comboIndexChanged(int))); |
||||
} |
||||
|
||||
void ParamWidget::setValue(double value) |
||||
{ |
||||
if (type == INT) |
||||
{ |
||||
ui.intSpinBox->setValue(value); |
||||
ui.valueSlider->setValue(((value - m_min) / (m_max - m_min)) * 100.0); |
||||
} |
||||
else if (type == DOUBLE) |
||||
{ |
||||
ui.doubleSpinBox->setValue(value); |
||||
ui.valueSlider->setValue(((value - m_min) / (m_max - m_min)) * 100.0); |
||||
} |
||||
else if (type == COMBO) |
||||
{ |
||||
for (int i=0;i<m_valueList.size();i++) |
||||
{ |
||||
if ((int)value == m_valueList[i].first) |
||||
{ |
||||
disconnect(ui.valueComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(comboIndexChanged(int))); |
||||
ui.valueComboBox->setCurrentIndex(i); |
||||
connect(ui.valueComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(comboIndexChanged(int))); |
||||
return; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,43 +0,0 @@
@@ -1,43 +0,0 @@
|
||||
#ifndef PARAMWIDGET_H |
||||
#define PARAMWIDGET_H |
||||
|
||||
#include <QWidget> |
||||
#include "ui_ParamWidget.h" |
||||
|
||||
class ParamWidget : public QWidget |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
explicit ParamWidget(QString param,QWidget *parent = 0); |
||||
~ParamWidget(); |
||||
void setupInt(QString title,QString description,int value,int min,int max); |
||||
void setupDouble(QString title,QString description,double value,double min,double max); |
||||
void setupCombo(QString title,QString description,QList<QPair<int,QString> > list); |
||||
void setValue(double value); |
||||
signals: |
||||
void doubleValueChanged(QString param,double value); |
||||
void intValueChanged(QString param,int value); |
||||
private slots: |
||||
void doubleSpinEditFinished(); |
||||
void intSpinEditFinished(); |
||||
void comboIndexChanged(int index); |
||||
void valueSliderReleased(); |
||||
private: |
||||
QString m_param; |
||||
enum VIEWTYPE |
||||
{ |
||||
INT, |
||||
DOUBLE, |
||||
COMBO |
||||
}; |
||||
double m_min; |
||||
double m_max; |
||||
double m_dvalue; |
||||
int m_ivalue; |
||||
VIEWTYPE type; |
||||
QList<QPair<int,QString> > m_valueList; |
||||
Ui::ParamWidget ui; |
||||
}; |
||||
|
||||
#endif // PARAMWIDGET_H
|
@ -1,81 +0,0 @@
@@ -1,81 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<ui version="4.0"> |
||||
<class>ParamWidget</class> |
||||
<widget class="QWidget" name="ParamWidget"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>0</x> |
||||
<y>0</y> |
||||
<width>619</width> |
||||
<height>207</height> |
||||
</rect> |
||||
</property> |
||||
<property name="windowTitle"> |
||||
<string>Form</string> |
||||
</property> |
||||
<layout class="QHBoxLayout" name="horizontalLayout_2"> |
||||
<item> |
||||
<layout class="QVBoxLayout" name="verticalLayout"> |
||||
<item> |
||||
<widget class="QLabel" name="titleLabel"> |
||||
<property name="text"> |
||||
<string>TextLabel</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QLabel" name="descriptionLabel"> |
||||
<property name="text"> |
||||
<string>TextLabel</string> |
||||
</property> |
||||
<property name="wordWrap"> |
||||
<bool>true</bool> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<layout class="QHBoxLayout" name="horizontalLayout"> |
||||
<item> |
||||
<widget class="QSpinBox" name="intSpinBox"/> |
||||
</item> |
||||
<item> |
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox"/> |
||||
</item> |
||||
<item> |
||||
<widget class="QSlider" name="valueSlider"> |
||||
<property name="maximum"> |
||||
<number>100</number> |
||||
</property> |
||||
<property name="value"> |
||||
<number>0</number> |
||||
</property> |
||||
<property name="orientation"> |
||||
<enum>Qt::Horizontal</enum> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QComboBox" name="valueComboBox"/> |
||||
</item> |
||||
</layout> |
||||
</item> |
||||
</layout> |
||||
</item> |
||||
<item> |
||||
<spacer name="horizontalSpacer"> |
||||
<property name="orientation"> |
||||
<enum>Qt::Horizontal</enum> |
||||
</property> |
||||
<property name="sizeHint" stdset="0"> |
||||
<size> |
||||
<width>40</width> |
||||
<height>20</height> |
||||
</size> |
||||
</property> |
||||
</spacer> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
<resources/> |
||||
<connections/> |
||||
</ui> |
@ -1,194 +0,0 @@
@@ -1,194 +0,0 @@
|
||||
/*=====================================================================
|
||||
|
||||
APM_PLANNER Open Source Ground Control Station |
||||
|
||||
(c) 2013, Bill Bonney <billbonney@communistech.com> |
||||
|
||||
This file is part of the APM_PLANNER project |
||||
|
||||
APM_PLANNER is free software: you can redistribute it and/or modify |
||||
it under the terms of the GNU General Public License as published by |
||||
the Free Software Foundation, either version 3 of the License, or |
||||
(at your option) any later version. |
||||
|
||||
APM_PLANNER is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU General Public License for more details. |
||||
|
||||
You should have received a copy of the GNU General Public License |
||||
along with APM_PLANNER. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
======================================================================*/ |
||||
|
||||
/**
|
||||
* @file |
||||
* @brief Serial Settings View. |
||||
* |
||||
* @author Bill Bonney <billbonney@communistech.com> |
||||
* |
||||
* Influenced from Qt examples by :- |
||||
* Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com> |
||||
* Copyright (C) 2012 Laszlo Papp <lpapp@kde.org> |
||||
* |
||||
*/ |
||||
|
||||
#include "SerialSettingsDialog.h" |
||||
#include "terminalconsole.h" |
||||
#include "ui_SerialSettingsDialog.h" |
||||
|
||||
#ifdef __android__ |
||||
#include "qserialport.h" |
||||
#include "qserialportinfo.h" |
||||
#else |
||||
#include <QSerialPort> |
||||
#include <QSerialPortInfo> |
||||
#endif |
||||
#include <QIntValidator> |
||||
#include <QLineEdit> |
||||
|
||||
QT_USE_NAMESPACE |
||||
|
||||
SerialSettingsDialog::SerialSettingsDialog(QWidget *parent) : |
||||
QDialog(parent), |
||||
ui(new Ui::SerialSettingsDialog) |
||||
{ |
||||
ui->setupUi(this); |
||||
|
||||
m_intValidator = new QIntValidator(0, 4000000, this); |
||||
|
||||
ui->baudRateBox->setInsertPolicy(QComboBox::NoInsert); |
||||
|
||||
connect(ui->applyButton, SIGNAL(clicked()), |
||||
this, SLOT(apply())); |
||||
connect(ui->serialPortInfoListBox, SIGNAL(currentIndexChanged(int)), |
||||
this, SLOT(showPortInfo(int))); |
||||
connect(ui->baudRateBox, SIGNAL(currentIndexChanged(int)), |
||||
this, SLOT(checkCustomBaudRatePolicy(int))); |
||||
|
||||
fillPortsParameters(); |
||||
fillPortsInfo(); |
||||
|
||||
updateSettings(); |
||||
} |
||||
|
||||
SerialSettingsDialog::~SerialSettingsDialog() |
||||
{ |
||||
delete ui; |
||||
} |
||||
|
||||
const SerialSettings& SerialSettingsDialog::settings() const |
||||
{ |
||||
return m_currentSettings; |
||||
} |
||||
|
||||
void SerialSettingsDialog::showPortInfo(int idx) |
||||
{ |
||||
if (idx != -1) { |
||||
QStringList list = ui->serialPortInfoListBox->itemData(idx).toStringList(); |
||||
ui->descriptionLabel->setText(tr("Description: %1").arg(list.at(1))); |
||||
ui->manufacturerLabel->setText(tr("Manufacturer: %1").arg(list.at(2))); |
||||
ui->locationLabel->setText(tr("Location: %1").arg(list.at(3))); |
||||
ui->vidLabel->setText(tr("Vendor Identifier: %1").arg(list.at(4))); |
||||
ui->pidLabel->setText(tr("Product Identifier: %1").arg(list.at(5))); |
||||
} |
||||
} |
||||
|
||||
void SerialSettingsDialog::apply() |
||||
{ |
||||
updateSettings(); |
||||
hide(); |
||||
} |
||||
|
||||
void SerialSettingsDialog::checkCustomBaudRatePolicy(int idx) |
||||
{ |
||||
bool isCustomBaudRate = !ui->baudRateBox->itemData(idx).isValid(); |
||||
ui->baudRateBox->setEditable(isCustomBaudRate); |
||||
if (isCustomBaudRate) { |
||||
ui->baudRateBox->clearEditText(); |
||||
QLineEdit *edit = ui->baudRateBox->lineEdit(); |
||||
edit->setValidator(m_intValidator); |
||||
} |
||||
} |
||||
|
||||
void SerialSettingsDialog::fillPortsParameters() |
||||
{ |
||||
// fill baud rate (is not the entire list of available values,
|
||||
// desired values??, add your independently)
|
||||
ui->baudRateBox->addItem(QLatin1String("115200"), QSerialPort::Baud115200); |
||||
ui->baudRateBox->addItem(QLatin1String("57600"), QSerialPort::Baud57600); |
||||
ui->baudRateBox->addItem(QLatin1String("38400"), QSerialPort::Baud38400); |
||||
ui->baudRateBox->addItem(QLatin1String("19200"), QSerialPort::Baud19200); |
||||
ui->baudRateBox->addItem(QLatin1String("19200"), QSerialPort::Baud19200); |
||||
ui->baudRateBox->addItem(QLatin1String("9600"), QSerialPort::Baud9600); |
||||
ui->baudRateBox->addItem(QLatin1String("Custom")); |
||||
|
||||
// fill data bits
|
||||
ui->dataBitsBox->addItem(QLatin1String("5"), QSerialPort::Data5); |
||||
ui->dataBitsBox->addItem(QLatin1String("6"), QSerialPort::Data6); |
||||
ui->dataBitsBox->addItem(QLatin1String("7"), QSerialPort::Data7); |
||||
ui->dataBitsBox->addItem(QLatin1String("8"), QSerialPort::Data8); |
||||
ui->dataBitsBox->setCurrentIndex(3); |
||||
|
||||
// fill parity
|
||||
ui->parityBox->addItem(QLatin1String("None"), QSerialPort::NoParity); |
||||
ui->parityBox->addItem(QLatin1String("Even"), QSerialPort::EvenParity); |
||||
ui->parityBox->addItem(QLatin1String("Odd"), QSerialPort::OddParity); |
||||
ui->parityBox->addItem(QLatin1String("Mark"), QSerialPort::MarkParity); |
||||
ui->parityBox->addItem(QLatin1String("Space"), QSerialPort::SpaceParity); |
||||
|
||||
// fill stop bits
|
||||
ui->stopBitsBox->addItem(QLatin1String("1"), QSerialPort::OneStop); |
||||
#ifdef Q_OS_WIN |
||||
ui->stopBitsBox->addItem(QLatin1String("1.5"), QSerialPort::OneAndHalfStop); |
||||
#endif |
||||
ui->stopBitsBox->addItem(QLatin1String("2"), QSerialPort::TwoStop); |
||||
|
||||
// fill flow control
|
||||
ui->flowControlBox->addItem(QLatin1String("None"), QSerialPort::NoFlowControl); |
||||
ui->flowControlBox->addItem(QLatin1String("RTS/CTS"), QSerialPort::HardwareControl); |
||||
ui->flowControlBox->addItem(QLatin1String("XON/XOFF"), QSerialPort::SoftwareControl); |
||||
} |
||||
|
||||
void SerialSettingsDialog::fillPortsInfo() |
||||
{ |
||||
ui->serialPortInfoListBox->clear(); |
||||
foreach (const QSerialPortInfo &info, QSerialPortInfo::availablePorts()) { |
||||
QStringList list; |
||||
list << info.portName() |
||||
<< info.description() |
||||
<< info.manufacturer() |
||||
<< info.systemLocation() |
||||
<< (info.vendorIdentifier() ? QString::number(info.vendorIdentifier(), 16) : QString()) |
||||
<< (info.productIdentifier() ? QString::number(info.productIdentifier(), 16) : QString()); |
||||
|
||||
ui->serialPortInfoListBox->insertItem(0, list.first(), list); |
||||
} |
||||
} |
||||
|
||||
void SerialSettingsDialog::updateSettings() |
||||
{ |
||||
m_currentSettings.name = ui->serialPortInfoListBox->currentText(); |
||||
|
||||
// Baud Rate
|
||||
if (ui->baudRateBox->currentIndex() == 4) { |
||||
// custom baud rate
|
||||
m_currentSettings.baudRate = ui->baudRateBox->currentText().toInt(); |
||||
} else { |
||||
// standard baud rate
|
||||
m_currentSettings.baudRate = static_cast<QSerialPort::BaudRate>( |
||||
ui->baudRateBox->itemData(ui->baudRateBox->currentIndex()).toInt()); |
||||
} |
||||
// Data bits
|
||||
m_currentSettings.dataBits = static_cast<QSerialPort::DataBits>( |
||||
ui->dataBitsBox->itemData(ui->dataBitsBox->currentIndex()).toInt()); |
||||
// Parity
|
||||
m_currentSettings.parity = static_cast<QSerialPort::Parity>( |
||||
ui->parityBox->itemData(ui->parityBox->currentIndex()).toInt()); |
||||
// Stop bits
|
||||
m_currentSettings.stopBits = static_cast<QSerialPort::StopBits>( |
||||
ui->stopBitsBox->itemData(ui->stopBitsBox->currentIndex()).toInt()); |
||||
// Flow control
|
||||
m_currentSettings.flowControl = static_cast<QSerialPort::FlowControl>( |
||||
ui->flowControlBox->itemData(ui->flowControlBox->currentIndex()).toInt()); |
||||
} |
@ -1,95 +0,0 @@
@@ -1,95 +0,0 @@
|
||||
/*=====================================================================
|
||||
|
||||
APM_PLANNER Open Source Ground Control Station |
||||
|
||||
(c) 2013, Bill Bonney <billbonney@communistech.com> |
||||
|
||||
This file is part of the APM_PLANNER project |
||||
|
||||
APM_PLANNER is free software: you can redistribute it and/or modify |
||||
it under the terms of the GNU General Public License as published by |
||||
the Free Software Foundation, either version 3 of the License, or |
||||
(at your option) any later version. |
||||
|
||||
APM_PLANNER is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU General Public License for more details. |
||||
|
||||
You should have received a copy of the GNU General Public License |
||||
along with APM_PLANNER. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
======================================================================*/ |
||||
|
||||
/**
|
||||
* @file |
||||
* @brief Serial Settings View. |
||||
* |
||||
* @author Bill Bonney <billbonney@communistech.com> |
||||
* |
||||
* Influenced from Qt examples by :- |
||||
* Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com> |
||||
* Copyright (C) 2012 Laszlo Papp <lpapp@kde.org> |
||||
* |
||||
*/ |
||||
|
||||
#ifndef SERIALSETTINGSDIALOG_H |
||||
#define SERIALSETTINGSDIALOG_H |
||||
|
||||
#include <QDialog> |
||||
#ifdef __android__ |
||||
#include "qserialport.h" |
||||
#else |
||||
#include <QSerialPort> |
||||
#endif |
||||
|
||||
namespace Ui { |
||||
class SerialSettingsDialog; |
||||
} |
||||
|
||||
class QIntValidator; |
||||
|
||||
class SerialSettings { |
||||
public: |
||||
SerialSettings() : name(""), |
||||
baudRate(115200), |
||||
dataBits(QSerialPort::Data8), |
||||
parity(QSerialPort::NoParity), |
||||
stopBits(QSerialPort::OneStop), |
||||
flowControl(QSerialPort::NoFlowControl){} |
||||
public: |
||||
QString name; |
||||
qint32 baudRate; |
||||
QSerialPort::DataBits dataBits; |
||||
QSerialPort::Parity parity; |
||||
QSerialPort::StopBits stopBits; |
||||
QSerialPort::FlowControl flowControl; |
||||
}; |
||||
|
||||
class SerialSettingsDialog : public QDialog |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
explicit SerialSettingsDialog(QWidget *parent = 0); |
||||
~SerialSettingsDialog(); |
||||
|
||||
const SerialSettings &settings() const; |
||||
|
||||
private slots: |
||||
void showPortInfo(int idx); |
||||
void apply(); |
||||
void checkCustomBaudRatePolicy(int idx); |
||||
|
||||
private: |
||||
void fillPortsParameters(); |
||||
void fillPortsInfo(); |
||||
void updateSettings(); |
||||
|
||||
private: |
||||
Ui::SerialSettingsDialog *ui; |
||||
SerialSettings m_currentSettings; |
||||
QIntValidator *m_intValidator; |
||||
}; |
||||
|
||||
#endif |
@ -1,151 +0,0 @@
@@ -1,151 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<ui version="4.0"> |
||||
<class>SerialSettingsDialog</class> |
||||
<widget class="QDialog" name="SerialSettingsDialog"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>0</x> |
||||
<y>0</y> |
||||
<width>401</width> |
||||
<height>250</height> |
||||
</rect> |
||||
</property> |
||||
<property name="windowTitle"> |
||||
<string>Settings</string> |
||||
</property> |
||||
<layout class="QGridLayout" name="gridLayout_3"> |
||||
<item row="0" column="0"> |
||||
<widget class="QGroupBox" name="selectBox"> |
||||
<property name="title"> |
||||
<string>Select Serial Port</string> |
||||
</property> |
||||
<layout class="QGridLayout" name="gridLayout"> |
||||
<item row="0" column="0"> |
||||
<widget class="QComboBox" name="serialPortInfoListBox"/> |
||||
</item> |
||||
<item row="1" column="0"> |
||||
<widget class="QLabel" name="descriptionLabel"> |
||||
<property name="text"> |
||||
<string>Description:</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="2" column="0"> |
||||
<widget class="QLabel" name="manufacturerLabel"> |
||||
<property name="text"> |
||||
<string>Manufacturer:</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="3" column="0"> |
||||
<widget class="QLabel" name="locationLabel"> |
||||
<property name="text"> |
||||
<string>Location:</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="4" column="0"> |
||||
<widget class="QLabel" name="vidLabel"> |
||||
<property name="text"> |
||||
<string>Vendor ID:</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="5" column="0"> |
||||
<widget class="QLabel" name="pidLabel"> |
||||
<property name="text"> |
||||
<string>Product ID:</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
</item> |
||||
<item row="1" column="0" colspan="2"> |
||||
<layout class="QHBoxLayout" name="horizontalLayout"> |
||||
<item> |
||||
<spacer name="horizontalSpacer"> |
||||
<property name="orientation"> |
||||
<enum>Qt::Horizontal</enum> |
||||
</property> |
||||
<property name="sizeHint" stdset="0"> |
||||
<size> |
||||
<width>96</width> |
||||
<height>20</height> |
||||
</size> |
||||
</property> |
||||
</spacer> |
||||
</item> |
||||
<item> |
||||
<widget class="QPushButton" name="applyButton"> |
||||
<property name="text"> |
||||
<string>Apply</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</item> |
||||
<item row="0" column="1"> |
||||
<widget class="QGroupBox" name="parametersBox"> |
||||
<property name="title"> |
||||
<string>Select Parameters</string> |
||||
</property> |
||||
<layout class="QGridLayout" name="gridLayout_2"> |
||||
<item row="0" column="0"> |
||||
<widget class="QLabel" name="baudRateLabel"> |
||||
<property name="text"> |
||||
<string>BaudRate:</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="0" column="1"> |
||||
<widget class="QComboBox" name="baudRateBox"/> |
||||
</item> |
||||
<item row="1" column="0"> |
||||
<widget class="QLabel" name="dataBitsLabel"> |
||||
<property name="text"> |
||||
<string>Data bits:</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="1" column="1"> |
||||
<widget class="QComboBox" name="dataBitsBox"/> |
||||
</item> |
||||
<item row="2" column="0"> |
||||
<widget class="QLabel" name="parityLabel"> |
||||
<property name="text"> |
||||
<string>Parity:</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="2" column="1"> |
||||
<widget class="QComboBox" name="parityBox"/> |
||||
</item> |
||||
<item row="3" column="0"> |
||||
<widget class="QLabel" name="stopBitsLabel"> |
||||
<property name="text"> |
||||
<string>Stop bits:</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="3" column="1"> |
||||
<widget class="QComboBox" name="stopBitsBox"/> |
||||
</item> |
||||
<item row="4" column="0"> |
||||
<widget class="QLabel" name="flowControlLabel"> |
||||
<property name="text"> |
||||
<string>Flow control:</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item row="4" column="1"> |
||||
<widget class="QComboBox" name="flowControlBox"/> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
<resources/> |
||||
<connections/> |
||||
</ui> |
@ -1,14 +0,0 @@
@@ -1,14 +0,0 @@
|
||||
#include "terminalconsole.h" |
||||
#include "ui_terminalconsole.h" |
||||
|
||||
TerminalConsole::TerminalConsole(QWidget *parent) : |
||||
QWidget(parent), |
||||
ui(new Ui::TerminalConsole) |
||||
{ |
||||
ui->setupUi(this); |
||||
} |
||||
|
||||
TerminalConsole::~TerminalConsole() |
||||
{ |
||||
delete ui; |
||||
} |
@ -1,101 +0,0 @@
@@ -1,101 +0,0 @@
|
||||
/*=====================================================================
|
||||
|
||||
APM_PLANNER Open Source Ground Control Station |
||||
|
||||
(c) 2013, Bill Bonney <billbonney@communistech.com> |
||||
|
||||
This file is part of the APM_PLANNER project |
||||
|
||||
APM_PLANNER is free software: you can redistribute it and/or modify |
||||
it under the terms of the GNU General Public License as published by |
||||
the Free Software Foundation, either version 3 of the License, or |
||||
(at your option) any later version. |
||||
|
||||
APM_PLANNER is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU General Public License for more details. |
||||
|
||||
You should have received a copy of the GNU General Public License |
||||
along with APM_PLANNER. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
======================================================================*/ |
||||
|
||||
/**
|
||||
* @file |
||||
* @brief Text Console. |
||||
* |
||||
* @author Bill Bonney <billbonney@communistech.com> |
||||
* |
||||
* Influenced from Qt examples by :- |
||||
* Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com> |
||||
* Copyright (C) 2012 Laszlo Papp <lpapp@kde.org> |
||||
* |
||||
*/ |
||||
|
||||
#include "console.h" |
||||
#include "ApmHighlighter.h" |
||||
|
||||
#include <QScrollBar> |
||||
|
||||
#include <QtCore/QDebug> |
||||
|
||||
Console::Console(QWidget *parent) |
||||
: QPlainTextEdit(parent) |
||||
, localEchoEnabled(false) |
||||
{ |
||||
document()->setMaximumBlockCount(100); |
||||
QPalette p = palette(); |
||||
p.setColor(QPalette::Base, Qt::black); |
||||
p.setColor(QPalette::Text, Qt::green); |
||||
setPalette(p); |
||||
|
||||
m_highlighter = new APMHighlighter(document()); |
||||
|
||||
} |
||||
|
||||
void Console::putData(const QByteArray &data) |
||||
{ |
||||
insertPlainText(QString(data)); |
||||
|
||||
QScrollBar *bar = verticalScrollBar(); |
||||
bar->setValue(bar->maximum()); |
||||
} |
||||
|
||||
void Console::setLocalEchoEnabled(bool set) |
||||
{ |
||||
localEchoEnabled = set; |
||||
} |
||||
|
||||
void Console::keyPressEvent(QKeyEvent *e) |
||||
{ |
||||
switch (e->key()) { |
||||
case Qt::Key_Backspace: |
||||
case Qt::Key_Left: |
||||
case Qt::Key_Right: |
||||
case Qt::Key_Up: |
||||
case Qt::Key_Down: |
||||
// skip processing
|
||||
break; |
||||
default: |
||||
if (localEchoEnabled) |
||||
QPlainTextEdit::keyPressEvent(e); |
||||
emit getData(e->text().toLocal8Bit()); |
||||
} |
||||
} |
||||
|
||||
void Console::mousePressEvent(QMouseEvent *e) |
||||
{ |
||||
Q_UNUSED(e) |
||||
setFocus(); |
||||
} |
||||
|
||||
void Console::mouseDoubleClickEvent(QMouseEvent *e) |
||||
{ |
||||
Q_UNUSED(e) |
||||
} |
||||
|
||||
void Console::contextMenuEvent(QContextMenuEvent *e) |
||||
{ |
||||
Q_UNUSED(e) |
||||
} |
@ -1,69 +0,0 @@
@@ -1,69 +0,0 @@
|
||||
/*=====================================================================
|
||||
|
||||
APM_PLANNER Open Source Ground Control Station |
||||
|
||||
(c) 2013, Bill Bonney <billbonney@communistech.com> |
||||
|
||||
This file is part of the APM_PLANNER project |
||||
|
||||
APM_PLANNER is free software: you can redistribute it and/or modify |
||||
it under the terms of the GNU General Public License as published by |
||||
the Free Software Foundation, either version 3 of the License, or |
||||
(at your option) any later version. |
||||
|
||||
APM_PLANNER is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU General Public License for more details. |
||||
|
||||
You should have received a copy of the GNU General Public License |
||||
along with APM_PLANNER. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
======================================================================*/ |
||||
|
||||
/**
|
||||
* @file |
||||
* @brief Text Console. |
||||
* |
||||
* @author Bill Bonney <billbonney@communistech.com> |
||||
* |
||||
* Influenced from Qt examples by :- |
||||
* Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com> |
||||
* Copyright (C) 2012 Laszlo Papp <lpapp@kde.org> |
||||
* |
||||
*/ |
||||
|
||||
#ifndef CONSOLE_H |
||||
#define CONSOLE_H |
||||
|
||||
#include <QPlainTextEdit> |
||||
|
||||
class APMHighlighter; |
||||
|
||||
class Console : public QPlainTextEdit |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
signals: |
||||
void getData(const QByteArray &data); |
||||
|
||||
public: |
||||
explicit Console(QWidget *parent = 0); |
||||
|
||||
void putData(const QByteArray &data); |
||||
|
||||
void setLocalEchoEnabled(bool set); |
||||
|
||||
protected: |
||||
virtual void keyPressEvent(QKeyEvent *e); |
||||
virtual void mousePressEvent(QMouseEvent *e); |
||||
virtual void mouseDoubleClickEvent(QMouseEvent *e); |
||||
virtual void contextMenuEvent(QContextMenuEvent *e); |
||||
|
||||
private: |
||||
bool localEchoEnabled; |
||||
APMHighlighter* m_highlighter; |
||||
|
||||
}; |
||||
|
||||
#endif // CONSOLE_H
|
@ -1,305 +0,0 @@
@@ -1,305 +0,0 @@
|
||||
/*=====================================================================
|
||||
|
||||
APM_PLANNER Open Source Ground Control Station |
||||
|
||||
(c) 2013, Bill Bonney <billbonney@communistech.com> |
||||
|
||||
This file is part of the APM_PLANNER project |
||||
|
||||
APM_PLANNER is free software: you can redistribute it and/or modify |
||||
it under the terms of the GNU General Public License as published by |
||||
the Free Software Foundation, either version 3 of the License, or |
||||
(at your option) any later version. |
||||
|
||||
APM_PLANNER is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU General Public License for more details. |
||||
|
||||
You should have received a copy of the GNU General Public License |
||||
along with APM_PLANNER. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
======================================================================*/ |
||||
|
||||
/**
|
||||
* @file |
||||
* @brief Terminal Console display View. |
||||
* |
||||
* @author Bill Bonney <billbonney@communistech.com> |
||||
* |
||||
* Influenced from Qt examples by :- |
||||
* Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com> |
||||
* Copyright (C) 2012 Laszlo Papp <lpapp@kde.org> |
||||
* |
||||
*/ |
||||
|
||||
#include "SerialSettingsDialog.h" |
||||
#include "terminalconsole.h" |
||||
#include "ui_terminalconsole.h" |
||||
#include "console.h" |
||||
#include "QGCConfig.h" |
||||
#include "QGCMessageBox.h" |
||||
|
||||
#include <QDebug> |
||||
#include <QSettings> |
||||
#include <QStatusBar> |
||||
#include <QVBoxLayout> |
||||
#include <QComboBox> |
||||
#ifdef __android__ |
||||
#include "qserialport.h" |
||||
#include "qserialportinfo.h" |
||||
#else |
||||
#include <QSerialPort> |
||||
#include <QSerialPortInfo> |
||||
#endif |
||||
|
||||
TerminalConsole::TerminalConsole(QWidget *parent) : |
||||
QWidget(parent), |
||||
ui(new Ui::TerminalConsole), |
||||
m_consoleMode(APM) |
||||
{ |
||||
ui->setupUi(this); |
||||
|
||||
// create the cosole and add it to the centralwidget
|
||||
m_console = new Console; |
||||
m_console->setEnabled(false); |
||||
|
||||
m_statusBar = new QStatusBar; |
||||
|
||||
QLayout* layout = ui->terminalGroupBox->layout(); |
||||
layout->addWidget(m_console); |
||||
layout->addWidget(m_statusBar); |
||||
|
||||
m_serial = new QSerialPort(this); |
||||
m_settingsDialog = new SerialSettingsDialog; |
||||
|
||||
ui->connectButton->setEnabled(true); |
||||
ui->disconnectButton->setEnabled(false); |
||||
ui->settingsButton->setEnabled(true); |
||||
|
||||
|
||||
addBaudComboBoxConfig(); |
||||
fillPortsInfo(*ui->linkComboBox); |
||||
|
||||
loadSettings(); |
||||
|
||||
if (m_settings.name == "") { |
||||
setLink(ui->linkComboBox->currentIndex()); |
||||
} else { |
||||
ui->linkComboBox->setCurrentIndex(0); |
||||
} |
||||
|
||||
addConsoleModesComboBoxConfig(); |
||||
|
||||
initConnections(); |
||||
} |
||||
|
||||
void TerminalConsole::addBaudComboBoxConfig() |
||||
{ |
||||
ui->consoleModeBox->addItem(QLatin1String("APM"), APM); |
||||
ui->consoleModeBox->addItem(QLatin1String("PX4"), PX4); |
||||
} |
||||
|
||||
void TerminalConsole::addConsoleModesComboBoxConfig() |
||||
{ |
||||
ui->baudComboBox->addItem(QLatin1String("115200"), QSerialPort::Baud115200); |
||||
ui->baudComboBox->addItem(QLatin1String("57600"), QSerialPort::Baud57600); |
||||
ui->baudComboBox->addItem(QLatin1String("38400"), QSerialPort::Baud38400); |
||||
ui->baudComboBox->addItem(QLatin1String("19200"), QSerialPort::Baud19200); |
||||
ui->baudComboBox->addItem(QLatin1String("19200"), QSerialPort::Baud19200); |
||||
ui->baudComboBox->addItem(QLatin1String("9600"), QSerialPort::Baud9600); |
||||
} |
||||
|
||||
void TerminalConsole::fillPortsInfo(QComboBox &comboxBox) |
||||
{ |
||||
comboxBox.clear(); |
||||
foreach (const QSerialPortInfo &info, QSerialPortInfo::availablePorts()) { |
||||
QStringList list; |
||||
list << info.portName() |
||||
<< info.description() |
||||
<< info.manufacturer() |
||||
<< info.systemLocation() |
||||
<< (info.vendorIdentifier() ? QString::number(info.vendorIdentifier(), 16) : QString()) |
||||
<< (info.productIdentifier() ? QString::number(info.productIdentifier(), 16) : QString()); |
||||
|
||||
comboxBox.insertItem(0,list.first(), list); |
||||
//qDebug() << "Inserting " << list.first();
|
||||
} |
||||
} |
||||
|
||||
TerminalConsole::~TerminalConsole() |
||||
{ |
||||
delete m_console; |
||||
delete m_statusBar; |
||||
delete m_settingsDialog; |
||||
delete ui; |
||||
} |
||||
|
||||
void TerminalConsole::openSerialPort() |
||||
{ |
||||
openSerialPort(m_settings); |
||||
} |
||||
|
||||
void TerminalConsole::openSerialPort(const SerialSettings &settings) |
||||
{ |
||||
m_serial->setPortName(settings.name); |
||||
if (m_serial->open(QIODevice::ReadWrite)) { |
||||
if (m_serial->setBaudRate(settings.baudRate) |
||||
&& m_serial->setDataBits(settings.dataBits) |
||||
&& m_serial->setParity(settings.parity) |
||||
&& m_serial->setStopBits(settings.stopBits) |
||||
&& m_serial->setFlowControl(settings.flowControl)) { |
||||
|
||||
m_console->setEnabled(true); |
||||
m_console->setLocalEchoEnabled(false); |
||||
ui->connectButton->setEnabled(false); |
||||
ui->disconnectButton->setEnabled(true); |
||||
ui->settingsButton->setEnabled(false); |
||||
m_statusBar->showMessage(tr("Connected to %1 : baud %2z") |
||||
.arg(settings.name).arg(QString::number(settings.baudRate))); |
||||
qDebug() << "Open Terminal Console Serial Port"; |
||||
writeSettings(); // Save last successful connection
|
||||
|
||||
sendResetCommand(); |
||||
|
||||
} else { |
||||
m_serial->close(); |
||||
QGCMessageBox::critical(tr("Error"), m_serial->errorString()); |
||||
|
||||
m_statusBar->showMessage(tr("Open error")); |
||||
} |
||||
} else { |
||||
QGCMessageBox::critical(tr("Error"), m_serial->errorString()); |
||||
|
||||
m_statusBar->showMessage(tr("Configure error")); |
||||
} |
||||
} |
||||
|
||||
void TerminalConsole::closeSerialPort() |
||||
{ |
||||
m_serial->close(); |
||||
m_console->setEnabled(false); |
||||
ui->connectButton->setEnabled(true); |
||||
ui->disconnectButton->setEnabled(false); |
||||
ui->settingsButton->setEnabled(true); |
||||
m_statusBar->showMessage(tr("Disconnected")); |
||||
} |
||||
|
||||
void TerminalConsole::sendResetCommand() |
||||
{ |
||||
if (m_serial->isOpen()) { |
||||
m_serial->setDataTerminalReady(true); |
||||
m_serial->waitForBytesWritten(250); |
||||
m_serial->setDataTerminalReady(false); |
||||
} |
||||
} |
||||
|
||||
void TerminalConsole::writeData(const QByteArray &data) |
||||
{ |
||||
// qDebug() << "writeData:" << data;
|
||||
m_serial->write(data); |
||||
} |
||||
|
||||
void TerminalConsole::readData() |
||||
{ |
||||
QByteArray data = m_serial->readAll(); |
||||
// qDebug() << "readData:" << data;
|
||||
m_console->putData(data); |
||||
|
||||
switch(m_consoleMode) |
||||
{ |
||||
case APM: // APM
|
||||
// On reset, send the break sequence and display help
|
||||
if (data.contains("ENTER 3")) { |
||||
m_serial->write("\r\r\r"); |
||||
m_serial->waitForBytesWritten(10); |
||||
m_serial->write("HELP\r"); |
||||
} |
||||
break; |
||||
case PX4: |
||||
// Do nothing
|
||||
default: |
||||
qDebug() << "Mode not yet implemented"; |
||||
} |
||||
|
||||
} |
||||
|
||||
void TerminalConsole::handleError(QSerialPort::SerialPortError error) |
||||
{ |
||||
if (error == QSerialPort::ResourceError) { |
||||
QGCMessageBox::critical(tr("Critical Error"), m_serial->errorString()); |
||||
closeSerialPort(); |
||||
} |
||||
} |
||||
|
||||
void TerminalConsole::initConnections() |
||||
{ |
||||
// Ui Connections
|
||||
connect(ui->connectButton, SIGNAL(released()), this, SLOT(openSerialPort())); |
||||
connect(ui->disconnectButton, SIGNAL(released()), this, SLOT(closeSerialPort())); |
||||
connect(ui->settingsButton, SIGNAL(released()), m_settingsDialog, SLOT(show())); |
||||
connect(ui->clearButton, SIGNAL(released()), m_console, SLOT(clear())); |
||||
|
||||
connect(ui->baudComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(setBaudRate(int))); |
||||
connect(ui->linkComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(setLink(int))); |
||||
// connect(ui->linkComboBox, SIGNAL()), this, SLOT(setLink(int)));
|
||||
|
||||
// Serial Port Connections
|
||||
connect(m_serial, SIGNAL(error(QSerialPort::SerialPortError)), this, |
||||
SLOT(handleError(QSerialPort::SerialPortError))); |
||||
|
||||
connect(m_serial, SIGNAL(readyRead()), this, SLOT(readData())); |
||||
connect(m_console, SIGNAL(getData(QByteArray)), this, SLOT(writeData(QByteArray))); |
||||
} |
||||
|
||||
void TerminalConsole::setBaudRate(int index) |
||||
{ |
||||
m_settings.baudRate = static_cast<QSerialPort::BaudRate>( |
||||
ui->baudComboBox->itemData(index).toInt()); |
||||
qDebug() << "Changed Baud to:" << m_settings.baudRate; |
||||
|
||||
} |
||||
|
||||
void TerminalConsole::setLink(int index) |
||||
{ |
||||
Q_UNUSED(index); |
||||
m_settings.name = ui->linkComboBox->currentText(); |
||||
qDebug() << "Changed Link to:" << m_settings.name; |
||||
|
||||
} |
||||
|
||||
void TerminalConsole::loadSettings() |
||||
{ |
||||
// Load defaults from settings
|
||||
QSettings settings; |
||||
if (settings.contains("TERMINALCONSOLE_COMM_PORT")) |
||||
{ |
||||
m_settings.name = settings.value("TERMINALCONSOLE_COMM_PORT").toString(); |
||||
m_settings.baudRate = settings.value("TERMINALCONSOLE_COMM_BAUD").toInt(); |
||||
m_settings.parity = static_cast<QSerialPort::Parity> |
||||
(settings.value("TERMINALCONSOLE_COMM_PARITY").toInt()); |
||||
m_settings.stopBits = static_cast<QSerialPort::StopBits> |
||||
(settings.value("TERMINALCONSOLE_COMM_STOPBITS").toInt()); |
||||
m_settings.dataBits = static_cast<QSerialPort::DataBits> |
||||
(settings.value("TERMINALCONSOLE_COMM_DATABITS").toInt()); |
||||
m_settings.flowControl = static_cast<QSerialPort::FlowControl> |
||||
(settings.value("TERMINALCONSOLE_COMM_FLOW_CONTROL").toInt()); |
||||
} else { |
||||
// init the structure
|
||||
} |
||||
} |
||||
|
||||
void TerminalConsole::writeSettings() |
||||
{ |
||||
// Store settings
|
||||
QSettings settings; |
||||
settings.setValue("TERMINALCONSOLE_COMM_PORT", m_settings.name); |
||||
settings.setValue("TERMINALCONSOLE_COMM_BAUD", m_settings.baudRate); |
||||
settings.setValue("TERMINALCONSOLE_COMM_PARITY", m_settings.parity); |
||||
settings.setValue("TERMINALCONSOLE_COMM_STOPBITS", m_settings.stopBits); |
||||
settings.setValue("TERMINALCONSOLE_COMM_DATABITS", m_settings.dataBits); |
||||
settings.setValue("TERMINALCONSOLE_COMM_FLOW_CONTROL", m_settings.flowControl); |
||||
} |
||||
|
||||
|
||||
|
@ -1,101 +0,0 @@
@@ -1,101 +0,0 @@
|
||||
/*=====================================================================
|
||||
|
||||
APM_PLANNER Open Source Ground Control Station |
||||
|
||||
(c) 2013, Bill Bonney <billbonney@communistech.com> |
||||
|
||||
This file is part of the APM_PLANNER project |
||||
|
||||
APM_PLANNER is free software: you can redistribute it and/or modify |
||||
it under the terms of the GNU General Public License as published by |
||||
the Free Software Foundation, either version 3 of the License, or |
||||
(at your option) any later version. |
||||
|
||||
APM_PLANNER is distributed in the hope that it will be useful, |
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
GNU General Public License for more details. |
||||
|
||||
You should have received a copy of the GNU General Public License |
||||
along with APM_PLANNER. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
======================================================================*/ |
||||
|
||||
/**
|
||||
* @file |
||||
* @brief Terminal Console display View. |
||||
* |
||||
* @author Bill Bonney <billbonney@communistech.com> |
||||
* |
||||
* Influenced from Qt examples by :- |
||||
* Copyright (C) 2012 Denis Shienkov <denis.shienkov@gmail.com> |
||||
* Copyright (C) 2012 Laszlo Papp <lpapp@kde.org> |
||||
* |
||||
*/ |
||||
|
||||
#ifndef TERMINALCONSOLE_H |
||||
#define TERMINALCONSOLE_H |
||||
|
||||
#include "SerialSettingsDialog.h" |
||||
|
||||
#include <QWidget> |
||||
#ifdef __android__ |
||||
#include "qserialport.h" |
||||
#else |
||||
#include <QSerialPort> |
||||
#endif |
||||
|
||||
namespace Ui { |
||||
class TerminalConsole; |
||||
} |
||||
|
||||
class Console; |
||||
class SettingsDialog; |
||||
class QStatusBar; |
||||
class QComboBox; |
||||
|
||||
class TerminalConsole : public QWidget |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
enum ConsoleMode { APM, PX4 }; |
||||
public: |
||||
explicit TerminalConsole(QWidget *parent = 0); |
||||
~TerminalConsole(); |
||||
|
||||
private slots: |
||||
void openSerialPort(); |
||||
void openSerialPort(const SerialSettings &settings); |
||||
void closeSerialPort(); |
||||
void writeData(const QByteArray &data); |
||||
void readData(); |
||||
void sendResetCommand(); |
||||
|
||||
void handleError(QSerialPort::SerialPortError error); |
||||
|
||||
private slots: |
||||
void setBaudRate(int index); |
||||
void setLink(int index); |
||||
|
||||
private: |
||||
void initConnections(); |
||||
void addBaudComboBoxConfig(); |
||||
void fillPortsInfo(QComboBox &comboxBox); |
||||
void addConsoleModesComboBoxConfig(); |
||||
void writeSettings(); |
||||
void loadSettings(); |
||||
|
||||
|
||||
private: |
||||
Ui::TerminalConsole *ui; |
||||
|
||||
Console *m_console; |
||||
QStatusBar *m_statusBar; |
||||
SerialSettingsDialog *m_settingsDialog; |
||||
QSerialPort *m_serial; |
||||
SerialSettings m_settings; |
||||
ConsoleMode m_consoleMode; |
||||
}; |
||||
|
||||
#endif // TERMINALCONSOLE_H
|
@ -1,177 +0,0 @@
@@ -1,177 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<ui version="4.0"> |
||||
<class>TerminalConsole</class> |
||||
<widget class="QWidget" name="TerminalConsole"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>0</x> |
||||
<y>0</y> |
||||
<width>889</width> |
||||
<height>531</height> |
||||
</rect> |
||||
</property> |
||||
<property name="windowTitle"> |
||||
<string>Form</string> |
||||
</property> |
||||
<layout class="QHBoxLayout" name="horizontalLayout"> |
||||
<item> |
||||
<widget class="QGroupBox" name="terminalGroupBox"> |
||||
<property name="sizePolicy"> |
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding"> |
||||
<horstretch>0</horstretch> |
||||
<verstretch>0</verstretch> |
||||
</sizepolicy> |
||||
</property> |
||||
<property name="title"> |
||||
<string>Terminal Output</string> |
||||
</property> |
||||
<layout class="QVBoxLayout" name="verticalLayout_2"/> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<layout class="QVBoxLayout" name="verticalLayout"> |
||||
<property name="sizeConstraint"> |
||||
<enum>QLayout::SetMinAndMaxSize</enum> |
||||
</property> |
||||
<item alignment="Qt::AlignRight|Qt::AlignVCenter"> |
||||
<widget class="QPushButton" name="connectButton"> |
||||
<property name="sizePolicy"> |
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> |
||||
<horstretch>100</horstretch> |
||||
<verstretch>0</verstretch> |
||||
</sizepolicy> |
||||
</property> |
||||
<property name="minimumSize"> |
||||
<size> |
||||
<width>131</width> |
||||
<height>0</height> |
||||
</size> |
||||
</property> |
||||
<property name="text"> |
||||
<string>CONNECT</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item alignment="Qt::AlignRight"> |
||||
<widget class="QPushButton" name="disconnectButton"> |
||||
<property name="sizePolicy"> |
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> |
||||
<horstretch>0</horstretch> |
||||
<verstretch>0</verstretch> |
||||
</sizepolicy> |
||||
</property> |
||||
<property name="minimumSize"> |
||||
<size> |
||||
<width>131</width> |
||||
<height>0</height> |
||||
</size> |
||||
</property> |
||||
<property name="text"> |
||||
<string>DISCONNECT</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<spacer name="verticalSpacer_2"> |
||||
<property name="orientation"> |
||||
<enum>Qt::Vertical</enum> |
||||
</property> |
||||
<property name="sizeType"> |
||||
<enum>QSizePolicy::Fixed</enum> |
||||
</property> |
||||
<property name="sizeHint" stdset="0"> |
||||
<size> |
||||
<width>20</width> |
||||
<height>20</height> |
||||
</size> |
||||
</property> |
||||
</spacer> |
||||
</item> |
||||
<item alignment="Qt::AlignRight"> |
||||
<widget class="QComboBox" name="linkComboBox"> |
||||
<property name="sizePolicy"> |
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed"> |
||||
<horstretch>0</horstretch> |
||||
<verstretch>0</verstretch> |
||||
</sizepolicy> |
||||
</property> |
||||
<property name="minimumSize"> |
||||
<size> |
||||
<width>123</width> |
||||
<height>0</height> |
||||
</size> |
||||
</property> |
||||
<property name="maximumSize"> |
||||
<size> |
||||
<width>220</width> |
||||
<height>32</height> |
||||
</size> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item alignment="Qt::AlignRight"> |
||||
<widget class="QComboBox" name="baudComboBox"> |
||||
<property name="sizePolicy"> |
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed"> |
||||
<horstretch>0</horstretch> |
||||
<verstretch>0</verstretch> |
||||
</sizepolicy> |
||||
</property> |
||||
<property name="minimumSize"> |
||||
<size> |
||||
<width>123</width> |
||||
<height>0</height> |
||||
</size> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item alignment="Qt::AlignRight"> |
||||
<widget class="QComboBox" name="consoleModeBox"> |
||||
<property name="sizePolicy"> |
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed"> |
||||
<horstretch>0</horstretch> |
||||
<verstretch>0</verstretch> |
||||
</sizepolicy> |
||||
</property> |
||||
<property name="minimumSize"> |
||||
<size> |
||||
<width>123</width> |
||||
<height>0</height> |
||||
</size> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<spacer name="verticalSpacer"> |
||||
<property name="orientation"> |
||||
<enum>Qt::Vertical</enum> |
||||
</property> |
||||
<property name="sizeHint" stdset="0"> |
||||
<size> |
||||
<width>91</width> |
||||
<height>23</height> |
||||
</size> |
||||
</property> |
||||
</spacer> |
||||
</item> |
||||
<item> |
||||
<widget class="QPushButton" name="settingsButton"> |
||||
<property name="text"> |
||||
<string>Adv. Settings</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
<item> |
||||
<widget class="QPushButton" name="clearButton"> |
||||
<property name="text"> |
||||
<string>Clear</string> |
||||
</property> |
||||
</widget> |
||||
</item> |
||||
</layout> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
<resources/> |
||||
<connections/> |
||||
</ui> |
Loading…
Reference in new issue