diff --git a/sdrgui/limerfegui/limerfeusbdialog.cpp b/sdrgui/limerfegui/limerfeusbdialog.cpp index b67048ec1..cd6cbaa28 100644 --- a/sdrgui/limerfegui/limerfeusbdialog.cpp +++ b/sdrgui/limerfegui/limerfeusbdialog.cpp @@ -18,6 +18,7 @@ #include #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(); +} \ No newline at end of file diff --git a/sdrgui/limerfegui/limerfeusbdialog.h b/sdrgui/limerfegui/limerfeusbdialog.h index 280e0d644..591d8ca1d 100644 --- a/sdrgui/limerfegui/limerfeusbdialog.h +++ b/sdrgui/limerfegui/limerfeusbdialog.h @@ -20,6 +20,7 @@ #define SDRGUI_LIMERFEGUI_LIMERFEUSBDIALOG_H_ #include +#include #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_ diff --git a/sdrgui/limerfegui/limerfeusbdialog.ui b/sdrgui/limerfegui/limerfeusbdialog.ui index abd4482ec..67c523084 100644 --- a/sdrgui/limerfegui/limerfeusbdialog.ui +++ b/sdrgui/limerfegui/limerfeusbdialog.ui @@ -7,7 +7,7 @@ 0 0 411 - 436 + 499 @@ -17,7 +17,7 @@ 310 - 390 + 460 81 32 @@ -423,7 +423,7 @@ - + 0 @@ -440,7 +440,7 @@ 10 - 280 + 350 51 27 @@ -459,7 +459,7 @@ 70 - 280 + 350 51 27 @@ -477,8 +477,8 @@ - 80 - 250 + 70 + 320 111 27 @@ -494,8 +494,8 @@ 10 - 250 - 91 + 320 + 50 27 @@ -507,7 +507,7 @@ 10 - 390 + 460 71 27 @@ -523,7 +523,7 @@ 10 - 320 + 390 391 61 @@ -536,7 +536,7 @@ 130 - 280 + 350 71 27 @@ -548,7 +548,253 @@ Toggle + + + + 120 + 250 + 31 + 17 + + + + Fwd + + + + + + 170 + 250 + 31 + 17 + + + + Ref + + + + + + 170 + 270 + 35 + 17 + + + + Relative reflected power in dB + + + 00.0 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 120 + 270 + 35 + 17 + + + + Relative forward power in dB + + + 00.0 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 260 + 270 + 25 + 17 + + + + dB + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 220 + 250 + 31 + 17 + + + + RL + + + + + + 220 + 270 + 35 + 17 + + + + Return loss in dB + + + 00.0 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 10 + 250 + 50 + 27 + + + + Enable power measurements + + + Pwr + + + + + + 80 + 250 + 24 + 24 + + + + Refresh power + + + + + + + :/recycle.png:/recycle.png + + + + + + 300 + 250 + 45 + 17 + + + + VSWR + + + + + + 0 + 310 + 401 + 16 + + + + Qt::Horizontal + + + + + + 80 + 280 + 24 + 24 + + + + Auto refresh power + + + + + + + :/play.png:/play.png + + + true + + + + + + 290 + 270 + 50 + 17 + + + + Voltage Standing Wave Ratio + + + 1.000 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 10 + 280 + 60 + 25 + + + + Power measurement source (EXTernal, CELlular) + + + + EXT + + + + + CEL + + + + + + ButtonSwitch + QToolButton +
gui/buttonswitch.h
+
+