mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-03-24 05:08:37 -04:00
LimeRFE USB support: implemented power calibration in UI
This commit is contained in:
parent
ab4f18684e
commit
cf6f8374de
@ -48,7 +48,7 @@ public:
|
||||
CellularBand38
|
||||
};
|
||||
|
||||
QMap<int, int> m_calibrations; //!< Channel range to calibration value in centi-Bels
|
||||
QMap<int, double> m_calibrations; //!< Channel range to calibration value in floating point decibels
|
||||
|
||||
private:
|
||||
void serializeCalibMap(QByteArray& data) const;
|
||||
|
@ -96,6 +96,7 @@ set(sdrgui_HEADERS
|
||||
gui/cwkeyergui.h
|
||||
gui/devicestreamselectiondialog.h
|
||||
gui/deviceuserargsdialog.h
|
||||
gui/doublevalidator.h
|
||||
gui/editcommanddialog.h
|
||||
gui/externalclockbutton.h
|
||||
gui/externalclockdialog.h
|
||||
|
59
sdrgui/gui/doublevalidator.h
Normal file
59
sdrgui/gui/doublevalidator.h
Normal file
@ -0,0 +1,59 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2020 F4EXB //
|
||||
// written by Edouard Griffiths //
|
||||
// //
|
||||
// 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 //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// 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_GUI_DOUBLEVALIDATOR_H_
|
||||
#define SDRGUI_GUI_DOUBLEVALIDATOR_H_
|
||||
|
||||
#include <QDoubleValidator>
|
||||
|
||||
class DoubleValidator : public QDoubleValidator
|
||||
{
|
||||
public:
|
||||
DoubleValidator(double bottom, double top, int decimals, QObject * parent) :
|
||||
QDoubleValidator(bottom, top, decimals, parent)
|
||||
{
|
||||
}
|
||||
|
||||
QValidator::State validate(QString &s, int &i) const
|
||||
{
|
||||
if (s.isEmpty() || s == "-") {
|
||||
return QValidator::Intermediate;
|
||||
}
|
||||
|
||||
QChar decimalPoint = locale().decimalPoint();
|
||||
|
||||
if(s.indexOf(decimalPoint) != -1) {
|
||||
int charsAfterPoint = s.length() - s.indexOf(decimalPoint) - 1;
|
||||
|
||||
if (charsAfterPoint > decimals()) {
|
||||
return QValidator::Invalid;
|
||||
}
|
||||
}
|
||||
|
||||
bool ok;
|
||||
double d = locale().toDouble(s, &ok);
|
||||
|
||||
if (ok && d >= bottom() && d <= top()) {
|
||||
return QValidator::Acceptable;
|
||||
} else {
|
||||
return QValidator::Invalid;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endif // SDRGUI_GUI_DOUBLEVALIDATOR_H_
|
@ -20,16 +20,19 @@
|
||||
#include "util/serialutil.h"
|
||||
#include "util/db.h"
|
||||
#include "dsp/dspengine.h"
|
||||
#include "gui/doublevalidator.h"
|
||||
|
||||
#include "limerfeusbdialog.h"
|
||||
#include "ui_limerfeusbdialog.h"
|
||||
|
||||
LimeRFEUSBDialog::LimeRFEUSBDialog(QWidget* parent) :
|
||||
LimeRFEUSBDialog::LimeRFEUSBDialog(LimeRFEUSBCalib& limeRFEUSBCalib, QWidget* parent) :
|
||||
m_limeRFEUSBCalib(limeRFEUSBCalib),
|
||||
QDialog(parent),
|
||||
ui(new Ui::LimeRFEUSBDialog),
|
||||
m_rxTxToggle(false)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->powerCorrValue->setValidator(new DoubleValidator(-99.9, 99.9, 1, ui->powerCorrValue));
|
||||
std::vector<std::string> comPorts;
|
||||
SerialUtil::getComPorts(comPorts, "ttyUSB[0-9]+"); // regex is for Linux only
|
||||
|
||||
@ -109,8 +112,10 @@ void LimeRFEUSBDialog::displayPower()
|
||||
{
|
||||
ui->powerEnable->blockSignals(true);
|
||||
ui->powerSource->blockSignals(true);
|
||||
|
||||
ui->powerEnable->setChecked(m_settings.m_swrEnable);
|
||||
ui->powerSource->setCurrentIndex((int) m_settings.m_swrSource);
|
||||
|
||||
ui->powerEnable->blockSignals(false);
|
||||
ui->powerSource->blockSignals(false);
|
||||
}
|
||||
@ -154,6 +159,8 @@ void LimeRFEUSBDialog::refreshPower()
|
||||
vswr = vswr < 0.0 ? 0.0 : vswr > 99.999 ? 99.999 : vswr;
|
||||
ui->swrText->setText(QString::number(vswr, 'f', 3));
|
||||
}
|
||||
|
||||
updateAbsPower(m_currentPowerCorrection);
|
||||
}
|
||||
|
||||
void LimeRFEUSBDialog::setRxChannels()
|
||||
@ -238,6 +245,8 @@ void LimeRFEUSBDialog::setTxChannels()
|
||||
{
|
||||
ui->txChannel->blockSignals(true);
|
||||
ui->txPort->blockSignals(true);
|
||||
ui->powerCorrValue->blockSignals(true);
|
||||
|
||||
ui->txChannel->clear();
|
||||
ui->txPort->clear();
|
||||
|
||||
@ -305,10 +314,128 @@ void LimeRFEUSBDialog::setTxChannels()
|
||||
}
|
||||
|
||||
ui->txChannelGroup->setCurrentIndex((int) m_settings.m_txChannels);
|
||||
m_currentPowerCorrection = getPowerCorrection();
|
||||
ui->powerCorrValue->setText(QString::number(m_currentPowerCorrection, 'f', 1));
|
||||
updateAbsPower(m_currentPowerCorrection);
|
||||
|
||||
ui->powerCorrValue->blockSignals(false);
|
||||
ui->txPort->blockSignals(false);
|
||||
ui->txChannel->blockSignals(false);
|
||||
}
|
||||
|
||||
int LimeRFEUSBDialog::getPowerCorectionIndex()
|
||||
{
|
||||
LimeRFEUSBCalib::ChannelRange range;
|
||||
|
||||
switch (m_settings.m_txChannels)
|
||||
{
|
||||
case LimeRFEController::ChannelsWideband:
|
||||
{
|
||||
switch (m_settings.m_txWidebandChannel)
|
||||
{
|
||||
case LimeRFEController::WidebandLow:
|
||||
range = LimeRFEUSBCalib::WidebandLow;
|
||||
break;
|
||||
case LimeRFEController::WidebandHigh:
|
||||
range = LimeRFEUSBCalib::WidebandHigh;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case LimeRFEController::ChannelsHAM:
|
||||
{
|
||||
switch (m_settings.m_txHAMChannel)
|
||||
{
|
||||
case LimeRFEController::HAM_30M:
|
||||
range = LimeRFEUSBCalib::HAM_30MHz;
|
||||
break;
|
||||
case LimeRFEController::HAM_50_70MHz:
|
||||
range = LimeRFEUSBCalib::HAM_50_70MHz;
|
||||
break;
|
||||
case LimeRFEController::HAM_144_146MHz:
|
||||
range = LimeRFEUSBCalib::HAM_144_146MHz;
|
||||
break;
|
||||
case LimeRFEController::HAM_220_225MHz:
|
||||
range = LimeRFEUSBCalib::HAM_220_225MHz;
|
||||
break;
|
||||
case LimeRFEController::HAM_430_440MHz:
|
||||
range = LimeRFEUSBCalib::HAM_430_440MHz;
|
||||
break;
|
||||
case LimeRFEController::HAM_902_928MHz:
|
||||
range = LimeRFEUSBCalib::HAM_902_928MHz;
|
||||
break;
|
||||
case LimeRFEController::HAM_1240_1325MHz:
|
||||
range = LimeRFEUSBCalib::HAM_1240_1325MHz;
|
||||
break;
|
||||
case LimeRFEController::HAM_2300_2450MHz:
|
||||
range = LimeRFEUSBCalib::HAM_2300_2450MHz;
|
||||
break;
|
||||
case LimeRFEController::HAM_3300_3500MHz:
|
||||
range = LimeRFEUSBCalib::HAM_3300_3500MHz;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case LimeRFEController::ChannelsCellular:
|
||||
{
|
||||
switch (m_settings.m_txCellularChannel)
|
||||
{
|
||||
case LimeRFEController::CellularBand1:
|
||||
range = LimeRFEUSBCalib::CellularBand1;
|
||||
break;
|
||||
case LimeRFEController::CellularBand2:
|
||||
range = LimeRFEUSBCalib::CellularBand2;
|
||||
break;
|
||||
case LimeRFEController::CellularBand7:
|
||||
range = LimeRFEUSBCalib::CellularBand7;
|
||||
break;
|
||||
case LimeRFEController::CellularBand38:
|
||||
range = LimeRFEUSBCalib::CellularBand38;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return -1;
|
||||
break;
|
||||
}
|
||||
|
||||
return (int) range;
|
||||
}
|
||||
|
||||
double LimeRFEUSBDialog::getPowerCorrection()
|
||||
{
|
||||
int index = getPowerCorectionIndex();
|
||||
|
||||
QMap<int, double>::const_iterator it = m_limeRFEUSBCalib.m_calibrations.find(index);
|
||||
|
||||
if (it != m_limeRFEUSBCalib.m_calibrations.end()) {
|
||||
return it.value();
|
||||
} else {
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
void LimeRFEUSBDialog::setPowerCorrection(double dbValue)
|
||||
{
|
||||
int index = getPowerCorectionIndex();
|
||||
|
||||
if (index < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_limeRFEUSBCalib.m_calibrations[index] = dbValue;
|
||||
}
|
||||
|
||||
void LimeRFEUSBDialog::on_openDevice_clicked()
|
||||
{
|
||||
int rc = m_controller.openDevice(ui->device->currentText().toStdString());
|
||||
@ -447,6 +574,34 @@ void LimeRFEUSBDialog::on_powerAutoRefresh_toggled(bool checked)
|
||||
}
|
||||
}
|
||||
|
||||
void LimeRFEUSBDialog::on_powerCorrValue_textEdited(const QString &text)
|
||||
{
|
||||
bool ok;
|
||||
double powerCorrection = text.toDouble(&ok);
|
||||
|
||||
if (ok)
|
||||
{
|
||||
setPowerCorrection(powerCorrection);
|
||||
m_currentPowerCorrection = powerCorrection;
|
||||
updateAbsPower(powerCorrection);
|
||||
}
|
||||
}
|
||||
|
||||
void LimeRFEUSBDialog::updateAbsPower(double powerCorrDB)
|
||||
{
|
||||
bool ok;
|
||||
double power = ui->powerFwdText->text().toDouble(&ok);
|
||||
|
||||
if (ok)
|
||||
{
|
||||
double powerCorrected = power + powerCorrDB;
|
||||
ui->powerAbsDbText->setText(QString::number(powerCorrected, 'f', 1));
|
||||
double powerMilliwatts = CalcDb::powerFromdB(powerCorrected);
|
||||
powerMilliwatts = powerMilliwatts > 8000.0 ? 8000.0 : powerMilliwatts;
|
||||
ui->powerAbsWText->setText(QString::number(powerMilliwatts/1000.0, 'f', 3));
|
||||
}
|
||||
}
|
||||
|
||||
void LimeRFEUSBDialog::on_modeRx_toggled(bool checked)
|
||||
{
|
||||
int rc;
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <QTimer>
|
||||
|
||||
#include "limerfe/limerfecontroller.h"
|
||||
#include "limerfe/limerfeusbcalib.h"
|
||||
#include "export.h"
|
||||
|
||||
namespace Ui {
|
||||
@ -33,7 +34,7 @@ class SDRGUI_API LimeRFEUSBDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit LimeRFEUSBDialog(QWidget* parent = nullptr);
|
||||
explicit LimeRFEUSBDialog(LimeRFEUSBCalib& limeRFEUSBCalib, QWidget* parent = nullptr);
|
||||
~LimeRFEUSBDialog();
|
||||
|
||||
private:
|
||||
@ -43,12 +44,18 @@ private:
|
||||
void refreshPower();
|
||||
void setRxChannels();
|
||||
void setTxChannels();
|
||||
int getPowerCorectionIndex();
|
||||
double getPowerCorrection();
|
||||
void setPowerCorrection(double dbValue);
|
||||
void updateAbsPower(double powerCorrDB);
|
||||
|
||||
Ui::LimeRFEUSBDialog* ui;
|
||||
LimeRFEController m_controller;
|
||||
LimeRFEController::LimeRFESettings m_settings;
|
||||
LimeRFEUSBCalib& m_limeRFEUSBCalib;
|
||||
bool m_rxTxToggle;
|
||||
QTimer m_timer;
|
||||
double m_currentPowerCorrection;
|
||||
|
||||
private slots:
|
||||
void on_openDevice_clicked();
|
||||
@ -65,6 +72,7 @@ private slots:
|
||||
void on_powerSource_currentIndexChanged(int index);
|
||||
void on_powerRefresh_clicked();
|
||||
void on_powerAutoRefresh_toggled(bool checked);
|
||||
void on_powerCorrValue_textEdited(const QString &text);
|
||||
void on_modeRx_toggled(bool checked);
|
||||
void on_modeTx_toggled(bool checked);
|
||||
void on_rxTxToggle_clicked();
|
||||
|
@ -551,7 +551,7 @@
|
||||
<widget class="QLabel" name="powerFwdLabel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>120</x>
|
||||
<x>180</x>
|
||||
<y>250</y>
|
||||
<width>31</width>
|
||||
<height>17</height>
|
||||
@ -564,7 +564,7 @@
|
||||
<widget class="QLabel" name="powerRefLabel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>170</x>
|
||||
<x>230</x>
|
||||
<y>250</y>
|
||||
<width>31</width>
|
||||
<height>17</height>
|
||||
@ -577,7 +577,7 @@
|
||||
<widget class="QLabel" name="powerRefText">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>170</x>
|
||||
<x>230</x>
|
||||
<y>270</y>
|
||||
<width>35</width>
|
||||
<height>17</height>
|
||||
@ -596,7 +596,7 @@
|
||||
<widget class="QLabel" name="powerFwdText">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>120</x>
|
||||
<x>180</x>
|
||||
<y>270</y>
|
||||
<width>35</width>
|
||||
<height>17</height>
|
||||
@ -615,7 +615,7 @@
|
||||
<widget class="QLabel" name="powerUnits">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>260</x>
|
||||
<x>320</x>
|
||||
<y>270</y>
|
||||
<width>25</width>
|
||||
<height>17</height>
|
||||
@ -631,7 +631,7 @@
|
||||
<widget class="QLabel" name="returnLossLabel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>220</x>
|
||||
<x>280</x>
|
||||
<y>250</y>
|
||||
<width>31</width>
|
||||
<height>17</height>
|
||||
@ -644,7 +644,7 @@
|
||||
<widget class="QLabel" name="returnLossText">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>220</x>
|
||||
<x>280</x>
|
||||
<y>270</y>
|
||||
<width>35</width>
|
||||
<height>17</height>
|
||||
@ -699,7 +699,7 @@
|
||||
<widget class="QLabel" name="swrLabel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>300</x>
|
||||
<x>360</x>
|
||||
<y>250</y>
|
||||
<width>45</width>
|
||||
<height>17</height>
|
||||
@ -748,7 +748,7 @@
|
||||
<widget class="QLabel" name="swrText">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>290</x>
|
||||
<x>350</x>
|
||||
<y>270</y>
|
||||
<width>50</width>
|
||||
<height>17</height>
|
||||
@ -787,6 +787,95 @@
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
<widget class="QLabel" name="powerCorrLabel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>120</x>
|
||||
<y>260</y>
|
||||
<width>31</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Corr</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="powerAbsDbText">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>170</x>
|
||||
<y>290</y>
|
||||
<width>45</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Corrected forward power in dB</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>-00.0</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="powerAbsWText">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>220</x>
|
||||
<y>290</y>
|
||||
<width>45</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Corrected forward power in Watts</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>0.000</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="powerAbsUnits">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>280</x>
|
||||
<y>290</y>
|
||||
<width>15</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>W</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="powerCorrValue">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>110</x>
|
||||
<y>280</y>
|
||||
<width>55</width>
|
||||
<height>27</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::ClickFocus</enum>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Power correction in dBm</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>-00.0</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
@ -1613,7 +1613,7 @@ void MainWindow::on_action_LimeRFE_triggered()
|
||||
qDebug("MainWindow::on_action_LimeRFE_triggered");
|
||||
#if defined(HAS_LIMERFE)
|
||||
qDebug("MainWindow::on_action_LimeRFE_triggered: activated");
|
||||
LimeRFEUSBDialog *limeRFEUSBDialog = new LimeRFEUSBDialog(this);
|
||||
LimeRFEUSBDialog *limeRFEUSBDialog = new LimeRFEUSBDialog(m_settings.getLimeRFEUSBCalib(), this);
|
||||
limeRFEUSBDialog->setModal(false);
|
||||
limeRFEUSBDialog->show();
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user