From 98b79de593f8ebcc27a319a4a2ba0e84be5ca7f3 Mon Sep 17 00:00:00 2001 From: f4exb Date: Thu, 8 Nov 2018 14:35:02 +0100 Subject: [PATCH] SoapySDR support: added GUI for complex factors (manual DC offset and IQ imbalance settings) --- sdrgui/CMakeLists.txt | 3 + sdrgui/soapygui/complexfactorgui.cpp | 88 +++++++++++++ sdrgui/soapygui/complexfactorgui.h | 65 ++++++++++ sdrgui/soapygui/complexfactorgui.ui | 183 +++++++++++++++++++++++++++ 4 files changed, 339 insertions(+) create mode 100644 sdrgui/soapygui/complexfactorgui.cpp create mode 100644 sdrgui/soapygui/complexfactorgui.h create mode 100644 sdrgui/soapygui/complexfactorgui.ui diff --git a/sdrgui/CMakeLists.txt b/sdrgui/CMakeLists.txt index 2914b29b5..f401299f2 100644 --- a/sdrgui/CMakeLists.txt +++ b/sdrgui/CMakeLists.txt @@ -60,6 +60,7 @@ set(sdrgui_SOURCES soapygui/stringrangegui.cpp soapygui/dynamicitemsettinggui.cpp soapygui/intervalslidergui.cpp + soapygui/complexfactorgui.cpp webapi/webapiadaptergui.cpp ) @@ -124,6 +125,7 @@ set(sdrgui_HEADERS soapygui/stringrangegui.h soapygui/dynamicitemsettinggui.h soapygui/intervalslidergui.h + soapygui/complexfactorgui.h webapi/webapiadaptergui.h ) @@ -156,6 +158,7 @@ set(sdrgui_FORMS soapygui/discreterangegui.ui soapygui/intervalrangegui.ui soapygui/intervalslidergui.ui + soapygui/complexfactorgui.ui ) set(sdrgui_RESOURCES diff --git a/sdrgui/soapygui/complexfactorgui.cpp b/sdrgui/soapygui/complexfactorgui.cpp new file mode 100644 index 000000000..c83920301 --- /dev/null +++ b/sdrgui/soapygui/complexfactorgui.cpp @@ -0,0 +1,88 @@ +/////////////////////////////////////////////////////////////////////////////////// +// 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 . // +/////////////////////////////////////////////////////////////////////////////////// + +#include "ui_complexfactorgui.h" +#include "complexfactorgui.h" + +ComplexFactorGUI::ComplexFactorGUI(QWidget *parent) : + QWidget(parent), + ui(new Ui::ComplexFactorGUI) +{ + ui->setupUi(this); + ui->automatic->setChecked(false); +} + +ComplexFactorGUI::~ComplexFactorGUI() +{ + delete ui; +} + +double ComplexFactorGUI::getModule() const +{ + return ui->module->value() / 100.0; +} + +double ComplexFactorGUI::getArgument() const +{ + return ui->arg->value() * 1.0; +} + +bool ComplexFactorGUI::getAutomatic() const +{ + return ui->automatic->isChecked(); +} + +void ComplexFactorGUI::setModule(double value) +{ + ui->module->setValue((int) (value < -1.0 ? -1.0 : value > 1.0 ? 1.0 : value)*100.0f); +} + +void ComplexFactorGUI::setArgument(double value) +{ + ui->module->setValue((int) (value < -180.0 ? -180.0 : value > 180.0 ? 180.0 : value)); +} + +void ComplexFactorGUI::setAutomatic(bool automatic) +{ + ui->automatic->setChecked(automatic); +} + +void ComplexFactorGUI::setAutomaticEnable(bool enable) +{ + ui->automatic->setEnabled(enable); +} + +void ComplexFactorGUI::setLabel(const QString& text) +{ + ui->label->setText(text); +} + +void ComplexFactorGUI::on_automatic_toggled(bool set) +{ + ui->module->setEnabled(!set); + ui->arg->setEnabled(!set); + emit automaticChanged(set); +} + +void ComplexFactorGUI::on_module_valueChanged(int value) +{ + emit moduleChanged(value / 100.0f); +} + +void ComplexFactorGUI::on_arg_valueChanged(int value) +{ + emit argumentChanged(value); +} \ No newline at end of file diff --git a/sdrgui/soapygui/complexfactorgui.h b/sdrgui/soapygui/complexfactorgui.h new file mode 100644 index 000000000..d5eb7dfdc --- /dev/null +++ b/sdrgui/soapygui/complexfactorgui.h @@ -0,0 +1,65 @@ +/////////////////////////////////////////////////////////////////////////////////// +// 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 . // +/////////////////////////////////////////////////////////////////////////////////// + +// This is an interface to an elementary GUI item used to get/set a normalized complex value from the GUI +// There is an automatic check to activate/deactivate possible automatic setting +// It is intended to be used primarily for DC offset and IQ imbalance corrections + +#ifndef PLUGINS_SAMPLESOURCE_SOAPYSDRINPUT_COMPLEXFACTORGUI_H_ +#define PLUGINS_SAMPLESOURCE_SOAPYSDRINPUT_COMPLEXFACTORGUI_H_ + +#include +#include + +#include "export.h" + +namespace Ui { + class ComplexFactorGUI; +} + +class SDRGUI_API ComplexFactorGUI : public QWidget +{ + Q_OBJECT +public: + explicit ComplexFactorGUI(QWidget *parent = 0); + ~ComplexFactorGUI(); + + double getModule() const; + double getArgument() const; + bool getAutomatic() const; + + void setModule(double value); + void setArgument(double value); + void setAutomatic(bool automatic); + void setAutomaticEnable(bool enable); + + void setLabel(const QString& text); + +signals: + void moduleChanged(double value); + void argumentChanged(double value); + void automaticChanged(bool value); + +private slots: + void on_automatic_toggled(bool set); + void on_module_valueChanged(int value); + void on_arg_valueChanged(int value); + +private: + Ui::ComplexFactorGUI* ui; +}; + +#endif /* PLUGINS_SAMPLESOURCE_SOAPYSDRINPUT_COMPLEXFACTORGUI_H_ */ diff --git a/sdrgui/soapygui/complexfactorgui.ui b/sdrgui/soapygui/complexfactorgui.ui new file mode 100644 index 000000000..01d5b1b3a --- /dev/null +++ b/sdrgui/soapygui/complexfactorgui.ui @@ -0,0 +1,183 @@ + + + ComplexFactorGUI + + + + 0 + 0 + 307 + 51 + + + + + 0 + 0 + + + + + 0 + 30 + + + + Form + + + + + 0 + 0 + 301 + 48 + + + + + 8 + + + + + + 40 + 0 + + + + Label + + + + + + + Qt::RightToLeft + + + Auto + + + + + + + 6 + + + 6 + + + + + + + + 32 + 0 + + + + Mod + + + + + + + Normalized module + + + -100 + + + 100 + + + 1 + + + Qt::Horizontal + + + + + + + + 40 + 0 + + + + -1.00 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + 32 + 0 + + + + Arg + + + + + + + Argument (angle) in degrees + + + -180 + + + 180 + + + 1 + + + Qt::Horizontal + + + + + + + + 40 + 0 + + + + -180 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + +