1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 09:48:45 -05:00

SoapySDR support: input: AGC GUI

This commit is contained in:
f4exb 2018-11-08 01:31:39 +01:00
parent 59c8ecd2d0
commit f97091e0f3
7 changed files with 58 additions and 10 deletions

View File

@ -221,6 +221,12 @@ void SoapySDRInput::getGlobalGainRange(int& min, int& max)
}
}
bool SoapySDRInput::isAGCSupported()
{
const DeviceSoapySDRParams::ChannelSettings* channelSettings = m_deviceShared.m_deviceParams->getRxChannelSettings(m_deviceShared.m_channel);
return channelSettings->m_hasAGC;
}
const std::vector<std::string>& SoapySDRInput::getAntennas()
{
const DeviceSoapySDRParams::ChannelSettings* channelSettings = m_deviceShared.m_deviceParams->getRxChannelSettings(m_deviceShared.m_channel);
@ -933,6 +939,22 @@ bool SoapySDRInput::applySettings(const SoapySDRInputSettings& settings, bool fo
}
}
if ((m_settings.m_autoGain != settings.m_autoGain) || force)
{
if (dev != 0)
{
try
{
dev->setGainMode(SOAPY_SDR_RX, requestedChannel, settings.m_autoGain);
qDebug("SoapySDRInput::applySettings: %s AGC", settings.m_autoGain ? "set" : "unset");
}
catch (const std::exception &ex)
{
qCritical("SoapySDRInput::applySettings: cannot %s AGC", settings.m_autoGain ? "set" : "unset");
}
}
}
if (forwardChangeOwnDSP)
{
int sampleRate = settings.m_devSampleRate/(1<<settings.m_log2Decim);

View File

@ -148,6 +148,7 @@ public:
void getFrequencyRange(uint64_t& min, uint64_t& max);
void getGlobalGainRange(int& min, int& max);
bool isAGCSupported();
const std::vector<std::string>& getAntennas();
const SoapySDR::RangeList& getRateRanges();
const SoapySDR::RangeList& getBandwidthRanges();

View File

@ -15,6 +15,7 @@
///////////////////////////////////////////////////////////////////////////////////
#include <QMessageBox>
#include <QCheckBox>
#include "dsp/dspengine.h"
#include "dsp/dspcommands.h"
@ -44,7 +45,8 @@ SoapySDRInputGui::SoapySDRInputGui(DeviceUISet *deviceUISet, QWidget* parent) :
m_antennas(0),
m_sampleRateGUI(0),
m_bandwidthGUI(0),
m_gainSliderGUI(0)
m_gainSliderGUI(0),
m_autoGain(0)
{
m_sampleSource = (SoapySDRInput*) m_deviceUISet->m_deviceSourceAPI->getSampleSource();
ui->setupUi(this);
@ -197,6 +199,21 @@ void SoapySDRInputGui::createGlobalGainControl()
m_gainSliderGUI->setUnits(QString(""));
QVBoxLayout *layout = (QVBoxLayout *) ui->scrollAreaWidgetContents->layout();
QFrame *line = new QFrame(this);
line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken);
layout->addWidget(line);
if (m_sampleSource->isAGCSupported())
{
m_autoGain = new QCheckBox(this);
m_autoGain->setText(QString("AGC"));
layout->addWidget(m_autoGain);
connect(m_autoGain, SIGNAL(toggled(bool)), this, SLOT(autoGainChanged(bool)));
}
layout->addWidget(m_gainSliderGUI);
connect(m_gainSliderGUI, SIGNAL(valueChanged(double)), this, SLOT(globalGainChanged(double)));
@ -376,6 +393,12 @@ void SoapySDRInputGui::globalGainChanged(double gain)
sendSettings();
}
void SoapySDRInputGui::autoGainChanged(bool set)
{
m_settings.m_autoGain = set;
sendSettings();
}
void SoapySDRInputGui::individualGainChanged(QString name, double value)
{
m_settings.m_individualGains[name] = value;
@ -478,6 +501,9 @@ void SoapySDRInputGui::displaySettings()
if (m_gainSliderGUI) {
m_gainSliderGUI->setValue(m_settings.m_globalGain);
}
if (m_autoGain) {
m_autoGain->setChecked(m_settings.m_autoGain);
}
ui->dcOffset->setChecked(m_settings.m_dcBlock);
ui->iqImbalance->setChecked(m_settings.m_iqCorrection);

View File

@ -19,7 +19,6 @@
#include <QTimer>
#include <QWidget>
#include <QComboBox>
#include "plugin/plugininstancegui.h"
#include "util/messagequeue.h"
@ -31,6 +30,7 @@ class ItemSettingGUI;
class StringRangeGUI;
class DynamicItemSettingGUI;
class IntervalSliderGUI;
class QCheckBox;
namespace Ui {
class SoapySDRInputGui;
@ -86,6 +86,7 @@ private:
std::vector<DynamicItemSettingGUI*> m_tunableElementsGUIs;
IntervalSliderGUI *m_gainSliderGUI;
std::vector<DynamicItemSettingGUI*> m_individualGainsGUIs;
QCheckBox *m_autoGain;
void displaySettings();
void displayTunableElementsControlSettings();
@ -103,6 +104,7 @@ private slots:
void bandwidthChanged(double bandwidth);
void tunableElementChanged(QString name, double value);
void globalGainChanged(double gain);
void autoGainChanged(bool set);
void individualGainChanged(QString name, double value);
void on_centerFrequency_changed(quint64 value);
void on_LOppm_valueChanged(int value);

View File

@ -365,13 +365,6 @@
</item>
</layout>
</item>
<item>
<widget class="Line" name="line_freq">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="verticalScrollBarPolicy">
@ -386,7 +379,7 @@
<x>0</x>
<y>0</y>
<width>318</width>
<height>51</height>
<height>53</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">

View File

@ -40,6 +40,7 @@ void SoapySDRInputSettings::resetToDefaults()
m_antenna = "NONE";
m_bandwidth = 1000000;
m_globalGain = 0;
m_autoGain = false;
}
QByteArray SoapySDRInputSettings::serialize() const
@ -59,6 +60,7 @@ QByteArray SoapySDRInputSettings::serialize() const
s.writeBlob(11, serializeNamedElementMap(m_tunableElements));
s.writeS32(12, m_globalGain);
s.writeBlob(13, serializeNamedElementMap(m_individualGains));
s.writeBool(14, m_autoGain);
return s.final();
}
@ -94,6 +96,7 @@ bool SoapySDRInputSettings::deserialize(const QByteArray& data)
d.readS32(12, &m_globalGain, 0);
d.readBlob(13, &blob);
deserializeNamedElementMap(blob, m_individualGains);
d.readBool(14, &m_autoGain, false);
return true;
}

View File

@ -43,6 +43,7 @@ struct SoapySDRInputSettings {
QMap<QString, double> m_tunableElements;
qint32 m_globalGain;
QMap<QString, double> m_individualGains;
bool m_autoGain;
SoapySDRInputSettings();
void resetToDefaults();