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
|
|
|
{
|
|
|
|
return m_settings.centerFrequency;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
|
|
|
ui->centerFrequency->setValue(m_settings.centerFrequency / 1000);
|
2015-09-05 05:46:56 -04:00
|
|
|
ui->checkBoxG->setChecked(m_settings.lnaGain);
|
|
|
|
ui->checkBoxB->setChecked(m_settings.biasT);
|
2015-09-05 19:34:20 -04:00
|
|
|
ui->mixGain->setChecked(m_settings.mixGain);
|
|
|
|
ui->ifGain->setValue(m_settings.ifGain);
|
|
|
|
ui->ifGainText->setText(QString("%1dB").arg(m_settings.ifGain));
|
|
|
|
ui->filterIF->setCurrentIndex(m_settings.ifFilterIndex);
|
|
|
|
ui->filterRF->setCurrentIndex(m_settings.rfFilterIndex);
|
|
|
|
ui->ppm->setValue(m_settings.LOppmTenths);
|
|
|
|
ui->ppmText->setText(QString("%1").arg(QString::number(m_settings.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
|
|
|
{
|
|
|
|
m_settings.centerFrequency = value * 1000;
|
|
|
|
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-05 05:46:56 -04:00
|
|
|
m_settings.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-05 05:46:56 -04:00
|
|
|
m_settings.biasT = (state == Qt::Checked);
|
|
|
|
sendSettings();
|
|
|
|
}
|
2015-09-02 21:57:54 -04:00
|
|
|
|
2015-09-05 05:46:56 -04:00
|
|
|
void FCDProPlusGui::on_mixGain_stateChanged(int state)
|
|
|
|
{
|
|
|
|
m_settings.mixGain = (state == Qt::Checked);
|
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FCDProPlusGui::on_filterIF_currentIndexChanged(int index)
|
|
|
|
{
|
|
|
|
m_settings.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)
|
|
|
|
{
|
|
|
|
m_settings.rfFilterIndex = index;
|
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FCDProPlusGui::on_ifGain_valueChanged(int value)
|
|
|
|
{
|
|
|
|
m_settings.ifGain = value;
|
2015-09-05 19:34:20 -04:00
|
|
|
displaySettings();
|
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FCDProPlusGui::on_ppm_valueChanged(int value)
|
|
|
|
{
|
|
|
|
m_settings.LOppmTenths = value;
|
|
|
|
displaySettings();
|
2015-09-05 05:46:56 -04:00
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|