2015-09-05 19:34:20 -04:00
|
|
|
#include <QDebug>
|
2015-09-03 22:10:38 -04:00
|
|
|
#include "ui_fcdproplusgui.h"
|
2015-09-02 21:57:54 -04:00
|
|
|
#include "plugin/pluginapi.h"
|
|
|
|
#include "gui/colormapper.h"
|
|
|
|
#include "dsp/dspengine.h"
|
2015-09-03 22:10:38 -04:00
|
|
|
#include "fcdproplusgui.h"
|
2015-09-05 05:46:56 -04:00
|
|
|
#include "fcdproplusconst.h"
|
2015-09-02 21:57:54 -04:00
|
|
|
|
2015-09-03 22:10:38 -04:00
|
|
|
FCDProPlusGui::FCDProPlusGui(PluginAPI* pluginAPI, QWidget* parent) :
|
2015-09-02 21:57:54 -04:00
|
|
|
QWidget(parent),
|
2015-09-03 22:10:38 -04:00
|
|
|
ui(new Ui::FCDProPlusGui),
|
2015-09-02 21:57:54 -04:00
|
|
|
m_pluginAPI(pluginAPI),
|
|
|
|
m_settings(),
|
|
|
|
m_sampleSource(NULL)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
2015-09-05 05:46:56 -04:00
|
|
|
|
2015-09-02 21:57:54 -04:00
|
|
|
ui->centerFrequency->setColorMapper(ColorMapper(ColorMapper::ReverseGold));
|
2015-09-05 19:34:20 -04:00
|
|
|
ui->centerFrequency->setValueRange(7, 150U, 2000000U);
|
2015-09-05 05:46:56 -04:00
|
|
|
|
|
|
|
ui->filterIF->clear();
|
|
|
|
for (int i = 0; i < FCDProPlusConstants::fcdproplus_if_filter_nb_values(); i++)
|
|
|
|
{
|
|
|
|
ui->filterIF->addItem(QString(FCDProPlusConstants::if_filters[i].label.c_str()), i);
|
|
|
|
}
|
|
|
|
|
|
|
|
ui->filterRF->clear();
|
|
|
|
for (int i = 0; i < FCDProPlusConstants::fcdproplus_rf_filter_nb_values(); i++)
|
|
|
|
{
|
|
|
|
ui->filterRF->addItem(QString(FCDProPlusConstants::rf_filters[i].label.c_str()), i);
|
|
|
|
}
|
|
|
|
|
2015-09-02 21:57:54 -04:00
|
|
|
connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateHardware()));
|
|
|
|
displaySettings();
|
|
|
|
|
2015-09-03 22:10:38 -04:00
|
|
|
m_sampleSource = new FCDProPlusInput();
|
2015-09-02 21:57:54 -04:00
|
|
|
DSPEngine::instance()->setSource(m_sampleSource);
|
|
|
|
}
|
|
|
|
|
2015-09-03 22:10:38 -04:00
|
|
|
FCDProPlusGui::~FCDProPlusGui()
|
2015-09-02 21:57:54 -04:00
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2015-09-03 22:10:38 -04:00
|
|
|
void FCDProPlusGui::destroy()
|
2015-09-02 21:57:54 -04:00
|
|
|
{
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
|
2015-09-03 22:10:38 -04:00
|
|
|
void FCDProPlusGui::setName(const QString& name)
|
2015-09-02 21:57:54 -04:00
|
|
|
{
|
|
|
|
setObjectName(name);
|
|
|
|
}
|
|
|
|
|
2015-09-03 22:10:38 -04:00
|
|
|
QString FCDProPlusGui::getName() const
|
2015-09-02 21:57:54 -04:00
|
|
|
{
|
|
|
|
return objectName();
|
|
|
|
}
|
|
|
|
|
2015-09-03 22:10:38 -04:00
|
|
|
void FCDProPlusGui::resetToDefaults()
|
2015-09-02 21:57:54 -04:00
|
|
|
{
|
|
|
|
m_settings.resetToDefaults();
|
|
|
|
displaySettings();
|
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
2015-09-03 22:10:38 -04:00
|
|
|
qint64 FCDProPlusGui::getCenterFrequency() const
|
2015-09-03 02:50:07 -04:00
|
|
|
{
|
2015-09-30 21:37:53 -04:00
|
|
|
return m_settings.m_centerFrequency;
|
2015-09-03 02:50:07 -04:00
|
|
|
}
|
|
|
|
|
2015-09-28 21:35:14 -04:00
|
|
|
void FCDProPlusGui::setCenterFrequency(qint64 centerFrequency)
|
|
|
|
{
|
2015-09-30 21:37:53 -04:00
|
|
|
m_settings.m_centerFrequency = centerFrequency;
|
2015-09-28 21:35:14 -04:00
|
|
|
displaySettings();
|
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
2015-09-03 22:10:38 -04:00
|
|
|
QByteArray FCDProPlusGui::serialize() const
|
2015-09-02 21:57:54 -04:00
|
|
|
{
|
|
|
|
return m_settings.serialize();
|
|
|
|
}
|
|
|
|
|
2015-09-03 22:10:38 -04:00
|
|
|
bool FCDProPlusGui::deserialize(const QByteArray& data)
|
2015-09-02 21:57:54 -04:00
|
|
|
{
|
|
|
|
if(m_settings.deserialize(data))
|
|
|
|
{
|
|
|
|
displaySettings();
|
|
|
|
sendSettings();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
resetToDefaults();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-03 22:10:38 -04:00
|
|
|
bool FCDProPlusGui::handleMessage(const Message& message)
|
2015-09-02 21:57:54 -04:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-09-03 22:10:38 -04:00
|
|
|
void FCDProPlusGui::displaySettings()
|
2015-09-02 21:57:54 -04:00
|
|
|
{
|
2015-09-30 21:37:53 -04:00
|
|
|
ui->centerFrequency->setValue(m_settings.m_centerFrequency / 1000);
|
2015-09-30 22:13:04 -04:00
|
|
|
ui->dcOffset->setChecked(m_settings.m_dcBlock);
|
|
|
|
ui->iqImbalance->setChecked(m_settings.m_iqImbalance);
|
2015-09-30 21:37:53 -04:00
|
|
|
ui->checkBoxG->setChecked(m_settings.m_lnaGain);
|
|
|
|
ui->checkBoxB->setChecked(m_settings.m_biasT);
|
|
|
|
ui->mixGain->setChecked(m_settings.m_mixGain);
|
|
|
|
ui->ifGain->setValue(m_settings.m_ifGain);
|
|
|
|
ui->ifGainText->setText(QString("%1dB").arg(m_settings.m_ifGain));
|
|
|
|
ui->filterIF->setCurrentIndex(m_settings.m_ifFilterIndex);
|
|
|
|
ui->filterRF->setCurrentIndex(m_settings.m_rfFilterIndex);
|
|
|
|
ui->ppm->setValue(m_settings.m_LOppmTenths);
|
|
|
|
ui->ppmText->setText(QString("%1").arg(QString::number(m_settings.m_LOppmTenths/10.0, 'f', 1)));
|
2015-09-02 21:57:54 -04:00
|
|
|
}
|
|
|
|
|
2015-09-03 22:10:38 -04:00
|
|
|
void FCDProPlusGui::sendSettings()
|
2015-09-02 21:57:54 -04:00
|
|
|
{
|
|
|
|
if(!m_updateTimer.isActive())
|
|
|
|
m_updateTimer.start(100);
|
|
|
|
}
|
|
|
|
|
2015-09-03 22:10:38 -04:00
|
|
|
void FCDProPlusGui::on_centerFrequency_changed(quint64 value)
|
2015-09-02 21:57:54 -04:00
|
|
|
{
|
2015-09-30 21:37:53 -04:00
|
|
|
m_settings.m_centerFrequency = value * 1000;
|
2015-09-02 21:57:54 -04:00
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
2015-09-30 22:13:04 -04:00
|
|
|
void FCDProPlusGui::on_dcOffset_toggled(bool checked)
|
|
|
|
{
|
|
|
|
m_settings.m_dcBlock = checked;
|
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FCDProPlusGui::on_iqImbalance_toggled(bool checked)
|
|
|
|
{
|
|
|
|
m_settings.m_iqImbalance = checked;
|
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
2015-09-03 22:10:38 -04:00
|
|
|
void FCDProPlusGui::updateHardware()
|
2015-09-02 21:57:54 -04:00
|
|
|
{
|
2015-09-03 22:10:38 -04:00
|
|
|
FCDProPlusInput::MsgConfigureFCD* message = FCDProPlusInput::MsgConfigureFCD::create(m_settings);
|
2015-09-02 21:57:54 -04:00
|
|
|
m_sampleSource->getInputMessageQueue()->push(message);
|
|
|
|
m_updateTimer.stop();
|
|
|
|
}
|
|
|
|
|
2015-09-03 22:10:38 -04:00
|
|
|
void FCDProPlusGui::on_checkBoxG_stateChanged(int state)
|
2015-09-02 21:57:54 -04:00
|
|
|
{
|
2015-09-30 21:37:53 -04:00
|
|
|
m_settings.m_lnaGain = (state == Qt::Checked);
|
2015-09-02 21:57:54 -04:00
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
2015-09-03 22:10:38 -04:00
|
|
|
void FCDProPlusGui::on_checkBoxB_stateChanged(int state)
|
2015-09-02 21:57:54 -04:00
|
|
|
{
|
2015-09-30 21:37:53 -04:00
|
|
|
m_settings.m_biasT = (state == Qt::Checked);
|
2015-09-05 05:46:56 -04:00
|
|
|
sendSettings();
|
|
|
|
}
|
2015-09-02 21:57:54 -04:00
|
|
|
|
2015-09-05 05:46:56 -04:00
|
|
|
void FCDProPlusGui::on_mixGain_stateChanged(int state)
|
|
|
|
{
|
2015-09-30 21:37:53 -04:00
|
|
|
m_settings.m_mixGain = (state == Qt::Checked);
|
2015-09-05 05:46:56 -04:00
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FCDProPlusGui::on_filterIF_currentIndexChanged(int index)
|
|
|
|
{
|
2015-09-30 21:37:53 -04:00
|
|
|
m_settings.m_ifFilterIndex = index;
|
2015-09-02 21:57:54 -04:00
|
|
|
sendSettings();
|
|
|
|
}
|
2015-09-05 05:46:56 -04:00
|
|
|
|
|
|
|
void FCDProPlusGui::on_filterRF_currentIndexChanged(int index)
|
|
|
|
{
|
2015-09-30 21:37:53 -04:00
|
|
|
m_settings.m_rfFilterIndex = index;
|
2015-09-05 05:46:56 -04:00
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FCDProPlusGui::on_ifGain_valueChanged(int value)
|
|
|
|
{
|
2015-09-30 21:37:53 -04:00
|
|
|
m_settings.m_ifGain = value;
|
2015-09-05 19:34:20 -04:00
|
|
|
displaySettings();
|
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FCDProPlusGui::on_ppm_valueChanged(int value)
|
|
|
|
{
|
2015-09-30 21:37:53 -04:00
|
|
|
m_settings.m_LOppmTenths = value;
|
2015-09-05 19:34:20 -04:00
|
|
|
displaySettings();
|
2015-09-05 05:46:56 -04:00
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|