1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-09-28 07:46:37 -04:00

LimeRFE USB: support power measurement in UI

This commit is contained in:
f4exb 2020-01-16 01:25:53 +01:00
parent 96abae1fc0
commit 6f14d21b1f
3 changed files with 356 additions and 13 deletions

View File

@ -18,6 +18,7 @@
#include <vector>
#include "util/serialutil.h"
#include "util/db.h"
#include "dsp/dspengine.h"
#include "limerfeusbdialog.h"
@ -37,6 +38,7 @@ LimeRFEUSBDialog::LimeRFEUSBDialog(QWidget* parent) :
}
displaySettings(); // default values
m_timer.setInterval(1000);
}
LimeRFEUSBDialog::~LimeRFEUSBDialog()
@ -55,6 +57,7 @@ void LimeRFEUSBDialog::displaySettings()
ui->txFollowsRx->setChecked(m_settings.m_txRxDriven);
ui->rxTxToggle->setChecked(m_rxTxToggle);
displayMode();
displayPower();
}
void LimeRFEUSBDialog::displayMode()
@ -102,6 +105,57 @@ void LimeRFEUSBDialog::displayMode()
ui->modeTx->blockSignals(false);
}
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);
}
void LimeRFEUSBDialog::refreshPower()
{
int fwdPower, refPower;
int rc = m_controller.getFwdPower(fwdPower);
if (rc != 0)
{
ui->statusText->setText(m_controller.getError(rc).c_str());
return;
}
rc = m_controller.getRefPower(refPower);
if (rc != 0)
{
ui->statusText->setText(m_controller.getError(rc).c_str());
return;
}
double fwdPowerDB = fwdPower / 10.0;
double refPowerDB = refPower / 10.0;
double retLossDB = fwdPowerDB - refPowerDB;
ui->powerFwdText->setText(QString::number(fwdPowerDB, 'f', 1));
ui->powerRefText->setText(QString::number(refPowerDB, 'f', 1));
ui->returnLossText->setText(QString::number(retLossDB, 'f', 1));
double denom = CalcDb::powerFromdB(retLossDB/2.0) - 1.0;
if (denom == 0.0)
{
ui->swrText->setText("---");
}
else
{
double vswr = (CalcDb::powerFromdB(retLossDB/2.0) + 1.0) / denom;
vswr = vswr < 0.0 ? 0.0 : vswr > 99.999 ? 99.999 : vswr;
ui->swrText->setText(QString::number(vswr, 'f', 3));
}
}
void LimeRFEUSBDialog::setRxChannels()
{
ui->rxChannel->blockSignals(true);
@ -272,7 +326,7 @@ void LimeRFEUSBDialog::on_closeDevice_clicked()
{
ui->statusText->clear();
m_controller.closeDevice();
ui->statusText->setText("Cloed");
ui->statusText->setText("Closed");
}
void LimeRFEUSBDialog::on_deviceToGUI_clicked()
@ -364,6 +418,35 @@ void LimeRFEUSBDialog::on_txPort_currentIndexChanged(int index)
m_settings.m_txPort = (LimeRFEController::TxPort) index;
}
void LimeRFEUSBDialog::on_powerEnable_clicked()
{
m_settings.m_swrEnable = ui->powerEnable->isChecked();
}
void LimeRFEUSBDialog::on_powerSource_currentIndexChanged(int index)
{
m_settings.m_swrSource = (LimeRFEController::SWRSource) index;
}
void LimeRFEUSBDialog::on_powerRefresh_clicked()
{
refreshPower();
}
void LimeRFEUSBDialog::on_powerAutoRefresh_toggled(bool checked)
{
if (checked)
{
connect(&m_timer, SIGNAL(timeout()), this, SLOT(tick()));
m_timer.start();
}
else
{
m_timer.stop();
disconnect(&m_timer, SIGNAL(timeout()), this, SLOT(tick()));
}
}
void LimeRFEUSBDialog::on_modeRx_toggled(bool checked)
{
int rc;
@ -452,3 +535,8 @@ void LimeRFEUSBDialog::on_apply_clicked()
int rc = m_controller.configure();
ui->statusText->setText(m_controller.getError(rc).c_str());
}
void LimeRFEUSBDialog::tick()
{
refreshPower();
}

View File

@ -20,6 +20,7 @@
#define SDRGUI_LIMERFEGUI_LIMERFEUSBDIALOG_H_
#include <QDialog>
#include <QTimer>
#include "limerfe/limerfecontroller.h"
#include "export.h"
@ -38,6 +39,8 @@ public:
private:
void displaySettings();
void displayMode();
void displayPower();
void refreshPower();
void setRxChannels();
void setTxChannels();
@ -45,6 +48,7 @@ private:
LimeRFEController m_controller;
LimeRFEController::LimeRFESettings m_settings;
bool m_rxTxToggle;
QTimer m_timer;
private slots:
void on_openDevice_clicked();
@ -57,10 +61,15 @@ private slots:
void on_txChannelGroup_currentIndexChanged(int index);
void on_txChannel_currentIndexChanged(int index);
void on_txPort_currentIndexChanged(int index);
void on_powerEnable_clicked();
void on_powerSource_currentIndexChanged(int index);
void on_powerRefresh_clicked();
void on_powerAutoRefresh_toggled(bool checked);
void on_modeRx_toggled(bool checked);
void on_modeTx_toggled(bool checked);
void on_rxTxToggle_clicked();
void on_apply_clicked();
void tick();
};
#endif // SDRGUI_LIMERFEGUI_LIMERFEUSBDIALOG_H_

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>411</width>
<height>436</height>
<height>499</height>
</rect>
</property>
<property name="windowTitle">
@ -17,7 +17,7 @@
<property name="geometry">
<rect>
<x>310</x>
<y>390</y>
<y>460</y>
<width>81</width>
<height>32</height>
</rect>
@ -423,7 +423,7 @@
</property>
</item>
</widget>
<widget class="Line" name="modeSeparaor">
<widget class="Line" name="powerSeparator">
<property name="geometry">
<rect>
<x>0</x>
@ -440,7 +440,7 @@
<property name="geometry">
<rect>
<x>10</x>
<y>280</y>
<y>350</y>
<width>51</width>
<height>27</height>
</rect>
@ -459,7 +459,7 @@
<property name="geometry">
<rect>
<x>70</x>
<y>280</y>
<y>350</y>
<width>51</width>
<height>27</height>
</rect>
@ -477,8 +477,8 @@
<widget class="QLabel" name="modeText">
<property name="geometry">
<rect>
<x>80</x>
<y>250</y>
<x>70</x>
<y>320</y>
<width>111</width>
<height>27</height>
</rect>
@ -494,8 +494,8 @@
<property name="geometry">
<rect>
<x>10</x>
<y>250</y>
<width>91</width>
<y>320</y>
<width>50</width>
<height>27</height>
</rect>
</property>
@ -507,7 +507,7 @@
<property name="geometry">
<rect>
<x>10</x>
<y>390</y>
<y>460</y>
<width>71</width>
<height>27</height>
</rect>
@ -523,7 +523,7 @@
<property name="geometry">
<rect>
<x>10</x>
<y>320</y>
<y>390</y>
<width>391</width>
<height>61</height>
</rect>
@ -536,7 +536,7 @@
<property name="geometry">
<rect>
<x>130</x>
<y>280</y>
<y>350</y>
<width>71</width>
<height>27</height>
</rect>
@ -548,7 +548,253 @@
<string>Toggle</string>
</property>
</widget>
<widget class="QLabel" name="powerFwdLabel">
<property name="geometry">
<rect>
<x>120</x>
<y>250</y>
<width>31</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>Fwd</string>
</property>
</widget>
<widget class="QLabel" name="powerRefLabel">
<property name="geometry">
<rect>
<x>170</x>
<y>250</y>
<width>31</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>Ref</string>
</property>
</widget>
<widget class="QLabel" name="powerRefText">
<property name="geometry">
<rect>
<x>170</x>
<y>270</y>
<width>35</width>
<height>17</height>
</rect>
</property>
<property name="toolTip">
<string>Relative reflected 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="powerFwdText">
<property name="geometry">
<rect>
<x>120</x>
<y>270</y>
<width>35</width>
<height>17</height>
</rect>
</property>
<property name="toolTip">
<string>Relative 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="powerUnits">
<property name="geometry">
<rect>
<x>260</x>
<y>270</y>
<width>25</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>dB</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
<widget class="QLabel" name="returnLossLabel">
<property name="geometry">
<rect>
<x>220</x>
<y>250</y>
<width>31</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>RL</string>
</property>
</widget>
<widget class="QLabel" name="returnLossText">
<property name="geometry">
<rect>
<x>220</x>
<y>270</y>
<width>35</width>
<height>17</height>
</rect>
</property>
<property name="toolTip">
<string>Return loss 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="QCheckBox" name="powerEnable">
<property name="geometry">
<rect>
<x>10</x>
<y>250</y>
<width>50</width>
<height>27</height>
</rect>
</property>
<property name="toolTip">
<string>Enable power measurements</string>
</property>
<property name="text">
<string>Pwr</string>
</property>
</widget>
<widget class="QPushButton" name="powerRefresh">
<property name="geometry">
<rect>
<x>80</x>
<y>250</y>
<width>24</width>
<height>24</height>
</rect>
</property>
<property name="toolTip">
<string>Refresh power</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../resources/res.qrc">
<normaloff>:/recycle.png</normaloff>:/recycle.png</iconset>
</property>
</widget>
<widget class="QLabel" name="swrLabel">
<property name="geometry">
<rect>
<x>300</x>
<y>250</y>
<width>45</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>VSWR</string>
</property>
</widget>
<widget class="Line" name="modeSeparator">
<property name="geometry">
<rect>
<x>0</x>
<y>310</y>
<width>401</width>
<height>16</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="ButtonSwitch" name="powerAutoRefresh">
<property name="geometry">
<rect>
<x>80</x>
<y>280</y>
<width>24</width>
<height>24</height>
</rect>
</property>
<property name="toolTip">
<string>Auto refresh power</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../resources/res.qrc">
<normaloff>:/play.png</normaloff>:/play.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="swrText">
<property name="geometry">
<rect>
<x>290</x>
<y>270</y>
<width>50</width>
<height>17</height>
</rect>
</property>
<property name="toolTip">
<string>Voltage Standing Wave Ratio</string>
</property>
<property name="text">
<string>1.000</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
<widget class="QComboBox" name="powerSource">
<property name="geometry">
<rect>
<x>10</x>
<y>280</y>
<width>60</width>
<height>25</height>
</rect>
</property>
<property name="toolTip">
<string>Power measurement source (EXTernal, CELlular)</string>
</property>
<item>
<property name="text">
<string>EXT</string>
</property>
</item>
<item>
<property name="text">
<string>CEL</string>
</property>
</item>
</widget>
</widget>
<customwidgets>
<customwidget>
<class>ButtonSwitch</class>
<extends>QToolButton</extends>
<header>gui/buttonswitch.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../resources/res.qrc"/>
</resources>