SoapySDR support: input: global gain GUI

pull/263/head
f4exb 2018-11-07 01:33:17 +01:00
rodzic 5c8073bade
commit d7be0927b1
10 zmienionych plików z 289 dodań i 3 usunięć

Wyświetl plik

@ -184,7 +184,7 @@ void SoapySDRInput::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();
@ -203,6 +203,22 @@ void SoapySDRInput::getFrequencyRange(uint64_t& min, uint64_t& max)
}
}
void SoapySDRInput::getGlobalGainRange(int& min, int& max)
{
const DeviceSoapySDRParams::ChannelSettings* channelSettings = m_deviceShared.m_deviceParams->getRxChannelSettings(m_deviceShared.m_channel);
if (channelSettings)
{
min = channelSettings->m_gainRange.minimum();
max = channelSettings->m_gainRange.maximum();
}
else
{
min = 0;
max = 0;
}
}
const std::vector<std::string>& SoapySDRInput::getAntennas()
{
const DeviceSoapySDRParams::ChannelSettings* channelSettings = m_deviceShared.m_deviceParams->getRxChannelSettings(m_deviceShared.m_channel);
@ -239,6 +255,12 @@ const std::vector<DeviceSoapySDRParams::FrequencySetting>& SoapySDRInput::getTun
return channelSettings->m_frequencySettings;
}
const std::vector<DeviceSoapySDRParams::GainSetting>& SoapySDRInput::getIndividualGainsRanges()
{
const DeviceSoapySDRParams::ChannelSettings* channelSettings = m_deviceShared.m_deviceParams->getRxChannelSettings(m_deviceShared.m_channel);
return channelSettings->m_gainSettings;
}
void SoapySDRInput::init()
{
applySettings(m_settings, true);
@ -837,6 +859,23 @@ bool SoapySDRInput::applySettings(const SoapySDRInputSettings& settings, bool fo
}
}
if ((m_settings.m_globalGain != settings.m_globalGain) || force)
{
if (dev != 0)
{
try
{
dev->setGain(SOAPY_SDR_RX, requestedChannel, settings.m_globalGain);
qDebug("SoapySDRInput::applySettings: set gain to %d", settings.m_globalGain);
}
catch (const std::exception &ex)
{
qCritical("SoapySDRInput::applySettings: cannot set gain to %d: %s",
settings.m_globalGain, ex.what());
}
}
}
if (forwardChangeOwnDSP)
{
int sampleRate = settings.m_devSampleRate/(1<<settings.m_log2Decim);
@ -887,7 +926,8 @@ bool SoapySDRInput::applySettings(const SoapySDRInputSettings& settings, bool fo
<< " m_dcBlock: " << m_settings.m_dcBlock
<< " m_iqCorrection: " << m_settings.m_iqCorrection
<< " m_antenna: " << m_settings.m_antenna
<< " m_bandwidth: " << m_settings.m_bandwidth;
<< " m_bandwidth: " << m_settings.m_bandwidth
<< " m_globalGain: " << m_settings.m_globalGain;
return true;
}

Wyświetl plik

@ -121,11 +121,13 @@ public:
virtual bool handleMessage(const Message& message);
void getFrequencyRange(uint64_t& min, uint64_t& max);
void getGlobalGainRange(int& min, int& max);
const std::vector<std::string>& getAntennas();
const SoapySDR::RangeList& getRateRanges();
const SoapySDR::RangeList& getBandwidthRanges();
int getAntennaIndex(const std::string& antenna);
const std::vector<DeviceSoapySDRParams::FrequencySetting>& getTunableElements();
const std::vector<DeviceSoapySDRParams::GainSetting>& getIndividualGainsRanges();
private:
DeviceSourceAPI *m_deviceAPI;

Wyświetl plik

@ -26,6 +26,7 @@
#include "soapygui/intervalrangegui.h"
#include "soapygui/stringrangegui.h"
#include "soapygui/dynamicitemsettinggui.h"
#include "soapygui/intervalslidergui.h"
#include "ui_soapysdrinputgui.h"
#include "soapysdrinputgui.h"
@ -42,7 +43,8 @@ SoapySDRInputGui::SoapySDRInputGui(DeviceUISet *deviceUISet, QWidget* parent) :
m_lastEngineState(DSPDeviceSourceEngine::StNotStarted),
m_antennas(0),
m_sampleRateGUI(0),
m_bandwidthGUI(0)
m_bandwidthGUI(0),
m_gainSliderGUI(0)
{
m_sampleSource = (SoapySDRInput*) m_deviceUISet->m_deviceSourceAPI->getSampleSource();
ui->setupUi(this);
@ -56,6 +58,7 @@ SoapySDRInputGui::SoapySDRInputGui(DeviceUISet *deviceUISet, QWidget* parent) :
createRangesControl(&m_sampleRateGUI, m_sampleSource->getRateRanges(), "SR", "S/s");
createRangesControl(&m_bandwidthGUI, m_sampleSource->getBandwidthRanges(), "BW", "Hz");
createTunableElementsControl(m_sampleSource->getTunableElements());
createGlobalGainControl();
if (m_sampleRateGUI) {
connect(m_sampleRateGUI, SIGNAL(valueChanged(double)), this, SLOT(sampleRateChanged(double)));
@ -182,6 +185,21 @@ void SoapySDRInputGui::createTunableElementsControl(const std::vector<DeviceSoap
}
}
void SoapySDRInputGui::createGlobalGainControl()
{
m_gainSliderGUI = new IntervalSliderGUI(this);
int min, max;
m_sampleSource->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 SoapySDRInputGui::setName(const QString& name)
{
setObjectName(name);
@ -310,6 +328,12 @@ void SoapySDRInputGui::tunableElementChanged(QString name, double value)
sendSettings();
}
void SoapySDRInputGui::globalGainChanged(double gain)
{
m_settings.m_globalGain = round(gain);
sendSettings();
}
void SoapySDRInputGui::on_centerFrequency_changed(quint64 value)
{
m_settings.m_centerFrequency = value * 1000;
@ -403,6 +427,9 @@ void SoapySDRInputGui::displaySettings()
if (m_bandwidthGUI) {
m_bandwidthGUI->setValue(m_settings.m_bandwidth);
}
if (m_gainSliderGUI) {
m_gainSliderGUI->setValue(m_settings.m_globalGain);
}
ui->dcOffset->setChecked(m_settings.m_dcBlock);
ui->iqImbalance->setChecked(m_settings.m_iqCorrection);

Wyświetl plik

@ -30,6 +30,7 @@ class DeviceUISet;
class ItemSettingGUI;
class StringRangeGUI;
class DynamicItemSettingGUI;
class IntervalSliderGUI;
namespace Ui {
class SoapySDRInputGui;
@ -62,6 +63,7 @@ private:
const QString& unit);
void createAntennasControl(const std::vector<std::string>& antennaList);
void createTunableElementsControl(const std::vector<DeviceSoapySDRParams::FrequencySetting>& tunableElementsList);
void createGlobalGainControl();
Ui::SoapySDRInputGui* ui;
@ -81,6 +83,7 @@ private:
ItemSettingGUI *m_sampleRateGUI;
ItemSettingGUI *m_bandwidthGUI;
std::vector<DynamicItemSettingGUI*> m_tunableElementsGUIs;
IntervalSliderGUI *m_gainSliderGUI;
void displaySettings();
void displayTunableElementsControlSettings();
@ -96,6 +99,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_dcOffset_toggled(bool checked);

Wyświetl plik

@ -39,6 +39,7 @@ void SoapySDRInputSettings::resetToDefaults()
m_fileRecordName = "";
m_antenna = "NONE";
m_bandwidth = 1000000;
m_globalGain = 0;
}
QByteArray SoapySDRInputSettings::serialize() const
@ -56,6 +57,7 @@ QByteArray SoapySDRInputSettings::serialize() const
s.writeString(9, m_antenna);
s.writeU32(10, m_bandwidth);
s.writeBlob(11, serializeNamedElementMap(m_tunableElements));
s.writeS32(12, m_globalGain);
return s.final();
}
@ -88,6 +90,7 @@ bool SoapySDRInputSettings::deserialize(const QByteArray& data)
d.readU32(10, &m_bandwidth, 1000000);
d.readBlob(11, &blob);
deserializeNamedElementMap(blob, m_tunableElements);
d.readS32(12, &m_globalGain, 0);
return true;
}

Wyświetl plik

@ -41,6 +41,7 @@ struct SoapySDRInputSettings {
QString m_antenna;
quint32 m_bandwidth;
QMap<QString, double> m_tunableElements;
qint32 m_globalGain;
SoapySDRInputSettings();
void resetToDefaults();

Wyświetl plik

@ -59,6 +59,7 @@ set(sdrgui_SOURCES
soapygui/itemsettinggui.cpp
soapygui/stringrangegui.cpp
soapygui/dynamicitemsettinggui.cpp
soapygui/intervalslidergui.cpp
webapi/webapiadaptergui.cpp
)
@ -122,6 +123,7 @@ set(sdrgui_HEADERS
soapygui/itemsettinggui.h
soapygui/stringrangegui.h
soapygui/dynamicitemsettinggui.h
soapygui/intervalslidergui.h
webapi/webapiadaptergui.h
)
@ -153,6 +155,7 @@ set(sdrgui_FORMS
gui/loggingdialog.ui
soapygui/discreterangegui.ui
soapygui/intervalrangegui.ui
soapygui/intervalslidergui.ui
)
set(sdrgui_RESOURCES

Wyświetl plik

@ -0,0 +1,71 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2018 Edouard Griffiths, F4EXB //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include <math.h>
#include "ui_intervalslidergui.h"
#include "intervalslidergui.h"
IntervalSliderGUI::IntervalSliderGUI(QWidget* parent) :
QWidget(parent),
ui(new Ui::IntervalSliderGUI),
m_minimum(0),
m_maximum(0)
{
ui->setupUi(this);
}
IntervalSliderGUI::~IntervalSliderGUI()
{
delete ui;
}
void IntervalSliderGUI::setLabel(const QString& text)
{
ui->intervalLabel->setText(text);
}
void IntervalSliderGUI::setUnits(const QString& units)
{
ui->intervalUnits->setText(units);
}
void IntervalSliderGUI::setInterval(double minimum, double maximum)
{
ui->intervalSlider->blockSignals(true);
ui->intervalSlider->setMinimum(minimum);
ui->intervalSlider->setMaximum(maximum);
ui->intervalSlider->blockSignals(false);
m_minimum = minimum;
m_maximum = maximum;
}
double IntervalSliderGUI::getCurrentValue()
{
return ui->intervalSlider->value();
}
void IntervalSliderGUI::setValue(double value)
{
ui->intervalSlider->setValue(value);
ui->valueText->setText(QString("%1").arg(ui->intervalSlider->value()));
}
void IntervalSliderGUI::on_intervalSlider_valueChanged(int value)
{
ui->valueText->setText(QString("%1").arg(value));
emit valueChanged(value);
}

Wyświetl plik

@ -0,0 +1,52 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2018 Edouard Griffiths, F4EXB //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef SDRGUI_SOAPYGUI_INTERVALSLIDERGUI_H_
#define SDRGUI_SOAPYGUI_INTERVALSLIDERGUI_H_
#include <QWidget>
#include <QString>
namespace Ui {
class IntervalSliderGUI;
}
class IntervalSliderGUI : public QWidget
{
Q_OBJECT
public:
explicit IntervalSliderGUI(QWidget* parent = 0);
virtual ~IntervalSliderGUI();
void setLabel(const QString& text);
void setUnits(const QString& units);
void setInterval(double minimum, double maximum);
virtual double getCurrentValue();
virtual void setValue(double value);
signals:
void valueChanged(double value);
private slots:
void on_intervalSlider_valueChanged(int value);
private:
Ui::IntervalSliderGUI* ui;
double m_minimum;
double m_maximum;
};
#endif /* SDRGUI_SOAPYGUI_INTERVALSLIDERGUI_H_ */

Wyświetl plik

@ -0,0 +1,83 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>IntervalSliderGUI</class>
<widget class="QWidget" name="IntervalSliderGUI">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>203</width>
<height>30</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<widget class="QWidget" name="horizontalLayoutWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>179</width>
<height>29</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="intervalLabel">
<property name="text">
<string>Label</string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="intervalSlider">
<property name="pageStep">
<number>1</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="valueText">
<property name="minimumSize">
<size>
<width>40</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>0000</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="intervalUnits">
<property name="text">
<string>Unit</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
</ui>