From ded26cb8d6c4079caa7213e495527432cf979249 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=A4berich?= Date: Fri, 22 Aug 2025 19:36:16 +0200 Subject: [PATCH] configuration dialog for HW 0xFD --- .../LibreVNA/deviceconfigurationdialogvfd.cpp | 79 + .../LibreVNA/deviceconfigurationdialogvfd.h | 31 + .../LibreVNA/deviceconfigurationdialogvfd.ui | 1407 +++++++++++++++++ .../Device/LibreVNA/librevnadriver.cpp | 4 + .../Device/LibreVNA/librevnausbdriver.cpp | 2 +- .../LibreVNA-GUI/LibreVNA-GUI.pro | 3 + .../LibreVNA-Test/LibreVNA-Test.pro | 3 + .../Application/Communication/Protocol.hpp | 11 + 8 files changed, 1539 insertions(+), 1 deletion(-) create mode 100644 Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvfd.cpp create mode 100644 Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvfd.h create mode 100644 Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvfd.ui diff --git a/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvfd.cpp b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvfd.cpp new file mode 100644 index 0000000..588e0fc --- /dev/null +++ b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvfd.cpp @@ -0,0 +1,79 @@ +#include "deviceconfigurationdialogvfd.h" +#include "ui_deviceconfigurationdialogvfd.h" + +#include + +DeviceConfigurationDialogVFD::DeviceConfigurationDialogVFD(LibreVNADriver &dev, QWidget *parent) : + QDialog(parent), + ui(new Ui::DeviceConfigurationDialogVFD), + dev(dev) +{ + ui->setupUi(this); + setAttribute(Qt::WA_DeleteOnClose); + + emit dev.acquireControl(); + + ui->IF->setPrecision(8); + ui->IF->setUnit("Hz"); + ui->IF->setPrefixes(" kMG"); + + connect(&dev, &LibreVNADriver::receivedPacket, this, [=](const Protocol::PacketInfo &p) { + if(p.type == Protocol::PacketType::DeviceConfiguration) { + updateGUI(p.deviceConfig); + } + }); + + dev.sendWithoutPayload(Protocol::PacketType::RequestDeviceConfiguration); + + connect(ui->buttonBox, &QDialogButtonBox::accepted, this, [=](){ + updateDevice(); + accept(); + }); + connect(ui->buttonBox, &QDialogButtonBox::rejected, this, [=](){ + reject(); + }); +} + +DeviceConfigurationDialogVFD::~DeviceConfigurationDialogVFD() +{ + dev.releaseControl(); + delete ui; +} + +void DeviceConfigurationDialogVFD::updateGUI(const Protocol::DeviceConfig &c) +{ + ui->IF->setValue(c.VFD.IF); + if(c.VFD.P1PortGain == 0xFF) { + ui->P1PortGain->setCurrentIndex(0); + } else if(c.VFD.P1PortGain < 64) { + ui->P1PortGain->setCurrentIndex(64 - c.VFD.P1PortGain); + } + if(c.VFD.P1RefGain == 0xFF) { + ui->P1RefGain->setCurrentIndex(0); + } else if(c.VFD.P1RefGain < 64) { + ui->P1RefGain->setCurrentIndex(64 - c.VFD.P1RefGain); + } + if(c.VFD.P2PortGain == 0xFF) { + ui->P2PortGain->setCurrentIndex(0); + } else if(c.VFD.P2PortGain < 64) { + ui->P2PortGain->setCurrentIndex(64 - c.VFD.P2PortGain); + } + if(c.VFD.P2RefGain == 0xFF) { + ui->P2RefGain->setCurrentIndex(0); + } else if(c.VFD.P2RefGain < 64) { + ui->P2RefGain->setCurrentIndex(64 - c.VFD.P2RefGain); + } +} + +void DeviceConfigurationDialogVFD::updateDevice() +{ + Protocol::PacketInfo p; + p.type = Protocol::PacketType::DeviceConfiguration; + + p.deviceConfig.VFD.IF = ui->IF->value(); + p.deviceConfig.VFD.P1PortGain = ui->P1PortGain->currentIndex() == 0 ? 0xFF : 64 - ui->P1PortGain->currentIndex(); + p.deviceConfig.VFD.P1RefGain = ui->P1RefGain->currentIndex() == 0 ? 0xFF : 64 - ui->P1RefGain->currentIndex(); + p.deviceConfig.VFD.P2PortGain = ui->P2PortGain->currentIndex() == 0 ? 0xFF : 64 - ui->P2PortGain->currentIndex(); + p.deviceConfig.VFD.P2RefGain = ui->P2RefGain->currentIndex() == 0 ? 0xFF : 64 - ui->P2RefGain->currentIndex(); + dev.SendPacket(p); +} diff --git a/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvfd.h b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvfd.h new file mode 100644 index 0000000..87beb1c --- /dev/null +++ b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvfd.h @@ -0,0 +1,31 @@ +#ifndef DEVICECONFIGURATIONDIALOGVFD_H +#define DEVICECONFIGURATIONDIALOGVFD_H + +#include "librevnadriver.h" + +#include +#include + +namespace Ui { +class DeviceConfigurationDialogVFD; +} + +class DeviceConfigurationDialogVFD : public QDialog +{ + Q_OBJECT + +public: + explicit DeviceConfigurationDialogVFD(LibreVNADriver &dev, QWidget *parent = nullptr); + ~DeviceConfigurationDialogVFD(); + +private: + void updateGUI(const Protocol::DeviceConfig &c); + void updateDevice(); + + Ui::DeviceConfigurationDialogVFD *ui; + LibreVNADriver &dev; + + QHostAddress ip, mask, gateway; +}; + +#endif // DEVICECONFIGURATIONDIALOGVFD_H diff --git a/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvfd.ui b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvfd.ui new file mode 100644 index 0000000..3926922 --- /dev/null +++ b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvfd.ui @@ -0,0 +1,1407 @@ + + + DeviceConfigurationDialogVFD + + + + 0 + 0 + 274 + 278 + + + + Form + + + + + + Frequencies + + + + + + IF: + + + + + + + + + + + + + PGA configuration + + + + + + Port 1 port gain: + + + + + + + + Auto + + + + + -5.5 dB + + + + + -5.0 dB + + + + + -4.5 dB + + + + + -4.0 dB + + + + + -3.5 dB + + + + + -3.0 dB + + + + + -2.5 dB + + + + + -2.0 dB + + + + + -1.5 dB + + + + + -1.0 dB + + + + + -0.5 dB + + + + + 0.0 dB + + + + + 0.5 dB + + + + + 1.0 dB + + + + + 1.5 dB + + + + + 2.0 dB + + + + + 2.5 dB + + + + + 3.0 dB + + + + + 3.5 dB + + + + + 4.0 dB + + + + + 4.5 dB + + + + + 5.0 dB + + + + + 5.5 dB + + + + + 6.0 dB + + + + + 6.5 dB + + + + + 7.0 dB + + + + + 7.5 dB + + + + + 8.0 dB + + + + + 8.5 dB + + + + + 9.0 dB + + + + + 9.5 dB + + + + + 10.0 dB + + + + + 10.5 dB + + + + + 11.0 dB + + + + + 11.5 dB + + + + + 12.0 dB + + + + + 12.5 dB + + + + + 13.0 dB + + + + + 13.5 dB + + + + + 14.0 dB + + + + + 14.5 dB + + + + + 15.0 dB + + + + + 15.5 dB + + + + + 16.0 dB + + + + + 16.5 dB + + + + + 17.0 dB + + + + + 17.5 dB + + + + + 18.0 dB + + + + + 18.5 dB + + + + + 19.0 dB + + + + + 19.5 dB + + + + + 20.0 dB + + + + + 20.5 dB + + + + + 21.0 dB + + + + + 21.5 dB + + + + + 22.0 dB + + + + + 22.5 dB + + + + + 23.0 dB + + + + + 23.5 dB + + + + + 24.0 dB + + + + + 24.5 dB + + + + + 25.0 dB + + + + + 25.5 dB + + + + + 26.0 dB + + + + + + + + Port 1 reference gain: + + + + + + + + Auto + + + + + -5.5 dB + + + + + -5.0 dB + + + + + -4.5 dB + + + + + -4.0 dB + + + + + -3.5 dB + + + + + -3.0 dB + + + + + -2.5 dB + + + + + -2.0 dB + + + + + -1.5 dB + + + + + -1.0 dB + + + + + -0.5 dB + + + + + 0.0 dB + + + + + 0.5 dB + + + + + 1.0 dB + + + + + 1.5 dB + + + + + 2.0 dB + + + + + 2.5 dB + + + + + 3.0 dB + + + + + 3.5 dB + + + + + 4.0 dB + + + + + 4.5 dB + + + + + 5.0 dB + + + + + 5.5 dB + + + + + 6.0 dB + + + + + 6.5 dB + + + + + 7.0 dB + + + + + 7.5 dB + + + + + 8.0 dB + + + + + 8.5 dB + + + + + 9.0 dB + + + + + 9.5 dB + + + + + 10.0 dB + + + + + 10.5 dB + + + + + 11.0 dB + + + + + 11.5 dB + + + + + 12.0 dB + + + + + 12.5 dB + + + + + 13.0 dB + + + + + 13.5 dB + + + + + 14.0 dB + + + + + 14.5 dB + + + + + 15.0 dB + + + + + 15.5 dB + + + + + 16.0 dB + + + + + 16.5 dB + + + + + 17.0 dB + + + + + 17.5 dB + + + + + 18.0 dB + + + + + 18.5 dB + + + + + 19.0 dB + + + + + 19.5 dB + + + + + 20.0 dB + + + + + 20.5 dB + + + + + 21.0 dB + + + + + 21.5 dB + + + + + 22.0 dB + + + + + 22.5 dB + + + + + 23.0 dB + + + + + 23.5 dB + + + + + 24.0 dB + + + + + 24.5 dB + + + + + 25.0 dB + + + + + 25.5 dB + + + + + 26.0 dB + + + + + + + + Port 2 port gain: + + + + + + + + Auto + + + + + -5.5 dB + + + + + -5.0 dB + + + + + -4.5 dB + + + + + -4.0 dB + + + + + -3.5 dB + + + + + -3.0 dB + + + + + -2.5 dB + + + + + -2.0 dB + + + + + -1.5 dB + + + + + -1.0 dB + + + + + -0.5 dB + + + + + 0.0 dB + + + + + 0.5 dB + + + + + 1.0 dB + + + + + 1.5 dB + + + + + 2.0 dB + + + + + 2.5 dB + + + + + 3.0 dB + + + + + 3.5 dB + + + + + 4.0 dB + + + + + 4.5 dB + + + + + 5.0 dB + + + + + 5.5 dB + + + + + 6.0 dB + + + + + 6.5 dB + + + + + 7.0 dB + + + + + 7.5 dB + + + + + 8.0 dB + + + + + 8.5 dB + + + + + 9.0 dB + + + + + 9.5 dB + + + + + 10.0 dB + + + + + 10.5 dB + + + + + 11.0 dB + + + + + 11.5 dB + + + + + 12.0 dB + + + + + 12.5 dB + + + + + 13.0 dB + + + + + 13.5 dB + + + + + 14.0 dB + + + + + 14.5 dB + + + + + 15.0 dB + + + + + 15.5 dB + + + + + 16.0 dB + + + + + 16.5 dB + + + + + 17.0 dB + + + + + 17.5 dB + + + + + 18.0 dB + + + + + 18.5 dB + + + + + 19.0 dB + + + + + 19.5 dB + + + + + 20.0 dB + + + + + 20.5 dB + + + + + 21.0 dB + + + + + 21.5 dB + + + + + 22.0 dB + + + + + 22.5 dB + + + + + 23.0 dB + + + + + 23.5 dB + + + + + 24.0 dB + + + + + 24.5 dB + + + + + 25.0 dB + + + + + 25.5 dB + + + + + 26.0 dB + + + + + + + + Port 2 reference gain: + + + + + + + + Auto + + + + + -5.5 dB + + + + + -5.0 dB + + + + + -4.5 dB + + + + + -4.0 dB + + + + + -3.5 dB + + + + + -3.0 dB + + + + + -2.5 dB + + + + + -2.0 dB + + + + + -1.5 dB + + + + + -1.0 dB + + + + + -0.5 dB + + + + + 0.0 dB + + + + + 0.5 dB + + + + + 1.0 dB + + + + + 1.5 dB + + + + + 2.0 dB + + + + + 2.5 dB + + + + + 3.0 dB + + + + + 3.5 dB + + + + + 4.0 dB + + + + + 4.5 dB + + + + + 5.0 dB + + + + + 5.5 dB + + + + + 6.0 dB + + + + + 6.5 dB + + + + + 7.0 dB + + + + + 7.5 dB + + + + + 8.0 dB + + + + + 8.5 dB + + + + + 9.0 dB + + + + + 9.5 dB + + + + + 10.0 dB + + + + + 10.5 dB + + + + + 11.0 dB + + + + + 11.5 dB + + + + + 12.0 dB + + + + + 12.5 dB + + + + + 13.0 dB + + + + + 13.5 dB + + + + + 14.0 dB + + + + + 14.5 dB + + + + + 15.0 dB + + + + + 15.5 dB + + + + + 16.0 dB + + + + + 16.5 dB + + + + + 17.0 dB + + + + + 17.5 dB + + + + + 18.0 dB + + + + + 18.5 dB + + + + + 19.0 dB + + + + + 19.5 dB + + + + + 20.0 dB + + + + + 20.5 dB + + + + + 21.0 dB + + + + + 21.5 dB + + + + + 22.0 dB + + + + + 22.5 dB + + + + + 23.0 dB + + + + + 23.5 dB + + + + + 24.0 dB + + + + + 24.5 dB + + + + + 25.0 dB + + + + + 25.5 dB + + + + + 26.0 dB + + + + + + + + + + + QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok + + + + + + + + SIUnitEdit + QLineEdit +
CustomWidgets/siunitedit.h
+
+
+ + +
diff --git a/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/librevnadriver.cpp b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/librevnadriver.cpp index 37d89e2..d2d5ed4 100644 --- a/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/librevnadriver.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/librevnadriver.cpp @@ -7,6 +7,7 @@ #include "deviceconfigurationdialogv1.h" #include "deviceconfigurationdialogvff.h" #include "deviceconfigurationdialogvfe.h" +#include "deviceconfigurationdialogvfd.h" #include "firmwareupdatedialog.h" #include "frequencycaldialog.h" #include "sourcecaldialog.h" @@ -164,6 +165,9 @@ LibreVNADriver::LibreVNADriver() case 1: d = new DeviceConfigurationDialogV1(*this); break; + case 0xFD: + d = new DeviceConfigurationDialogVFD(*this); + break; case 0xFE: d = new DeviceConfigurationDialogVFE(*this); break; diff --git a/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/librevnausbdriver.cpp b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/librevnausbdriver.cpp index c9d03df..0eac15f 100644 --- a/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/librevnausbdriver.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/librevnausbdriver.cpp @@ -348,7 +348,7 @@ void LibreVNAUSBDriver::SearchDevices(std::function 0) { /* managed to read the product string */ QString product(c_product); - if (product == "VNA") { + if (product.contains("VNA")) { // this is a match if(!foundCallback(handle, QString(c_serial))) { // abort search diff --git a/Software/PC_Application/LibreVNA-GUI/LibreVNA-GUI.pro b/Software/PC_Application/LibreVNA-GUI/LibreVNA-GUI.pro index 151281b..1d5ac01 100644 --- a/Software/PC_Application/LibreVNA-GUI/LibreVNA-GUI.pro +++ b/Software/PC_Application/LibreVNA-GUI/LibreVNA-GUI.pro @@ -25,6 +25,7 @@ HEADERS += \ Device/LibreVNA/Compound/compounddriver.h \ Device/LibreVNA/amplitudecaldialog.h \ Device/LibreVNA/deviceconfigurationdialogv1.h \ + Device/LibreVNA/deviceconfigurationdialogvfd.h \ Device/LibreVNA/deviceconfigurationdialogvfe.h \ Device/LibreVNA/deviceconfigurationdialogvff.h \ Device/LibreVNA/devicepacketlog.h \ @@ -192,6 +193,7 @@ SOURCES += \ Device/LibreVNA/Compound/compounddriver.cpp \ Device/LibreVNA/amplitudecaldialog.cpp \ Device/LibreVNA/deviceconfigurationdialogv1.cpp \ + Device/LibreVNA/deviceconfigurationdialogvfd.cpp \ Device/LibreVNA/deviceconfigurationdialogvfe.cpp \ Device/LibreVNA/deviceconfigurationdialogvff.cpp \ Device/LibreVNA/devicepacketlog.cpp \ @@ -357,6 +359,7 @@ FORMS += \ Device/LibreVNA/amplitudecaldialog.ui \ Device/LibreVNA/automaticamplitudedialog.ui \ Device/LibreVNA/deviceconfigurationdialogv1.ui \ + Device/LibreVNA/deviceconfigurationdialogvfd.ui \ Device/LibreVNA/deviceconfigurationdialogvfe.ui \ Device/LibreVNA/deviceconfigurationdialogvff.ui \ Device/LibreVNA/devicepacketlogview.ui \ diff --git a/Software/PC_Application/LibreVNA-Test/LibreVNA-Test.pro b/Software/PC_Application/LibreVNA-Test/LibreVNA-Test.pro index 77323e5..06c3033 100644 --- a/Software/PC_Application/LibreVNA-Test/LibreVNA-Test.pro +++ b/Software/PC_Application/LibreVNA-Test/LibreVNA-Test.pro @@ -28,6 +28,7 @@ SOURCES += \ ../LibreVNA-GUI/CustomWidgets/tracesetselector.cpp \ ../LibreVNA-GUI/Device/LibreVNA/amplitudecaldialog.cpp \ ../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogv1.cpp \ + ../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvfd.cpp \ ../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvfe.cpp \ ../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvff.cpp \ ../LibreVNA-GUI/Device/LibreVNA/firmwareupdatedialog.cpp \ @@ -217,6 +218,7 @@ HEADERS += \ ../LibreVNA-GUI/CustomWidgets/tracesetselector.h \ ../LibreVNA-GUI/Device/LibreVNA/amplitudecaldialog.h \ ../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogv1.h \ + ../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvfd.h \ ../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvfe.h \ ../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvff.h \ ../LibreVNA-GUI/Device/LibreVNA/firmwareupdatedialog.h \ @@ -392,6 +394,7 @@ FORMS += \ ../LibreVNA-GUI/Device/LibreVNA/amplitudecaldialog.ui \ ../LibreVNA-GUI/Device/LibreVNA/automaticamplitudedialog.ui \ ../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogv1.ui \ + ../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvfd.ui \ ../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvfe.ui \ ../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvff.ui \ ../LibreVNA-GUI/Device/LibreVNA/firmwareupdatedialog.ui \ diff --git a/Software/VNA_embedded/Application/Communication/Protocol.hpp b/Software/VNA_embedded/Application/Communication/Protocol.hpp index 9d66f57..a398e27 100644 --- a/Software/VNA_embedded/Application/Communication/Protocol.hpp +++ b/Software/VNA_embedded/Application/Communication/Protocol.hpp @@ -486,6 +486,17 @@ using DeviceConfig = struct _deviceconfig { uint16_t DFTphaseInc; uint8_t PLLSettlingDelay; } V1; + struct { + uint32_t IF; + // Gain settings for all 4 receivers: + // 0-63: valid values, higher value indicate lower gain (higher attenuation) + // 0-254: invalid + // 255: autogain + uint8_t P1PortGain; + uint8_t P1RefGain; + uint8_t P2PortGain; + uint8_t P2RefGain; + } VFD; struct { uint32_t ip; uint32_t mask;