2014-11-29 13:09:35 -05:00
|
|
|
#include "fcdgui.h"
|
|
|
|
#include "ui_fcdgui.h"
|
|
|
|
#include "plugin/pluginapi.h"
|
2015-08-17 02:29:34 -04:00
|
|
|
#include "dsp/dspengine.h"
|
2014-11-29 13:09:35 -05:00
|
|
|
|
|
|
|
FCDGui::FCDGui(PluginAPI* pluginAPI, QWidget* parent) :
|
|
|
|
QWidget(parent),
|
|
|
|
ui(new Ui::FCDGui),
|
|
|
|
m_pluginAPI(pluginAPI),
|
|
|
|
m_settings(),
|
|
|
|
m_sampleSource(NULL)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
ui->centerFrequency->setValueRange(7, 420000U, 1900000U);
|
|
|
|
connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateHardware()));
|
|
|
|
displaySettings();
|
|
|
|
|
2015-08-17 02:29:34 -04:00
|
|
|
m_sampleSource = new FCDInput();
|
|
|
|
DSPEngine::instance()->setSource(m_sampleSource);
|
2014-11-29 13:09:35 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
FCDGui::~FCDGui()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FCDGui::destroy()
|
|
|
|
{
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FCDGui::setName(const QString& name)
|
|
|
|
{
|
|
|
|
setObjectName(name);
|
|
|
|
}
|
|
|
|
|
2015-06-06 21:30:28 -04:00
|
|
|
QString FCDGui::getName() const
|
|
|
|
{
|
|
|
|
return objectName();
|
|
|
|
}
|
|
|
|
|
2014-11-29 13:09:35 -05:00
|
|
|
void FCDGui::resetToDefaults()
|
|
|
|
{
|
|
|
|
m_settings.resetToDefaults();
|
|
|
|
displaySettings();
|
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray FCDGui::serialize() const
|
|
|
|
{
|
|
|
|
return m_settings.serialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FCDGui::deserialize(const QByteArray& data)
|
|
|
|
{
|
2015-08-17 02:29:34 -04:00
|
|
|
if(m_settings.deserialize(data))
|
|
|
|
{
|
2014-11-29 13:09:35 -05:00
|
|
|
displaySettings();
|
|
|
|
sendSettings();
|
|
|
|
return true;
|
2015-08-17 02:29:34 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-11-29 13:09:35 -05:00
|
|
|
resetToDefaults();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-17 02:29:34 -04:00
|
|
|
bool FCDGui::handleMessage(const Message& message)
|
2014-11-29 13:09:35 -05:00
|
|
|
{
|
2015-08-17 02:29:34 -04:00
|
|
|
return false;
|
2014-11-29 13:09:35 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void FCDGui::displaySettings()
|
|
|
|
{
|
2015-08-17 02:29:34 -04:00
|
|
|
ui->centerFrequency->setValue(m_settings.centerFrequency / 1000);
|
2014-12-02 09:23:21 -05:00
|
|
|
ui->checkBoxR->setChecked(m_settings.range);
|
|
|
|
ui->checkBoxG->setChecked(m_settings.gain);
|
|
|
|
ui->checkBoxB->setChecked(m_settings.bias);
|
2014-11-29 13:09:35 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void FCDGui::sendSettings()
|
|
|
|
{
|
|
|
|
if(!m_updateTimer.isActive())
|
|
|
|
m_updateTimer.start(100);
|
|
|
|
}
|
|
|
|
|
|
|
|
void FCDGui::on_centerFrequency_changed(quint64 value)
|
|
|
|
{
|
2015-08-17 02:29:34 -04:00
|
|
|
m_settings.centerFrequency = value * 1000;
|
2014-11-29 13:09:35 -05:00
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FCDGui::updateHardware()
|
|
|
|
{
|
2015-08-17 02:29:34 -04:00
|
|
|
FCDInput::MsgConfigureFCD* message = FCDInput::MsgConfigureFCD::create(m_settings);
|
|
|
|
m_sampleSource->getInputMessageQueue()->push(message);
|
2014-11-29 13:09:35 -05:00
|
|
|
m_updateTimer.stop();
|
|
|
|
}
|
|
|
|
|
2014-12-02 09:23:21 -05:00
|
|
|
void FCDGui::on_checkBoxR_stateChanged(int state)
|
|
|
|
{
|
2015-08-17 02:29:34 -04:00
|
|
|
if (state == Qt::Checked)
|
|
|
|
{
|
2014-11-29 13:09:35 -05:00
|
|
|
ui->centerFrequency->setValueRange(7, 150U, 240000U);
|
|
|
|
ui->centerFrequency->setValue(7000);
|
2015-08-17 02:29:34 -04:00
|
|
|
m_settings.centerFrequency = 7000 * 1000;
|
2014-12-02 09:23:21 -05:00
|
|
|
m_settings.range = 1;
|
2014-11-29 13:09:35 -05:00
|
|
|
}
|
2015-08-17 02:29:34 -04:00
|
|
|
else
|
|
|
|
{
|
2014-11-29 13:09:35 -05:00
|
|
|
ui->centerFrequency->setValueRange(7, 420000U, 1900000U);
|
2015-08-17 02:29:34 -04:00
|
|
|
ui->centerFrequency->setValue(435000);
|
|
|
|
m_settings.centerFrequency = 435000 * 1000;
|
2014-12-02 09:23:21 -05:00
|
|
|
m_settings.range = 0;
|
2014-11-29 13:09:35 -05:00
|
|
|
}
|
2015-08-17 02:29:34 -04:00
|
|
|
|
2014-11-29 13:09:35 -05:00
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
2014-12-02 09:23:21 -05:00
|
|
|
void FCDGui::on_checkBoxG_stateChanged(int state)
|
|
|
|
{
|
2015-08-17 02:29:34 -04:00
|
|
|
if (state == Qt::Checked)
|
|
|
|
{
|
2014-12-02 09:23:21 -05:00
|
|
|
m_settings.gain = 1;
|
2015-08-17 02:29:34 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-12-02 09:23:21 -05:00
|
|
|
m_settings.gain = 0;
|
|
|
|
}
|
2015-08-17 02:29:34 -04:00
|
|
|
|
2014-12-02 09:23:21 -05:00
|
|
|
sendSettings();
|
|
|
|
}
|
2015-08-17 02:29:34 -04:00
|
|
|
|
2014-12-02 09:23:21 -05:00
|
|
|
void FCDGui::on_checkBoxB_stateChanged(int state)
|
|
|
|
{
|
2015-08-17 02:29:34 -04:00
|
|
|
if (state == Qt::Checked)
|
|
|
|
{
|
2014-12-02 09:23:21 -05:00
|
|
|
m_settings.bias = 1;
|
2015-08-17 02:29:34 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-12-02 09:23:21 -05:00
|
|
|
m_settings.bias = 0;
|
|
|
|
}
|
2015-08-17 02:29:34 -04:00
|
|
|
|
2014-12-02 09:23:21 -05:00
|
|
|
sendSettings();
|
|
|
|
}
|