1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-21 23:55:13 -05:00

SoapySDR support: input: antenna selection GUI

This commit is contained in:
f4exb 2018-11-04 23:54:16 +01:00
parent 45a569655a
commit bf3fdcbfc2
13 changed files with 224 additions and 144 deletions

View File

@ -120,11 +120,9 @@ void DeviceSoapySDRParams::fillChannelParams(std::vector<ChannelSettings>& chann
channelSettings.back().m_frequencySettingsArgs = m_device->getFrequencyArgsInfo(direction, ichan);
// sample rates
channelSettings.back().m_ratesRanges = m_device->getSampleRateRange(direction, ichan);
// bandwidths
channelSettings.back().m_bandwidthsRanges = m_device->getBandwidthRange(direction, ichan);
}

View File

@ -189,6 +189,12 @@ const SoapySDR::RangeList& SoapySDROutput::getRateRanges()
return channelSettings->m_ratesRanges;
}
const std::vector<std::string>& SoapySDROutput::getAntennas()
{
const DeviceSoapySDRParams::ChannelSettings* channelSettings = m_deviceShared.m_deviceParams->getTxChannelSettings(m_deviceShared.m_channel);
return channelSettings->m_antennas;
}
void SoapySDROutput::init()
{
applySettings(m_settings, true);

View File

@ -101,6 +101,7 @@ public:
void getFrequencyRange(uint64_t& min, uint64_t& max);
const SoapySDR::RangeList& getRateRanges();
const std::vector<std::string>& getAntennas();
private:
DeviceSinkAPI *m_deviceAPI;

View File

@ -209,6 +209,24 @@ const SoapySDR::RangeList& SoapySDRInput::getRateRanges()
return channelSettings->m_ratesRanges;
}
const std::vector<std::string>& SoapySDRInput::getAntennas()
{
const DeviceSoapySDRParams::ChannelSettings* channelSettings = m_deviceShared.m_deviceParams->getRxChannelSettings(m_deviceShared.m_channel);
return channelSettings->m_antennas;
}
int SoapySDRInput::getAntennaIndex(const std::string& antenna)
{
const std::vector<std::string>& antennaList = getAntennas();
std::vector<std::string>::const_iterator it = std::find(antennaList.begin(), antennaList.end(), antenna);
if (it == antennaList.end()) {
return -1;
} else {
return it - antennaList.begin();
}
}
void SoapySDRInput::init()
{
applySettings(m_settings, true);
@ -745,6 +763,23 @@ bool SoapySDRInput::applySettings(const SoapySDRInputSettings& settings, bool fo
}
}
if ((m_settings.m_antenna != settings.m_antenna) || force)
{
if (dev != 0)
{
try
{
dev->setAntenna(SOAPY_SDR_RX, requestedChannel, settings.m_antenna.toStdString());
qDebug("SoapySDRInput::applySettings: set antenna to %s", settings.m_antenna.toStdString().c_str());
}
catch (const std::exception &ex)
{
qCritical("SoapySDRInput::applySettings: cannot set antenna to %s: %s",
settings.m_antenna.toStdString().c_str(), ex.what());
}
}
}
if (forwardChangeOwnDSP)
{
int sampleRate = settings.m_devSampleRate/(1<<settings.m_log2Decim);
@ -793,7 +828,8 @@ bool SoapySDRInput::applySettings(const SoapySDRInputSettings& settings, bool fo
<< " m_fcPos: " << m_settings.m_fcPos
<< " m_devSampleRate: " << m_settings.m_devSampleRate
<< " m_dcBlock: " << m_settings.m_dcBlock
<< " m_iqCorrection: " << m_settings.m_iqCorrection;
<< " m_iqCorrection: " << m_settings.m_iqCorrection
<< " m_antenna: " << m_settings.m_antenna;
return true;
}

View File

@ -122,6 +122,8 @@ public:
void getFrequencyRange(uint64_t& min, uint64_t& max);
const SoapySDR::RangeList& getRateRanges();
const std::vector<std::string>& getAntennas();
int getAntennaIndex(const std::string& antenna);
private:
DeviceSourceAPI *m_deviceAPI;

View File

@ -49,6 +49,7 @@ SoapySDRInputGui::SoapySDRInputGui(DeviceUISet *deviceUISet, QWidget* parent) :
ui->centerFrequency->setValueRange(7, f_min/1000, f_max/1000);
createRangesControl(m_sampleSource->getRateRanges(), "SR", "kS/s");
createAntennasControl(m_sampleSource->getAntennas());
connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateHardware()));
connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus()));
@ -92,7 +93,7 @@ void SoapySDRInputGui::createRangesControl(const SoapySDR::RangeList& rangeList,
if (rangeDiscrete)
{
DiscreteRangeGUI *rangeGUI = new DiscreteRangeGUI(ui->scrollAreaWidgetContents);
DiscreteRangeGUI *rangeGUI = new DiscreteRangeGUI(this);
rangeGUI->setLabel(text);
rangeGUI->setUnits(unit);
@ -101,6 +102,9 @@ void SoapySDRInputGui::createRangesControl(const SoapySDR::RangeList& rangeList,
}
m_sampleRateGUI = rangeGUI;
QVBoxLayout *layout = (QVBoxLayout *) ui->scrollAreaWidgetContents->layout();
layout->addWidget(rangeGUI);
connect(m_sampleRateGUI, SIGNAL(valueChanged(double)), this, SLOT(sampleRateChanged(double)));
// QHBoxLayout *layout = new QHBoxLayout();
// QLabel *rangeLabel = new QLabel();
@ -140,10 +144,29 @@ void SoapySDRInputGui::createRangesControl(const SoapySDR::RangeList& rangeList,
rangeGUI->reset();
m_sampleRateGUI = rangeGUI;
QVBoxLayout *layout = (QVBoxLayout *) ui->scrollAreaWidgetContents->layout();
layout->addWidget(rangeGUI);
connect(m_sampleRateGUI, SIGNAL(valueChanged(double)), this, SLOT(sampleRateChanged(double)));
}
}
void SoapySDRInputGui::createAntennasControl(const std::vector<std::string>& antennaList)
{
m_antennas = new StringRangeGUI(this);
m_antennas->setLabel(QString("Antenna"));
m_antennas->setUnits(QString("Port"));
for (const auto &it : antennaList) {
m_antennas->addItem(QString(it.c_str()), it);
}
QVBoxLayout *layout = (QVBoxLayout *) ui->scrollAreaWidgetContents->layout();
layout->addWidget(m_antennas);
connect(m_antennas, SIGNAL(valueChanged()), this, SLOT(antennasChanged()));
}
void SoapySDRInputGui::setName(const QString& name)
{
setObjectName(name);
@ -252,6 +275,14 @@ void SoapySDRInputGui::sampleRateChanged(double sampleRate)
sendSettings();
}
void SoapySDRInputGui::antennasChanged()
{
const std::string& antennaStr = m_antennas->getCurrentValue();
m_settings.m_antenna = QString(antennaStr.c_str());
sendSettings();
}
void SoapySDRInputGui::on_centerFrequency_changed(quint64 value)
{
m_settings.m_centerFrequency = value * 1000;
@ -346,6 +377,8 @@ void SoapySDRInputGui::displaySettings()
ui->LOppm->setValue(m_settings.m_LOppmTenths);
ui->LOppmText->setText(QString("%1").arg(QString::number(m_settings.m_LOppmTenths/10.0, 'f', 1)));
m_antennas->setValue(m_settings.m_antenna.toStdString());
blockApplySettings(false);
}

View File

@ -17,12 +17,13 @@
#ifndef PLUGINS_SAMPLESOURCE_SOAPYSDRINPUT_SOAPYSDRINPUTGUI_H_
#define PLUGINS_SAMPLESOURCE_SOAPYSDRINPUT_SOAPYSDRINPUTGUI_H_
#include <soapygui/stringrangegui.h>
#include <QTimer>
#include <QWidget>
#include <QComboBox>
#include "plugin/plugininstancegui.h"
#include "util/messagequeue.h"
#include "soapysdrinput.h"
class DeviceUISet;
@ -53,6 +54,8 @@ public:
private:
void createRangesControl(const SoapySDR::RangeList& rangeList, const QString& text, const QString& unit);
void createAntennasControl(const std::vector<std::string>& antennaList);
Ui::SoapySDRInputGui* ui;
DeviceUISet* m_deviceUISet;
@ -68,6 +71,7 @@ private:
MessageQueue m_inputMessageQueue;
ItemSettingGUI *m_sampleRateGUI;
StringRangeGUI *m_antennas;
void displaySettings();
void sendSettings();
@ -81,6 +85,7 @@ private slots:
void on_centerFrequency_changed(quint64 value);
void on_LOppm_valueChanged(int value);
void sampleRateChanged(double sampleRate);
void antennasChanged();
void on_dcOffset_toggled(bool checked);
void on_iqImbalance_toggled(bool checked);
void on_decim_currentIndexChanged(int index);

View File

@ -382,8 +382,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>304</width>
<height>120</height>
<width>318</width>
<height>51</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
@ -402,143 +402,6 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Data1</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox">
<item>
<property name="text">
<string>0</string>
</property>
</item>
<item>
<property name="text">
<string>1</string>
</property>
</item>
<item>
<property name="text">
<string>2</string>
</property>
</item>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Kiki</string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="horizontalSlider">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>0.0</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Tata</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>Zozo</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_2"/>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</widget>

View File

@ -35,6 +35,7 @@ void SoapySDRInputSettings::resetToDefaults()
m_transverterMode = false;
m_transverterDeltaFrequency = 0;
m_fileRecordName = "";
m_antenna = "NONE";
}
QByteArray SoapySDRInputSettings::serialize() const
@ -49,6 +50,7 @@ QByteArray SoapySDRInputSettings::serialize() const
s.writeS32(6, m_LOppmTenths);
s.writeBool(7, m_transverterMode);
s.writeS64(8, m_transverterDeltaFrequency);
s.writeString(9, m_antenna);
return s.final();
}
@ -76,6 +78,7 @@ bool SoapySDRInputSettings::deserialize(const QByteArray& data)
d.readS32(6, &m_LOppmTenths);
d.readBool(7, &m_transverterMode, false);
d.readS64(8, &m_transverterDeltaFrequency, 0);
d.readString(9, &m_antenna, "NONE");
return true;
}

View File

@ -37,6 +37,7 @@ struct SoapySDRInputSettings {
bool m_transverterMode;
qint64 m_transverterDeltaFrequency;
QString m_fileRecordName;
QString m_antenna;
SoapySDRInputSettings();
void resetToDefaults();

View File

@ -57,6 +57,7 @@ set(sdrgui_SOURCES
soapygui/discreterangegui.cpp
soapygui/intervalrangegui.cpp
soapygui/itemsettinggui.cpp
soapygui/stringrangegui.cpp
webapi/webapiadaptergui.cpp
)
@ -118,6 +119,7 @@ set(sdrgui_HEADERS
soapygui/discreterangegui.h
soapygui/intervalrangegui.h
soapygui/itemsettinggui.h
soapygui/stringrangegui.h
webapi/webapiadaptergui.h
)

View File

@ -0,0 +1,78 @@
///////////////////////////////////////////////////////////////////////////////////
// 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 "ui_discreterangegui.h"
#include "stringrangegui.h"
StringRangeGUI::StringRangeGUI(QWidget* parent) :
QWidget(parent),
ui(new Ui::DiscreteRangeGUI)
{
ui->setupUi(this);
}
StringRangeGUI::~StringRangeGUI()
{
delete ui;
}
void StringRangeGUI::setLabel(const QString& text)
{
ui->rangeLabel->setText(text);
}
void StringRangeGUI::setUnits(const QString& units)
{
ui->rangeUnits->setText(units);
}
void StringRangeGUI::addItem(const QString& itemStr, const std::string& itemValue)
{
ui->rangeCombo->blockSignals(true);
ui->rangeCombo->addItem(itemStr);
itemValues.push_back(itemValue);
ui->rangeCombo->blockSignals(false);
}
const std::string& StringRangeGUI::getCurrentValue()
{
return itemValues[ui->rangeCombo->currentIndex()];
}
void StringRangeGUI::setValue(const std::string& value)
{
int index = 0;
for (const auto &it : itemValues)
{
if (it >= value)
{
ui->rangeCombo->blockSignals(true);
ui->rangeCombo->setCurrentIndex(index);
ui->rangeCombo->blockSignals(false);
break;
}
index++;
}
}
void StringRangeGUI::on_rangeCombo_currentIndexChanged(int index __attribute__((unused)))
{
emit valueChanged();
}

View File

@ -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_STRINGRANGEGUI_H_
#define SDRGUI_SOAPYGUI_STRINGRANGEGUI_H_
#include <QWidget>
namespace Ui {
class DiscreteRangeGUI;
}
class StringRangeGUI : public QWidget
{
Q_OBJECT
public:
explicit StringRangeGUI(QWidget* parent = 0);
virtual ~StringRangeGUI();
void setLabel(const QString& text);
void setUnits(const QString& units);
void addItem(const QString& itemStr, const std::string& itemValue);
const std::string& getCurrentValue();
void setValue(const std::string& value);
signals:
void valueChanged();
private slots:
void on_rangeCombo_currentIndexChanged(int index);
private:
Ui::DiscreteRangeGUI* ui;
std::vector<std::string> itemValues;
};
#endif /* SDRGUI_SOAPYGUI_STRINGRANGEGUI_H_ */