1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-22 16:08:39 -05:00

SoapySDR support: output: individual gains GUIs

This commit is contained in:
f4exb 2018-11-07 13:47:47 +01:00
parent cfeaca424e
commit d2eb9130b0
5 changed files with 72 additions and 0 deletions

View File

@ -831,6 +831,31 @@ bool SoapySDROutput::applySettings(const SoapySDROutputSettings& settings, bool
}
}
for (const auto &oname : m_settings.m_individualGains.keys())
{
auto nvalue = settings.m_individualGains.find(oname);
if (nvalue != settings.m_individualGains.end() && (m_settings.m_individualGains[oname] != *nvalue))
{
if (dev != 0)
{
try
{
dev->setGain(SOAPY_SDR_TX, requestedChannel, oname.toStdString(), *nvalue);
qDebug("SoapySDROutput::applySettings: individual gain %s set to %lf",
oname.toStdString().c_str(), *nvalue);
}
catch (const std::exception &ex)
{
qCritical("SoapySDROutput::applySettings: cannot set individual gain %s to %lf: %s",
oname.toStdString().c_str(), *nvalue, ex.what());
}
}
m_settings.m_individualGains[oname] = *nvalue;
}
}
if (forwardChangeOwnDSP)
{
int sampleRate = settings.m_devSampleRate/(1<<settings.m_log2Interp);

View File

@ -199,6 +199,26 @@ void SoapySDROutputGui::createGlobalGainControl()
connect(m_gainSliderGUI, SIGNAL(valueChanged(double)), this, SLOT(globalGainChanged(double)));
}
void SoapySDROutputGui::createIndividualGainsControl(const std::vector<DeviceSoapySDRParams::GainSetting>& individualGainsList)
{
if (individualGainsList.size() == 0) { // Leave early if list of individual gains is empty
return;
}
std::vector<DeviceSoapySDRParams::GainSetting>::const_iterator it = individualGainsList.begin();
for (int i = 0; it != individualGainsList.end(); ++it, i++)
{
IntervalSliderGUI *gainGUI = new IntervalSliderGUI(this);
gainGUI->setInterval(it->m_range.minimum(), it->m_range.maximum());
gainGUI->setLabel(QString("%1 gain").arg(it->m_name.c_str()));
gainGUI->setUnits(QString(""));
DynamicItemSettingGUI *gui = new DynamicItemSettingGUI(gainGUI, QString(it->m_name.c_str()));
m_individualGainsGUIs.push_back(gui);
connect(m_individualGainsGUIs.back(), SIGNAL(valueChanged(QString, double)), this, SLOT(individualGainChanged(QString, double)));
}
}
void SoapySDROutputGui::setName(const QString& name)
{
setObjectName(name);
@ -333,6 +353,12 @@ void SoapySDROutputGui::globalGainChanged(double gain)
sendSettings();
}
void SoapySDROutputGui::individualGainChanged(QString name, double value)
{
m_settings.m_individualGains[name] = value;
sendSettings();
}
void SoapySDROutputGui::on_centerFrequency_changed(quint64 value)
{
m_settings.m_centerFrequency = value * 1000;
@ -398,6 +424,7 @@ void SoapySDROutputGui::displaySettings()
ui->LOppmText->setText(QString("%1").arg(QString::number(m_settings.m_LOppmTenths/10.0, 'f', 1)));
displayTunableElementsControlSettings();
displayIndividualGainsControlSettings();
blockApplySettings(false);
}
@ -414,6 +441,18 @@ void SoapySDROutputGui::displayTunableElementsControlSettings()
}
}
void SoapySDROutputGui::displayIndividualGainsControlSettings()
{
for (const auto &it : m_individualGainsGUIs)
{
QMap<QString, double>::const_iterator elIt = m_settings.m_individualGains.find(it->getName());
if (elIt != m_settings.m_individualGains.end()) {
it->setValue(*elIt);
}
}
}
void SoapySDROutputGui::sendSettings()
{
if (!m_updateTimer.isActive()) {

View File

@ -65,6 +65,7 @@ private:
void createAntennasControl(const std::vector<std::string>& antennaList);
void createTunableElementsControl(const std::vector<DeviceSoapySDRParams::FrequencySetting>& tunableElementsList);
void createGlobalGainControl();
void createIndividualGainsControl(const std::vector<DeviceSoapySDRParams::GainSetting>& individualGainsList);
Ui::SoapySDROutputGui* ui;
@ -85,10 +86,12 @@ private:
ItemSettingGUI *m_bandwidthGUI;
std::vector<DynamicItemSettingGUI*> m_tunableElementsGUIs;
IntervalSliderGUI *m_gainSliderGUI;
std::vector<DynamicItemSettingGUI*> m_individualGainsGUIs;
void blockApplySettings(bool block) { m_doApplySettings = !block; }
void displaySettings();
void displayTunableElementsControlSettings();
void displayIndividualGainsControlSettings();
void sendSettings();
void updateSampleRateAndFrequency();
void updateFrequencyLimits();
@ -101,6 +104,7 @@ private slots:
void bandwidthChanged(double bandwidth);
void tunableElementChanged(QString name, double value);
void globalGainChanged(double gain);
void individualGainChanged(QString name, double value);
void on_centerFrequency_changed(quint64 value);
void on_LOppm_valueChanged(int value);
void on_interp_currentIndexChanged(int index);

View File

@ -52,6 +52,7 @@ QByteArray SoapySDROutputSettings::serialize() const
s.writeU32(7, m_bandwidth);
s.writeBlob(8, serializeNamedElementMap(m_tunableElements));
s.writeS32(12, m_globalGain);
s.writeBlob(13, serializeNamedElementMap(m_individualGains));
return s.final();
}
@ -80,6 +81,8 @@ bool SoapySDROutputSettings::deserialize(const QByteArray& data)
d.readBlob(8, &blob);
deserializeNamedElementMap(blob, m_tunableElements);
d.readS32(12, &m_globalGain, 0);
d.readBlob(13, &blob);
deserializeNamedElementMap(blob, m_individualGains);
return true;
}

View File

@ -31,6 +31,7 @@ struct SoapySDROutputSettings {
quint32 m_bandwidth;
QMap<QString, double> m_tunableElements;
qint32 m_globalGain;
QMap<QString, double> m_individualGains;
SoapySDROutputSettings();
void resetToDefaults();