mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-29 19:28:47 -05:00
SoapySDR support: output: global gain GUI
This commit is contained in:
parent
d7be0927b1
commit
d4e73086d0
@ -164,7 +164,7 @@ void SoapySDROutput::getFrequencyRange(uint64_t& min, uint64_t& max)
|
||||
DeviceSoapySDRParams::FrequencySetting freqSettings = channelSettings->m_frequencySettings[0];
|
||||
SoapySDR::RangeList rangeList = freqSettings.m_ranges;
|
||||
|
||||
if (rangeList.size() > 0) // TODO: handle multiple ranges
|
||||
if (rangeList.size() > 0)
|
||||
{
|
||||
SoapySDR::Range range = rangeList[0];
|
||||
min = range.minimum();
|
||||
@ -183,6 +183,23 @@ void SoapySDROutput::getFrequencyRange(uint64_t& min, uint64_t& max)
|
||||
}
|
||||
}
|
||||
|
||||
void SoapySDROutput::getGlobalGainRange(int& min, int& max)
|
||||
{
|
||||
const DeviceSoapySDRParams::ChannelSettings* channelSettings = m_deviceShared.m_deviceParams->getTxChannelSettings(m_deviceShared.m_channel);
|
||||
|
||||
if (channelSettings)
|
||||
{
|
||||
min = channelSettings->m_gainRange.minimum();
|
||||
max = channelSettings->m_gainRange.maximum();
|
||||
}
|
||||
else
|
||||
{
|
||||
min = 0;
|
||||
max = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const SoapySDR::RangeList& SoapySDROutput::getRateRanges()
|
||||
{
|
||||
const DeviceSoapySDRParams::ChannelSettings* channelSettings = m_deviceShared.m_deviceParams->getTxChannelSettings(m_deviceShared.m_channel);
|
||||
@ -207,6 +224,12 @@ const std::vector<DeviceSoapySDRParams::FrequencySetting>& SoapySDROutput::getTu
|
||||
return channelSettings->m_frequencySettings;
|
||||
}
|
||||
|
||||
const std::vector<DeviceSoapySDRParams::GainSetting>& SoapySDROutput::getIndividualGainsRanges()
|
||||
{
|
||||
const DeviceSoapySDRParams::ChannelSettings* channelSettings = m_deviceShared.m_deviceParams->getTxChannelSettings(m_deviceShared.m_channel);
|
||||
return channelSettings->m_gainSettings;
|
||||
}
|
||||
|
||||
void SoapySDROutput::init()
|
||||
{
|
||||
applySettings(m_settings, true);
|
||||
@ -791,6 +814,23 @@ bool SoapySDROutput::applySettings(const SoapySDROutputSettings& settings, bool
|
||||
}
|
||||
}
|
||||
|
||||
if ((m_settings.m_globalGain != settings.m_globalGain) || force)
|
||||
{
|
||||
if (dev != 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
dev->setGain(SOAPY_SDR_TX, requestedChannel, settings.m_globalGain);
|
||||
qDebug("SoapySDROutput::applySettings: set global gain to %d", settings.m_globalGain);
|
||||
}
|
||||
catch (const std::exception &ex)
|
||||
{
|
||||
qCritical("SoapySDROutput::applySettings: cannot set global gain to %d: %s",
|
||||
settings.m_globalGain, ex.what());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (forwardChangeOwnDSP)
|
||||
{
|
||||
int sampleRate = settings.m_devSampleRate/(1<<settings.m_log2Interp);
|
||||
@ -836,7 +876,8 @@ bool SoapySDROutput::applySettings(const SoapySDROutputSettings& settings, bool
|
||||
<< " m_LOppmTenths: " << m_settings.m_LOppmTenths
|
||||
<< " m_log2Interp: " << m_settings.m_log2Interp
|
||||
<< " m_devSampleRate: " << m_settings.m_devSampleRate
|
||||
<< " m_bandwidth: " << m_settings.m_bandwidth;
|
||||
<< " m_bandwidth: " << m_settings.m_bandwidth
|
||||
<< " m_globalGain: " << m_settings.m_globalGain;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -100,10 +100,12 @@ public:
|
||||
virtual bool handleMessage(const Message& message);
|
||||
|
||||
void getFrequencyRange(uint64_t& min, uint64_t& max);
|
||||
void getGlobalGainRange(int& min, int& max);
|
||||
const SoapySDR::RangeList& getRateRanges();
|
||||
const std::vector<std::string>& getAntennas();
|
||||
const SoapySDR::RangeList& getBandwidthRanges();
|
||||
const std::vector<DeviceSoapySDRParams::FrequencySetting>& getTunableElements();
|
||||
const std::vector<DeviceSoapySDRParams::GainSetting>& getIndividualGainsRanges();
|
||||
|
||||
private:
|
||||
DeviceSinkAPI *m_deviceAPI;
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "soapygui/intervalrangegui.h"
|
||||
#include "soapygui/stringrangegui.h"
|
||||
#include "soapygui/dynamicitemsettinggui.h"
|
||||
#include "soapygui/intervalslidergui.h"
|
||||
|
||||
#include "soapysdroutputgui.h"
|
||||
|
||||
@ -41,7 +42,8 @@ SoapySDROutputGui::SoapySDROutputGui(DeviceUISet *deviceUISet, QWidget* parent)
|
||||
m_lastEngineState(DSPDeviceSinkEngine::StNotStarted),
|
||||
m_antennas(0),
|
||||
m_sampleRateGUI(0),
|
||||
m_bandwidthGUI(0)
|
||||
m_bandwidthGUI(0),
|
||||
m_gainSliderGUI(0)
|
||||
{
|
||||
m_sampleSink = (SoapySDROutput*) m_deviceUISet->m_deviceSinkAPI->getSampleSink();
|
||||
ui->setupUi(this);
|
||||
@ -55,6 +57,7 @@ SoapySDROutputGui::SoapySDROutputGui(DeviceUISet *deviceUISet, QWidget* parent)
|
||||
createRangesControl(&m_sampleRateGUI, m_sampleSink->getRateRanges(), "SR", "S/s");
|
||||
createRangesControl(&m_bandwidthGUI, m_sampleSink->getBandwidthRanges(), "BW", "Hz");
|
||||
createTunableElementsControl(m_sampleSink->getTunableElements());
|
||||
createGlobalGainControl();
|
||||
|
||||
if (m_sampleRateGUI) {
|
||||
connect(m_sampleRateGUI, SIGNAL(valueChanged(double)), this, SLOT(sampleRateChanged(double)));
|
||||
@ -181,6 +184,21 @@ void SoapySDROutputGui::createTunableElementsControl(const std::vector<DeviceSoa
|
||||
}
|
||||
}
|
||||
|
||||
void SoapySDROutputGui::createGlobalGainControl()
|
||||
{
|
||||
m_gainSliderGUI = new IntervalSliderGUI(this);
|
||||
int min, max;
|
||||
m_sampleSink->getGlobalGainRange(min, max);
|
||||
m_gainSliderGUI->setInterval(min, max);
|
||||
m_gainSliderGUI->setLabel(QString("Global gain"));
|
||||
m_gainSliderGUI->setUnits(QString(""));
|
||||
|
||||
QVBoxLayout *layout = (QVBoxLayout *) ui->scrollAreaWidgetContents->layout();
|
||||
layout->addWidget(m_gainSliderGUI);
|
||||
|
||||
connect(m_gainSliderGUI, SIGNAL(valueChanged(double)), this, SLOT(globalGainChanged(double)));
|
||||
}
|
||||
|
||||
void SoapySDROutputGui::setName(const QString& name)
|
||||
{
|
||||
setObjectName(name);
|
||||
@ -309,6 +327,12 @@ void SoapySDROutputGui::tunableElementChanged(QString name, double value)
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
void SoapySDROutputGui::globalGainChanged(double gain)
|
||||
{
|
||||
m_settings.m_globalGain = round(gain);
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
void SoapySDROutputGui::on_centerFrequency_changed(quint64 value)
|
||||
{
|
||||
m_settings.m_centerFrequency = value * 1000;
|
||||
@ -364,6 +388,9 @@ void SoapySDROutputGui::displaySettings()
|
||||
if (m_bandwidthGUI) {
|
||||
m_bandwidthGUI->setValue(m_settings.m_bandwidth);
|
||||
}
|
||||
if (m_gainSliderGUI) {
|
||||
m_gainSliderGUI->setValue(m_settings.m_globalGain);
|
||||
}
|
||||
|
||||
ui->interp->setCurrentIndex(m_settings.m_log2Interp);
|
||||
|
||||
|
@ -31,6 +31,7 @@ class DeviceUISet;
|
||||
class ItemSettingGUI;
|
||||
class StringRangeGUI;
|
||||
class DynamicItemSettingGUI;
|
||||
class IntervalSliderGUI;
|
||||
|
||||
namespace Ui {
|
||||
class SoapySDROutputGui;
|
||||
@ -63,6 +64,7 @@ private:
|
||||
const QString& unit);
|
||||
void createAntennasControl(const std::vector<std::string>& antennaList);
|
||||
void createTunableElementsControl(const std::vector<DeviceSoapySDRParams::FrequencySetting>& tunableElementsList);
|
||||
void createGlobalGainControl();
|
||||
|
||||
Ui::SoapySDROutputGui* ui;
|
||||
|
||||
@ -82,6 +84,7 @@ private:
|
||||
ItemSettingGUI *m_sampleRateGUI;
|
||||
ItemSettingGUI *m_bandwidthGUI;
|
||||
std::vector<DynamicItemSettingGUI*> m_tunableElementsGUIs;
|
||||
IntervalSliderGUI *m_gainSliderGUI;
|
||||
|
||||
void blockApplySettings(bool block) { m_doApplySettings = !block; }
|
||||
void displaySettings();
|
||||
@ -97,6 +100,7 @@ private slots:
|
||||
void sampleRateChanged(double sampleRate);
|
||||
void bandwidthChanged(double bandwidth);
|
||||
void tunableElementChanged(QString name, double value);
|
||||
void globalGainChanged(double gain);
|
||||
void on_centerFrequency_changed(quint64 value);
|
||||
void on_LOppm_valueChanged(int value);
|
||||
void on_interp_currentIndexChanged(int index);
|
||||
|
@ -36,6 +36,7 @@ void SoapySDROutputSettings::resetToDefaults()
|
||||
m_transverterDeltaFrequency = 0;
|
||||
m_antenna = "NONE";
|
||||
m_bandwidth = 1000000;
|
||||
m_globalGain = 0;
|
||||
}
|
||||
|
||||
QByteArray SoapySDROutputSettings::serialize() const
|
||||
@ -50,6 +51,7 @@ QByteArray SoapySDROutputSettings::serialize() const
|
||||
s.writeString(6, m_antenna);
|
||||
s.writeU32(7, m_bandwidth);
|
||||
s.writeBlob(8, serializeNamedElementMap(m_tunableElements));
|
||||
s.writeS32(12, m_globalGain);
|
||||
|
||||
return s.final();
|
||||
}
|
||||
@ -77,6 +79,7 @@ bool SoapySDROutputSettings::deserialize(const QByteArray& data)
|
||||
d.readU32(7, &m_bandwidth, 1000000);
|
||||
d.readBlob(8, &blob);
|
||||
deserializeNamedElementMap(blob, m_tunableElements);
|
||||
d.readS32(12, &m_globalGain, 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ struct SoapySDROutputSettings {
|
||||
QString m_antenna;
|
||||
quint32 m_bandwidth;
|
||||
QMap<QString, double> m_tunableElements;
|
||||
qint32 m_globalGain;
|
||||
|
||||
SoapySDROutputSettings();
|
||||
void resetToDefaults();
|
||||
|
@ -866,11 +866,11 @@ bool SoapySDRInput::applySettings(const SoapySDRInputSettings& settings, bool fo
|
||||
try
|
||||
{
|
||||
dev->setGain(SOAPY_SDR_RX, requestedChannel, settings.m_globalGain);
|
||||
qDebug("SoapySDRInput::applySettings: set gain to %d", settings.m_globalGain);
|
||||
qDebug("SoapySDRInput::applySettings: set global gain to %d", settings.m_globalGain);
|
||||
}
|
||||
catch (const std::exception &ex)
|
||||
{
|
||||
qCritical("SoapySDRInput::applySettings: cannot set gain to %d: %s",
|
||||
qCritical("SoapySDRInput::applySettings: cannot set global gain to %d: %s",
|
||||
settings.m_globalGain, ex.what());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user