mirror of
https://github.com/jankae/LibreVNA.git
synced 2026-01-20 07:30:48 +01:00
configuration dialog for HW 0xFD
This commit is contained in:
parent
8a74eedfa0
commit
ded26cb8d6
|
|
@ -0,0 +1,79 @@
|
|||
#include "deviceconfigurationdialogvfd.h"
|
||||
#include "ui_deviceconfigurationdialogvfd.h"
|
||||
|
||||
#include <QtEndian>
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
#ifndef DEVICECONFIGURATIONDIALOGVFD_H
|
||||
#define DEVICECONFIGURATIONDIALOGVFD_H
|
||||
|
||||
#include "librevnadriver.h"
|
||||
|
||||
#include <QDialog>
|
||||
#include <QHostAddress>
|
||||
|
||||
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
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -348,7 +348,7 @@ void LibreVNAUSBDriver::SearchDevices(std::function<bool (libusb_device_handle *
|
|||
if (ret > 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
|
||||
|
|
|
|||
|
|
@ -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 \
|
||||
|
|
|
|||
|
|
@ -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 \
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue