diff --git a/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvfe.cpp b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvfe.cpp new file mode 100644 index 00000000..3df3b645 --- /dev/null +++ b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvfe.cpp @@ -0,0 +1,60 @@ +#include "deviceconfigurationdialogvfe.h" +#include "ui_deviceconfigurationdialogvfe.h" + +#include + +DeviceConfigurationDialogVFE::DeviceConfigurationDialogVFE(LibreVNADriver &dev, QWidget *parent) : + QDialog(parent), + ui(new Ui::DeviceConfigurationDialogVFE), + dev(dev) +{ + ui->setupUi(this); + setAttribute(Qt::WA_DeleteOnClose); + + emit dev.acquireControl(); + + connect(&dev, &LibreVNADriver::receivedPacket, this, [=](const Protocol::PacketInfo &p) { + if(p.type == Protocol::PacketType::DeviceConfiguration) { + updateGUI(p.deviceConfig); + } + }); + + connect(ui->autogain, &QCheckBox::toggled, this, [=](){ + ui->portgain->setEnabled(!ui->autogain->isChecked()); + ui->refgain->setEnabled(!ui->autogain->isChecked()); + }); + + dev.sendWithoutPayload(Protocol::PacketType::RequestDeviceConfiguration); + + connect(ui->buttonBox, &QDialogButtonBox::accepted, this, [=](){ + updateDevice(); + accept(); + }); + connect(ui->buttonBox, &QDialogButtonBox::rejected, this, [=](){ + reject(); + }); +} + +DeviceConfigurationDialogVFE::~DeviceConfigurationDialogVFE() +{ + dev.releaseControl(); + delete ui; +} + +void DeviceConfigurationDialogVFE::updateGUI(const Protocol::DeviceConfig &c) +{ + ui->autogain->setChecked(c.VFE.autogain); + ui->portgain->setCurrentIndex(c.VFE.portGain); + ui->refgain->setCurrentIndex(c.VFE.refGain); +} + +void DeviceConfigurationDialogVFE::updateDevice() +{ + Protocol::PacketInfo p; + p.type = Protocol::PacketType::DeviceConfiguration; + + p.deviceConfig.VFE.autogain = ui->autogain->isChecked() ? 1 : 0; + p.deviceConfig.VFE.portGain = ui->portgain->currentIndex(); + p.deviceConfig.VFE.refGain = ui->refgain->currentIndex(); + dev.SendPacket(p); +} diff --git a/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvfe.h b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvfe.h new file mode 100644 index 00000000..38673a97 --- /dev/null +++ b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvfe.h @@ -0,0 +1,31 @@ +#ifndef DEVICECONFIGURATIONDIALOGVFE_H +#define DEVICECONFIGURATIONDIALOGVFE_H + +#include "librevnadriver.h" + +#include +#include + +namespace Ui { +class DeviceConfigurationDialogVFE; +} + +class DeviceConfigurationDialogVFE : public QDialog +{ + Q_OBJECT + +public: + explicit DeviceConfigurationDialogVFE(LibreVNADriver &dev, QWidget *parent = nullptr); + ~DeviceConfigurationDialogVFE(); + +private: + void updateGUI(const Protocol::DeviceConfig &c); + void updateDevice(); + + Ui::DeviceConfigurationDialogVFE *ui; + LibreVNADriver &dev; + + QHostAddress ip, mask, gateway; +}; + +#endif // DEVICECONFIGURATIONDIALOGVFE_H diff --git a/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvfe.ui b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvfe.ui new file mode 100644 index 00000000..ec0e1a89 --- /dev/null +++ b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvfe.ui @@ -0,0 +1,170 @@ + + + DeviceConfigurationDialogVFE + + + + 0 + 0 + 307 + 180 + + + + Form + + + + + + PGA configuration (reset after reboot) + + + + + + Autogain + + + + + + + + + Port gain: + + + + + + + + 1V/V + + + + + 10V/V + + + + + 20V/V + + + + + 30V/V + + + + + 40V/V + + + + + 60V/V + + + + + 80V/V + + + + + 120V/V + + + + + 157V/V + + + + + 0.25V/V + + + + + + + + Reference gain: + + + + + + + + 1V/V + + + + + 10V/V + + + + + 20V/V + + + + + 30V/V + + + + + 40V/V + + + + + 60V/V + + + + + 80V/V + + + + + 120V/V + + + + + 157V/V + + + + + 0.25V/V + + + + + + + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + diff --git a/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/devicepacketlogview.cpp b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/devicepacketlogview.cpp index 3e837996..cc0eec73 100644 --- a/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/devicepacketlogview.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/devicepacketlogview.cpp @@ -204,6 +204,18 @@ void DevicePacketLogView::addEntry(const DevicePacketLog::LogEntry &e) addBool(VFF, "ADC overload", sFF.ADC_overload); addBool(VFF, "Unlevel", sFF.unlevel); addInteger(VFF, "MCU temperature", sFF.temp_MCU); + + auto sFE = e.p->status.VFE; + auto VFE = new QTreeWidgetItem(); + VFE->setData(2, Qt::DisplayRole, "VFE"); + item->addChild(VFE); + addBool(VFE, "Source locked", sFE.source_locked); + addBool(VFE, "LO locked", sFE.LO_locked); + addBool(VFE, "ADC overload", sFE.ADC_overload); + addBool(VFE, "Unlevel", sFE.unlevel); + addInteger(VFE, "MCU temperature", sFE.temp_MCU); + addDouble(VFE, "eCal temperature", (double) sFE.temp_eCal / 100.0); + addDouble(VFE, "eCal heater power", (double) sFE.power_heater / 1000.0); } break; case Protocol::PacketType::DeviceInfo: { @@ -227,9 +239,129 @@ void DevicePacketLogView::addEntry(const DevicePacketLog::LogEntry &e) addDouble(item, "Maximum harmonic frequency", s.limits_maxFreqHarmonic, "Hz"); } break; - case Protocol::PacketType::ManualControl: - case Protocol::PacketType::ManualStatus: - // TODO + case Protocol::PacketType::ManualControl: { + Protocol::ManualControl s = e.p->manual; + auto V1 = new QTreeWidgetItem(); + V1->setData(2, Qt::DisplayRole, "V1"); + item->addChild(V1); + addBool(V1, "High Source chip enable", s.V1.SourceHighCE); + addBool(V1, "High Source RF enable", s.V1.SourceHighRFEN); + addEnum(V1, "High Source power", s.V1.SourceHighPower, {"-4 dBm", "-1 dBm", "2 dBm", "5 dBm"}); + addEnum(V1, "High Source lowpass", s.V1.SourceHighLowpass, {"947 MHz", "1880 MHz", "3550 MHz", "None"}); + addDouble(V1, "High Source frequency", s.V1.SourceHighFrequency); + addBool(V1, "Low Source enable", s.V1.SourceLowEN); + addEnum(V1, "Low Source power", s.V1.SourceLowPower, {"2 mA", "4 mA", "6 mA", "8 mA"}); + addDouble(V1, "Low Source frequency", s.V1.SourceLowFrequency); + addDouble(V1, "Attenuator", s.V1.attenuator * 0.25); + addEnum(V1, "Source band selection", s.V1.SourceHighband, {"Low Source", "High Source"}); + addBool(V1, "Amplifier enable", s.V1.AmplifierEN); + addEnum(V1, "Port switch", s.V1.PortSwitch, {"Port 1", "Port 2"}); + addBool(V1, "LO1 chip enable", s.V1.LO1CE); + addBool(V1, "LO1 RF enable", s.V1.LO1RFEN); + addDouble(V1, "LO1 frequency", s.V1.LO1Frequency); + addBool(V1, "LO2 enable", s.V1.LO2EN); + addDouble(V1, "LO2 frequency", s.V1.LO2Frequency); + addBool(V1, "Port 1 receiver enable", s.V1.Port1EN); + addBool(V1, "Port 2 receiver enable", s.V1.Port2EN); + addBool(V1, "Reference receiver enable", s.V1.RefEN); + addInteger(V1, "Samples", s.V1.Samples); + addEnum(V1, "Window type", s.V1.WindowType, {"None", "Kaiser", "Hann", "Flattop"}); + + auto VFF = new QTreeWidgetItem(); + VFF->setData(2, Qt::DisplayRole, "VFF"); + item->addChild(VFF); + addBool(VFF, "Source chip enable", s.VFF.SourceCE); + addBool(VFF, "Source RF enable", s.VFF.SourceRFEN); + addEnum(VFF, "Source power", s.VFF.SourcePower, {"-1 dBm", "1 dBm", "2.5 dBm", "3.5 dBm", "4.5 dBm", "5.5 dBm", "6.5 dBm", "7 dBm"}); + addDouble(VFF, "Source frequency", s.VFF.SourceFrequency); + addDouble(VFF, "Attenuator", s.VFF.attenuator * 0.25); + addBool(VFF, "Source amplifier enable", s.VFF.SourceAmplifierEN); + addBool(VFF, "LO chip enable", s.VFF.LOCE); + addBool(VFF, "LO RF enable", s.VFF.LORFEN); + addBool(VFF, "LO amplifier enable", s.VFF.LOAmplifierEN); + addEnum(VFF, "LO selection", s.VFF.LOexternal, {"Internal", "External"}); + addDouble(VFF, "LO frequency", s.VFF.LOFrequency); + addBool(VFF, "Port receiver enable", s.VFF.PortEN); + addBool(VFF, "Reference receiver enable", s.VFF.RefEN); + addInteger(VFF, "Samples", s.VFF.Samples); + addEnum(VFF, "Window type", s.VFF.WindowType, {"None", "Kaiser", "Hann", "Flattop"}); + addEnum(VFF, "Port gain", s.VFF.PortGain, {"1 V/V", "10 V/V", "20 V/V", "30 V/V", "40 V/V", "60 V/V", "80 V/V", "120 V/V", "157 V/V", "0.25 V/V"}); + addEnum(VFF, "Reference gain", s.VFF.RefGain, {"1 V/V", "10 V/V", "20 V/V", "30 V/V", "40 V/V", "60 V/V", "80 V/V", "120 V/V", "157 V/V", "0.25 V/V"}); + + auto VFE = new QTreeWidgetItem(); + VFE->setData(2, Qt::DisplayRole, "VFE"); + item->addChild(VFE); + addBool(VFE, "Source chip enable", s.VFE.SourceCE); + addBool(VFE, "Source RF enable", s.VFE.SourceRFEN); + addDouble(VFE, "Source frequency", s.VFE.SourceFrequency); + addDouble(VFE, "Attenuator", s.VFE.attenuator * 0.25); + addBool(VFE, "Source amplifier 1 enable", s.VFE.SourceAmplifier1EN); + addBool(VFE, "Source amplifier 2 enable", s.VFE.SourceAmplifier2EN); + addBool(VFE, "LO chip enable", s.VFE.LOCE); + addBool(VFE, "LO RF enable", s.VFE.LORFEN); + addDouble(VFE, "LO frequency", s.VFE.LOFrequency); + addBool(VFE, "Port receiver enable", s.VFE.PortEN); + addBool(VFE, "Reference receiver enable", s.VFE.RefEN); + addInteger(VFE, "Samples", s.VFE.Samples); + addEnum(VFE, "Window type", s.VFE.WindowType, {"None", "Kaiser", "Hann", "Flattop"}); + addEnum(VFE, "Port gain", s.VFE.PortGain, {"1 V/V", "10 V/V", "20 V/V", "30 V/V", "40 V/V", "60 V/V", "80 V/V", "120 V/V", "157 V/V", "0.25 V/V"}); + addEnum(VFE, "Reference gain", s.VFE.RefGain, {"1 V/V", "10 V/V", "20 V/V", "30 V/V", "40 V/V", "60 V/V", "80 V/V", "120 V/V", "157 V/V", "0.25 V/V"}); + addEnum(VFE, "eCal state", s.VFE.eCal_state, {"Port", "Open", "Short", "Load"}); + addDouble(VFE, "eCal target temperature", (double) s.VFE.eCal_target / 100.0); + } + break; + case Protocol::PacketType::ManualStatus: { + Protocol::ManualStatus s = e.p->manualStatus; + auto V1 = new QTreeWidgetItem(); + V1->setData(2, Qt::DisplayRole, "V1"); + item->addChild(V1); + addInteger(V1, "ADC port 1 minimum", s.V1.port1min); + addInteger(V1, "ADC port 1 maximum", s.V1.port1max); + addInteger(V1, "ADC port 2 minimum", s.V1.port2min); + addInteger(V1, "ADC port 2 maximum", s.V1.port2max); + addInteger(V1, "ADC reference minimum", s.V1.refmin); + addInteger(V1, "ADC reference maximum", s.V1.refmax); + addDouble(V1, "Port 1 real", s.V1.port1real); + addDouble(V1, "Port 1 imaginary", s.V1.port1imag); + addDouble(V1, "Port 2 real", s.V1.port2real); + addDouble(V1, "Port 2 imaginary", s.V1.port2imag); + addDouble(V1, "Reference real", s.V1.refreal); + addDouble(V1, "Reference imaginary", s.V1.refimag); + addInteger(V1, "Source temperature", s.V1.temp_source); + addInteger(V1, "LO1 temperature", s.V1.temp_LO); + addBool(V1, "Source locked", s.V1.source_locked); + addBool(V1, "LO1 locked", s.V1.LO_locked); + + auto VFF = new QTreeWidgetItem(); + VFF->setData(2, Qt::DisplayRole, "VFF"); + item->addChild(VFF); + addInteger(VFF, "ADC port minimum", s.VFF.portmin); + addInteger(VFF, "ADC port maximum", s.VFF.portmax); + addInteger(VFF, "ADC reference minimum", s.VFF.refmin); + addInteger(VFF, "ADC reference maximum", s.VFF.refmax); + addDouble(VFF, "Port real", s.VFF.portreal); + addDouble(VFF, "Port imaginary", s.VFF.portimag); + addDouble(VFF, "Reference real", s.VFF.refreal); + addDouble(VFF, "Reference imaginary", s.VFF.refimag); + addBool(VFF, "Source locked", s.VFF.source_locked); + addBool(VFF, "LO locked", s.VFF.LO_locked); + + auto VFE = new QTreeWidgetItem(); + VFE->setData(2, Qt::DisplayRole, "VFE"); + item->addChild(VFE); + addInteger(VFE, "ADC port minimum", s.VFE.portmin); + addInteger(VFE, "ADC port maximum", s.VFE.portmax); + addInteger(VFE, "ADC reference minimum", s.VFE.refmin); + addInteger(VFE, "ADC reference maximum", s.VFE.refmax); + addDouble(VFE, "Port real", s.VFE.portreal); + addDouble(VFE, "Port imaginary", s.VFE.portimag); + addDouble(VFE, "Reference real", s.VFE.refreal); + addDouble(VFE, "Reference imaginary", s.VFE.refimag); + addBool(VFE, "Source locked", s.VFE.source_locked); + addBool(VFE, "LO locked", s.VFE.LO_locked); + addDouble(VFE, "eCal temperature", (double) s.VFE.temp_eCal / 100.0); + addDouble(VFE, "eCal heater power", (double) s.VFE.power_heater / 1000.0); + } break; case Protocol::PacketType::SpectrumAnalyzerSettings: { Protocol::SpectrumAnalyzerSettings s = e.p->spectrumSettings; @@ -330,6 +462,14 @@ void DevicePacketLogView::addEntry(const DevicePacketLog::LogEntry &e) addBool(VFF, "PGA autogain", sFF.autogain); addInteger(VFF, "Port gain", sFF.portGain); addInteger(VFF, "Reference gain", sFF.refGain); + + auto sFE = e.p->deviceConfig.VFE; + auto VFE = new QTreeWidgetItem(); + VFE->setData(2, Qt::DisplayRole, "VFE"); + item->addChild(VFE); + addBool(VFE, "PGA autogain", sFE.autogain); + addInteger(VFE, "Port gain", sFE.portGain); + addInteger(VFE, "Reference gain", sFE.refGain); } break; default: diff --git a/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/librevnadriver.cpp b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/librevnadriver.cpp index c597eb27..8418b89c 100644 --- a/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/librevnadriver.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/librevnadriver.cpp @@ -2,8 +2,10 @@ #include "manualcontroldialogV1.h" #include "manualcontroldialogvff.h" +#include "manualcontroldialogvfe.h" #include "deviceconfigurationdialogv1.h" #include "deviceconfigurationdialogvff.h" +#include "deviceconfigurationdialogvfe.h" #include "firmwareupdatedialog.h" #include "frequencycaldialog.h" #include "sourcecaldialog.h" @@ -121,6 +123,9 @@ LibreVNADriver::LibreVNADriver() case 1: d = new ManualControlDialogV1(*this); break; + case 0xFE: + d = new ManualControlDialogVFE(*this); + break; case 0xFF: d = new ManualControlDialogVFF(*this); break; @@ -138,6 +143,9 @@ LibreVNADriver::LibreVNADriver() case 1: d = new DeviceConfigurationDialogV1(*this); break; + case 0xFE: + d = new DeviceConfigurationDialogVFE(*this); + break; case 0xFF: d = new DeviceConfigurationDialogVFF(*this); break; @@ -210,6 +218,17 @@ std::set LibreVNADriver::getFlags() ret.insert(Flag::Overload); } break; + case 0xFE: + if(!lastStatus.VFE.source_locked || !lastStatus.VFE.LO_locked) { + ret.insert(Flag::Unlocked); + } + if(lastStatus.VFE.unlevel) { + ret.insert(Flag::Unlevel); + } + if(lastStatus.VFE.ADC_overload) { + ret.insert(Flag::Overload); + } + break; case 0xFF: if(!lastStatus.VFF.source_locked || !lastStatus.VFF.LO_locked) { ret.insert(Flag::Unlocked); @@ -244,6 +263,11 @@ QString LibreVNADriver::getStatus() } } break; + case 0xFE: + ret.append(" MCU Temp: "+QString::number(lastStatus.VFE.temp_MCU)+"°C"); + ret.append(" eCal Temp: "+QString::number(lastStatus.VFE.temp_eCal / 100.0)+"°C"); + ret.append(" eCal Power: "+QString::number(lastStatus.VFE.power_heater / 1000.0)+"W"); + break; case 0xFF: ret.append(" MCU Temp: "+QString::number(lastStatus.VFF.temp_MCU)+"°C"); break; @@ -672,8 +696,9 @@ void LibreVNADriver::handleReceivedPacket(const Protocol::PacketInfo &packet) QString LibreVNADriver::hardwareVersionToString(uint8_t version) { switch(version) { - case 1: return "1"; - case 255: return "PT"; + case 0x01: return "1"; + case 0xFE: return "P2"; + case 0xFF: return "PT"; default: return "Unknown"; } } @@ -686,8 +711,9 @@ unsigned int LibreVNADriver::getMaxAmplitudePoints() const QString LibreVNADriver::getFirmwareMagicString() { switch(hardwareVersion) { - case 1: return "VNA!"; - case 255: return "VNPT"; + case 0x01: return "VNA!"; + case 0xFE: return "VNP2"; + case 0xFF: return "VNPT"; default: return "XXXX"; } } diff --git a/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/manualcontroldialogvfe.cpp b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/manualcontroldialogvfe.cpp new file mode 100644 index 00000000..954dcd52 --- /dev/null +++ b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/manualcontroldialogvfe.cpp @@ -0,0 +1,419 @@ +#include "manualcontroldialogvfe.h" + +#include "ui_manualcontroldialogvfe.h" +#include "Util/util.h" + +#include +#include +#include +#include + + +using namespace std; + +ManualControlDialogVFE::ManualControlDialogVFE(LibreVNADriver &dev, QWidget *parent) : + QDialog(parent), + ui(new Ui::ManualControlDialogVFE), + dev(dev) +{ + ui->setupUi(this); + setAttribute(Qt::WA_DeleteOnClose); + + emit dev.acquireControl(); + + ui->SourceFrequency->setUnit("Hz"); + ui->SourceFrequency->setPrefixes(" kMG"); + ui->SourceFrequency->setPrecision(6); + ui->SourceFrequency->setValueQuiet(1000000000); + + ui->IF->setUnit("Hz"); + ui->IF->setPrefixes(" kM"); + ui->IF->setPrecision(6); + + ui->LOFrequency->setUnit("Hz"); + ui->LOFrequency->setPrefixes(" kMG"); + ui->LOFrequency->setPrecision(6); + + ui->eCalTarget->setUnit("°"); + ui->eCalTarget->setPrecision(4); + ui->eCalTarget->setValue(0); + + ui->eCalTemp->setUnit("°"); + ui->eCalTemp->setPrecision(4); + + ui->eCalPower->setUnit("W"); + ui->eCalPower->setPrefixes("m "); + ui->eCalPower->setPrecision(3); + + auto UpdateLO = [=]() { + double sourceFreq = ui->SourceFrequency->value(); + if (ui->LOFreqType->currentIndex() == 0) { + // fixed IF mode + ui->LOFrequency->setValueQuiet(sourceFreq + ui->IF->value()); + } else { + // Manual Frequency mode + ui->IF->setValueQuiet(ui->LOFrequency->value() - sourceFreq); + } + }; + + connect(ui->IF, &SIUnitEdit::valueChanged, [=](double) { + UpdateLO(); + }); + connect(ui->LOFrequency, &SIUnitEdit::valueChanged, [=](double) { + UpdateLO(); + }); + connect(ui->SourceFrequency, &SIUnitEdit::valueChanged, [=](double) { + UpdateLO(); + }); + + ui->IF->setValue(100000); + + // LO mode switch connections + connect(ui->LOFreqType, qOverload(&QComboBox::activated), [=](int index) { + switch(index) { + case 0: + ui->LOFrequency->setEnabled(false); + ui->IF->setEnabled(true); + break; + case 1: + ui->LOFrequency->setEnabled(true); + ui->IF->setEnabled(false); + break; + } + }); + + // Readonly widgets + auto MakeReadOnly = [](QWidget* w) { + w->setAttribute(Qt::WA_TransparentForMouseEvents); + w->setFocusPolicy(Qt::NoFocus); + }; + MakeReadOnly(ui->SourceLocked); + MakeReadOnly(ui->LOlocked); + MakeReadOnly(ui->portmin); + MakeReadOnly(ui->portmax); + MakeReadOnly(ui->portmag); + MakeReadOnly(ui->portphase); + MakeReadOnly(ui->portreferenced); + MakeReadOnly(ui->refmin); + MakeReadOnly(ui->refmax); + MakeReadOnly(ui->refmag); + MakeReadOnly(ui->refphase); + MakeReadOnly(ui->eCalPower); + MakeReadOnly(ui->eCalTemp); + + connect(&dev, &LibreVNADriver::receivedPacket, this, [=](const Protocol::PacketInfo &p){ + if(p.type == Protocol::PacketType::ManualStatus) { + NewStatus(p.manualStatus); + } + }, Qt::QueuedConnection); + + connect(ui->SourceCE, &QCheckBox::toggled, [=](bool) { UpdateDevice(); }); + connect(ui->SourceRFEN, &QCheckBox::toggled, [=](bool) { UpdateDevice(); }); + connect(ui->LOCE, &QCheckBox::toggled, [=](bool) { UpdateDevice(); }); + connect(ui->LORFEN, &QCheckBox::toggled, [=](bool) { UpdateDevice(); }); + connect(ui->SourceAmplifier1Enable, &QCheckBox::toggled, [=](bool) { UpdateDevice(); }); + connect(ui->SourceAmplifier2Enable, &QCheckBox::toggled, [=](bool) { UpdateDevice(); }); + connect(ui->Port1Enable, &QCheckBox::toggled, [=](bool) { UpdateDevice(); }); + connect(ui->RefEnable, &QCheckBox::toggled, [=](bool) { UpdateDevice(); }); + connect(ui->portgain, qOverload(&QComboBox::currentIndexChanged), [=](int) { UpdateDevice(); }); + connect(ui->refgain, qOverload(&QComboBox::currentIndexChanged), [=](int) { UpdateDevice(); }); + + connect(ui->SourceFrequency, &SIUnitEdit::valueChanged, [=](double) { UpdateDevice(); }); + connect(ui->LOFrequency, &SIUnitEdit::valueChanged, [=](double) { UpdateDevice(); }); + connect(ui->IF, &SIUnitEdit::valueChanged, [=](double) { UpdateDevice(); }); + + connect(ui->Attenuator, qOverload(&QDoubleSpinBox::valueChanged), [=](double) { UpdateDevice(); }); + connect(ui->Samples, qOverload(&QSpinBox::valueChanged), [=](double) { UpdateDevice(); }); + connect(ui->cbWindow, qOverload(&QComboBox::activated), [=](int) { UpdateDevice(); }); + + connect(ui->eCalState, qOverload(&QComboBox::currentIndexChanged), [=](int) { UpdateDevice(); }); + connect(ui->eCalTarget, &SIUnitEdit::valueChanged, [=](double) { UpdateDevice(); }); + + UpdateDevice(); +} + +ManualControlDialogVFE::~ManualControlDialogVFE() +{ + emit dev.releaseControl(); + delete ui; +} + +void ManualControlDialogVFE::setSourceChipEnable(bool enable) +{ + ui->SourceCE->setChecked(enable); +} + +bool ManualControlDialogVFE::getSourceChipEnable() +{ + return ui->SourceCE->isChecked(); +} + +void ManualControlDialogVFE::setSourceRFEnable(bool enable) +{ + ui->SourceRFEN->setChecked(enable); +} + +bool ManualControlDialogVFE::getSourceRFEnable() +{ + return ui->SourceRFEN->isChecked(); +} + +bool ManualControlDialogVFE::getSourceLocked() +{ + return ui->SourceLocked->isChecked(); +} + +void ManualControlDialogVFE::setSourceFrequency(double f) +{ + ui->SourceFrequency->setValue(f); +} + +double ManualControlDialogVFE::getSourceFrequency() +{ + return ui->SourceFrequency->value(); +} + +void ManualControlDialogVFE::setAttenuator(double att) +{ + ui->Attenuator->setValue(att); +} + +double ManualControlDialogVFE::getAttenuator() +{ + return ui->Attenuator->value(); +} + +void ManualControlDialogVFE::setSourceAmplifier1Enable(bool enable) +{ + ui->SourceAmplifier1Enable->setChecked(enable); +} + +bool ManualControlDialogVFE::getSourceAmplifier1Enable() +{ + return ui->SourceAmplifier1Enable->isChecked(); +} + +void ManualControlDialogVFE::setSourceAmplifier2Enable(bool enable) +{ + ui->SourceAmplifier2Enable->setChecked(enable); +} + +bool ManualControlDialogVFE::getSourceAmplifier2Enable() +{ + return ui->SourceAmplifier2Enable->isChecked(); +} + +void ManualControlDialogVFE::setLOChipEnable(bool enable) +{ + ui->LOCE->setChecked(enable); +} + +bool ManualControlDialogVFE::getLOChipEnable() +{ + return ui->LOCE->isChecked(); +} + +void ManualControlDialogVFE::setLORFEnable(bool enable) +{ + ui->LORFEN->setChecked(enable); +} + +bool ManualControlDialogVFE::getLORFEnable() +{ + return ui->LORFEN->isChecked(); +} + +bool ManualControlDialogVFE::getLOLocked() +{ + return ui->LOlocked->isChecked(); +} + +void ManualControlDialogVFE::setLOFrequency(double f) +{ + ui->LOFreqType->setCurrentIndex(1); + ui->LOFrequency->setValue(f); +} + +double ManualControlDialogVFE::getLOFrequency() +{ + return ui->LOFrequency->value(); +} + +void ManualControlDialogVFE::setIFFrequency(double f) +{ + ui->LOFreqType->setCurrentIndex(0); + ui->IF->setValue(f); +} + +double ManualControlDialogVFE::getIFFrequency() +{ + return ui->IF->value(); +} + +void ManualControlDialogVFE::setPortEnable(bool enable) +{ + ui->Port1Enable->setChecked(enable); +} + +bool ManualControlDialogVFE::getPortEnable() +{ + return ui->Port1Enable->isChecked(); +} + +void ManualControlDialogVFE::setRefEnable(bool enable) +{ + ui->RefEnable->setChecked(enable); +} + +bool ManualControlDialogVFE::getRefEnable() +{ + return ui->RefEnable->isChecked(); +} + +void ManualControlDialogVFE::setPortGain(Gain g) +{ + ui->portgain->setCurrentIndex((int) g); +} + +ManualControlDialogVFE::Gain ManualControlDialogVFE::getPortGain() +{ + return (Gain) ui->portgain->currentIndex(); +} + +void ManualControlDialogVFE::setRefGain(Gain g) +{ + ui->refgain->setCurrentIndex((int) g); +} + +ManualControlDialogVFE::Gain ManualControlDialogVFE::getRefGain() +{ + return (Gain) ui->refgain->currentIndex(); +} + +void ManualControlDialogVFE::setNumSamples(int samples) +{ + ui->Samples->setValue(samples); +} + +int ManualControlDialogVFE::getNumSamples() +{ + return ui->Samples->value(); +} + +void ManualControlDialogVFE::setWindow(ManualControlDialogVFE::Window w) +{ + ui->cbWindow->setCurrentIndex((int) w); +} + +ManualControlDialogVFE::Window ManualControlDialogVFE::getWindow() +{ + return (Window) ui->cbWindow->currentIndex(); +} + +int ManualControlDialogVFE::getPortMinADC() +{ + return ui->portmin->text().toInt(); +} + +int ManualControlDialogVFE::getPortMaxADC() +{ + return ui->portmax->text().toInt(); +} + +double ManualControlDialogVFE::getPortMagnitude() +{ + return ui->portmag->text().toDouble(); +} + +double ManualControlDialogVFE::getPortPhase() +{ + return ui->portphase->text().toDouble(); +} + +std::complex ManualControlDialogVFE::getPortReferenced() +{ + return portreferenced; +} + +int ManualControlDialogVFE::getRefMinADC() +{ + return ui->refmin->text().toInt(); +} + +int ManualControlDialogVFE::getRefMaxADC() +{ + return ui->refmax->text().toInt(); +} + +double ManualControlDialogVFE::getRefMagnitude() +{ + return ui->refmag->text().toDouble(); +} + +double ManualControlDialogVFE::getRefPhase() +{ + return ui->refphase->text().toDouble(); +} + +void ManualControlDialogVFE::NewStatus(Protocol::ManualStatus status) +{ + // ADC values + ui->portmin->setText(QString::number(status.VFE.portmin)); + ui->portmax->setText(QString::number(status.VFE.portmax)); + auto port = complex(status.VFE.portreal, status.VFE.portimag); + ui->portmag->setText(QString::number(abs(port))); + ui->portphase->setText(QString::number(arg(port)*180/M_PI)); + + ui->refmin->setText(QString::number(status.VFE.refmin)); + ui->refmax->setText(QString::number(status.VFE.refmax)); + auto ref = complex(status.VFE.refreal, status.VFE.refimag); + ui->refmag->setText(QString::number(abs(ref))); + ui->refphase->setText(QString::number(arg(ref)*180/M_PI)); + + portreferenced = port / ref; + auto portdb = Util::SparamTodB(portreferenced); + + ui->portreferenced->setText(QString::number(portdb, 'f', 1) + "db@" + QString::number(arg(portreferenced)*180/M_PI, 'f', 0) + "°"); + + // PLL state + ui->SourceLocked->setChecked(status.VFE.source_locked); + ui->LOlocked->setChecked(status.VFE.LO_locked); + + // eCal + ui->eCalTemp->setValue((double) status.VFE.temp_eCal / 100.0); + ui->eCalPower->setValue((double) status.VFE.power_heater / 1000.0); +} + +void ManualControlDialogVFE::UpdateDevice() +{ + Protocol::PacketInfo p; + p.type = Protocol::PacketType::ManualControl; + auto &m = p.manual.VFE; + // Source highband + m.SourceCE = ui->SourceCE->isChecked(); + m.SourceRFEN = ui->SourceRFEN->isChecked(); + m.SourceFrequency = ui->SourceFrequency->value(); + m.SourceAmplifier1EN = ui->SourceAmplifier1Enable->isChecked(); + m.SourceAmplifier2EN = ui->SourceAmplifier2Enable->isChecked(); + m.attenuator = -ui->Attenuator->value() / 0.25; + // LO + m.LOCE = ui->LOCE->isChecked(); + m.LORFEN = ui->LORFEN->isChecked(); + m.LOFrequency = ui->LOFrequency->value(); + + // Acquisition + m.PortEN = ui->Port1Enable->isChecked(); + m.PortGain = ui->portgain->currentIndex(); + m.RefEN = ui->RefEnable->isChecked(); + m.RefGain = ui->refgain->currentIndex(); + m.Samples = ui->Samples->value(); + m.WindowType = ui->cbWindow->currentIndex(); + + // eCal + m.eCal_state = ui->eCalState->currentIndex(); + m.eCal_target = ui->eCalTarget->value() * 100; + + qDebug() << "Updating manual control state"; + + dev.SendPacket(p); +} diff --git a/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/manualcontroldialogvfe.h b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/manualcontroldialogvfe.h new file mode 100644 index 00000000..f5f19375 --- /dev/null +++ b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/manualcontroldialogvfe.h @@ -0,0 +1,102 @@ +#ifndef MANUALCONTROLDIALOGVFE_H +#define MANUALCONTROLDIALOGVFE_H + +#include "librevnadriver.h" + +#include +#include + +namespace Ui { +class ManualControlDialogVFE; +} + +class ManualControlDialogVFE : public QDialog +{ + Q_OBJECT + +public: + explicit ManualControlDialogVFE(LibreVNADriver &dev, QWidget *parent = nullptr); + ~ManualControlDialogVFE(); + + void setSourceChipEnable(bool enable); + bool getSourceChipEnable(); + void setSourceRFEnable(bool enable); + bool getSourceRFEnable(); + bool getSourceLocked(); + void setSourceFrequency(double f); + double getSourceFrequency(); + + void setAttenuator(double att); + double getAttenuator(); + void setSourceAmplifier1Enable(bool enable); + bool getSourceAmplifier1Enable(); + void setSourceAmplifier2Enable(bool enable); + bool getSourceAmplifier2Enable(); + + void setLOChipEnable(bool enable); + bool getLOChipEnable(); + void setLORFEnable(bool enable); + bool getLORFEnable(); + bool getLOLocked(); + void setLOFrequency(double f); + double getLOFrequency(); + void setIFFrequency(double f); + double getIFFrequency(); + void setPortEnable(bool enable); + bool getPortEnable(); + void setRefEnable(bool enable); + bool getRefEnable(); + + enum class Gain { + G1 = 0, + G10 = 1, + G20 = 2, + G30 = 3, + G40 = 4, + G60 = 5, + G80 = 6, + G120 = 7, + G157 = 8, + G0_25 = 9, + }; + + void setPortGain(Gain g); + Gain getPortGain(); + void setRefGain(Gain g); + Gain getRefGain(); + + void setNumSamples(int samples); + int getNumSamples(); + + enum class Window { + None = 0, + Kaiser = 1, + Hann = 2, + FlatTop = 3 + }; + + void setWindow(Window w); + Window getWindow(); + + int getPortMinADC(); + int getPortMaxADC(); + double getPortMagnitude(); + double getPortPhase(); + std::complex getPortReferenced(); + + int getRefMinADC(); + int getRefMaxADC(); + double getRefMagnitude(); + double getRefPhase(); + +public slots: + void NewStatus(Protocol::ManualStatus status); + +private: + void UpdateDevice(); + Ui::ManualControlDialogVFE *ui; + LibreVNADriver &dev; + std::complex portreferenced; +}; + +#endif // MANUALCONTROLDIALOGVFE_H diff --git a/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/manualcontroldialogvfe.ui b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/manualcontroldialogvfe.ui new file mode 100644 index 00000000..59f6271e --- /dev/null +++ b/Software/PC_Application/LibreVNA-GUI/Device/LibreVNA/manualcontroldialogvfe.ui @@ -0,0 +1,661 @@ + + + ManualControlDialogVFE + + + + 0 + 0 + 816 + 588 + + + + Form + + + + + + + + + + Signal Generation + + + + + + + + Source + + + + + + Chip Enable + + + + + + + RF Enable + + + + + + + true + + + Locked + + + + + + + + + Frequency: + + + + + + + + + + + + + + + + + + + Attenuator + + + + + + db + + + -31.750000000000000 + + + 0.000000000000000 + + + 0.250000000000000 + + + + + + + + + + Amplifier + + + + + + Enable Amp1 + + + false + + + + + + + Enable Amp2 + + + + + + + + + + + + + + + Signal Analysis + + + + + + LO + + + + + + + + Chip Enable + + + + + + + RF Enable + + + + + + + true + + + Locked + + + + + + + + + Freq. Type: + + + + + + + + IF + + + + + Absolute + + + + + + + + Frequency: + + + + + + + false + + + + + + + IF1: + + + + + + + + + + + + + + + + + Aquisition + + + + + + Port Enable + + + + + + + Reference Enable + + + + + + + + + + 1V/V + + + + + 10V/V + + + + + 20V/V + + + + + 30V/V + + + + + 40V/V + + + + + 60V/V + + + + + 80V/V + + + + + 120V/V + + + + + 157V/V + + + + + 0.25V/V + + + + + + + + + 1V/V + + + + + 10V/V + + + + + 20V/V + + + + + 30V/V + + + + + 40V/V + + + + + 60V/V + + + + + 80V/V + + + + + 120V/V + + + + + 157V/V + + + + + 0.25V/V + + + + + + + + Samples: + + + + + + + 96 + + + 16384 + + + 16 + + + 16384 + + + + + + + Window: + + + + + + + + None + + + + + Kaiser + + + + + Hann + + + + + Flat Top + + + + + + + + Reference PGA gain: + + + + + + + Port PGA gain: + + + + + + + + + + + + + + + eCal + + + + + + Target temperature: + + + + + + + + + + State: + + + + + + + + Port + + + + + Open + + + + + Short + + + + + Load + + + + + + + + + + + + + Measurements + + + + + + Port + + + + + + + + ADC min: + + + + + + + + + + ADC max: + + + + + + + + + + Magnitude: + + + + + + + + + + Phase: + + + + + + + + + + Referenced: + + + + + + + + + + + + + + + Reference + + + + + + + + ADC min: + + + + + + + + + + ADC max: + + + + + + + + + + Magnitude: + + + + + + + + + + Phase: + + + + + + + + + + + + + + + eCal + + + + + + Temperature: + + + + + + + Qt::NoFocus + + + + + + + Heater Power: + + + + + + + Qt::NoFocus + + + + + + + + + + + + + + + + SIUnitEdit + QLineEdit +
CustomWidgets/siunitedit.h
+
+
+ + +
diff --git a/Software/PC_Application/LibreVNA-GUI/Generator/signalgenwidget.cpp b/Software/PC_Application/LibreVNA-GUI/Generator/signalgenwidget.cpp index af3908de..e1f21f20 100644 --- a/Software/PC_Application/LibreVNA-GUI/Generator/signalgenwidget.cpp +++ b/Software/PC_Application/LibreVNA-GUI/Generator/signalgenwidget.cpp @@ -207,6 +207,10 @@ void SignalgeneratorWidget::deviceInfoUpdated() emit SettingsChanged(); }); } + + setFrequency(ui->frequency->value()); + setLevel(ui->levelSpin->value()); + setPort(port); ui->levelSlider->setMaximum(info.Limits.Generator.maxdBm * 100); @@ -217,7 +221,13 @@ void SignalgeneratorWidget::deviceInfoUpdated() void SignalgeneratorWidget::setLevel(double level) { - // TODO constrain to frequency dependent levels + auto info = DeviceDriver::getInfo(window->getDevice()); + if(level < info.Limits.Generator.mindBm) { + level = info.Limits.Generator.mindBm; + } + if(level > info.Limits.Generator.maxdBm) { + level = info.Limits.Generator.maxdBm; + } ui->levelSpin->blockSignals(true); ui->levelSlider->blockSignals(true); ui->levelSpin->setValue(level); @@ -229,6 +239,13 @@ void SignalgeneratorWidget::setLevel(double level) void SignalgeneratorWidget::setFrequency(double frequency) { + auto info = DeviceDriver::getInfo(window->getDevice()); + if(frequency < info.Limits.Generator.minFreq) { + frequency = info.Limits.Generator.minFreq; + } + if(frequency > info.Limits.Generator.maxFreq) { + frequency = info.Limits.Generator.maxFreq; + } ui->frequency->setValue(frequency); } diff --git a/Software/PC_Application/LibreVNA-GUI/LibreVNA-GUI.pro b/Software/PC_Application/LibreVNA-GUI/LibreVNA-GUI.pro index 7be9128e..07069ace 100644 --- a/Software/PC_Application/LibreVNA-GUI/LibreVNA-GUI.pro +++ b/Software/PC_Application/LibreVNA-GUI/LibreVNA-GUI.pro @@ -24,6 +24,7 @@ HEADERS += \ Device/LibreVNA/Compound/compounddriver.h \ Device/LibreVNA/amplitudecaldialog.h \ Device/LibreVNA/deviceconfigurationdialogv1.h \ + Device/LibreVNA/deviceconfigurationdialogvfe.h \ Device/LibreVNA/deviceconfigurationdialogvff.h \ Device/LibreVNA/devicepacketlog.h \ Device/LibreVNA/devicepacketlogview.h \ @@ -33,6 +34,7 @@ HEADERS += \ Device/LibreVNA/librevnatcpdriver.h \ Device/LibreVNA/librevnausbdriver.h \ Device/LibreVNA/manualcontroldialogV1.h \ + Device/LibreVNA/manualcontroldialogvfe.h \ Device/LibreVNA/manualcontroldialogvff.h \ Device/LibreVNA/receivercaldialog.h \ Device/LibreVNA/sourcecaldialog.h \ @@ -182,6 +184,7 @@ SOURCES += \ Device/LibreVNA/Compound/compounddriver.cpp \ Device/LibreVNA/amplitudecaldialog.cpp \ Device/LibreVNA/deviceconfigurationdialogv1.cpp \ + Device/LibreVNA/deviceconfigurationdialogvfe.cpp \ Device/LibreVNA/deviceconfigurationdialogvff.cpp \ Device/LibreVNA/devicepacketlog.cpp \ Device/LibreVNA/devicepacketlogview.cpp \ @@ -191,6 +194,7 @@ SOURCES += \ Device/LibreVNA/librevnatcpdriver.cpp \ Device/LibreVNA/librevnausbdriver.cpp \ Device/LibreVNA/manualcontroldialogV1.cpp \ + Device/LibreVNA/manualcontroldialogvfe.cpp \ Device/LibreVNA/manualcontroldialogvff.cpp \ Device/LibreVNA/receivercaldialog.cpp \ Device/LibreVNA/sourcecaldialog.cpp \ @@ -330,12 +334,14 @@ FORMS += \ Device/LibreVNA/amplitudecaldialog.ui \ Device/LibreVNA/automaticamplitudedialog.ui \ Device/LibreVNA/deviceconfigurationdialogv1.ui \ + Device/LibreVNA/deviceconfigurationdialogvfe.ui \ Device/LibreVNA/deviceconfigurationdialogvff.ui \ Device/LibreVNA/devicepacketlogview.ui \ Device/LibreVNA/firmwareupdatedialog.ui \ Device/LibreVNA/frequencycaldialog.ui \ Device/LibreVNA/librevnadriversettingswidget.ui \ Device/LibreVNA/manualcontroldialogV1.ui \ + Device/LibreVNA/manualcontroldialogvfe.ui \ Device/LibreVNA/manualcontroldialogvff.ui \ Device/devicelog.ui \ Device/devicetcpdriversettings.ui \ diff --git a/Software/PC_Application/LibreVNA-Test/LibreVNA-Test.pro b/Software/PC_Application/LibreVNA-Test/LibreVNA-Test.pro index a6c1a624..24ba1901 100644 --- a/Software/PC_Application/LibreVNA-Test/LibreVNA-Test.pro +++ b/Software/PC_Application/LibreVNA-Test/LibreVNA-Test.pro @@ -27,6 +27,7 @@ SOURCES += \ ../LibreVNA-GUI/CustomWidgets/tracesetselector.cpp \ ../LibreVNA-GUI/Device/LibreVNA/amplitudecaldialog.cpp \ ../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogv1.cpp \ + ../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvfe.cpp \ ../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvff.cpp \ ../LibreVNA-GUI/Device/LibreVNA/firmwareupdatedialog.cpp \ ../LibreVNA-GUI/Device/LibreVNA/frequencycaldialog.cpp \ @@ -34,6 +35,7 @@ SOURCES += \ ../LibreVNA-GUI/Device/LibreVNA/librevnatcpdriver.cpp \ ../LibreVNA-GUI/Device/LibreVNA/librevnausbdriver.cpp \ ../LibreVNA-GUI/Device/LibreVNA/manualcontroldialogV1.cpp \ + ../LibreVNA-GUI/Device/LibreVNA/manualcontroldialogvfe.cpp \ ../LibreVNA-GUI/Device/LibreVNA/manualcontroldialogvff.cpp \ ../LibreVNA-GUI/Device/LibreVNA/receivercaldialog.cpp \ ../LibreVNA-GUI/Device/LibreVNA/sourcecaldialog.cpp \ @@ -203,6 +205,7 @@ HEADERS += \ ../LibreVNA-GUI/CustomWidgets/tracesetselector.h \ ../LibreVNA-GUI/Device/LibreVNA/amplitudecaldialog.h \ ../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogv1.h \ + ../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvfe.h \ ../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvff.h \ ../LibreVNA-GUI/Device/LibreVNA/firmwareupdatedialog.h \ ../LibreVNA-GUI/Device/LibreVNA/frequencycaldialog.h \ @@ -210,6 +213,7 @@ HEADERS += \ ../LibreVNA-GUI/Device/LibreVNA/librevnatcpdriver.h \ ../LibreVNA-GUI/Device/LibreVNA/librevnausbdriver.h \ ../LibreVNA-GUI/Device/LibreVNA/manualcontroldialogV1.h \ + ../LibreVNA-GUI/Device/LibreVNA/manualcontroldialogvfe.h \ ../LibreVNA-GUI/Device/LibreVNA/manualcontroldialogvff.h \ ../LibreVNA-GUI/Device/LibreVNA/receivercaldialog.h \ ../LibreVNA-GUI/Device/LibreVNA/sourcecaldialog.h \ @@ -364,12 +368,14 @@ FORMS += \ ../LibreVNA-GUI/Device/LibreVNA/amplitudecaldialog.ui \ ../LibreVNA-GUI/Device/LibreVNA/automaticamplitudedialog.ui \ ../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogv1.ui \ + ../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvfe.ui \ ../LibreVNA-GUI/Device/LibreVNA/deviceconfigurationdialogvff.ui \ ../LibreVNA-GUI/Device/LibreVNA/firmwareupdatedialog.ui \ ../LibreVNA-GUI/Device/LibreVNA/frequencycaldialog.ui \ ../LibreVNA-GUI/Device/LibreVNA/librevnadriversettingswidget.ui \ ../LibreVNA-GUI/Device/LibreVNA/manualcontroldialogV1.ui \ ../LibreVNA-GUI/Device/LibreVNA/Compound/compounddeviceeditdialog.ui \ + ../LibreVNA-GUI/Device/LibreVNA/manualcontroldialogvfe.ui \ ../LibreVNA-GUI/Device/LibreVNA/manualcontroldialogvff.ui \ ../LibreVNA-GUI/Device/devicelog.ui \ ../LibreVNA-GUI/Device/LibreVNA/devicepacketlogview.ui \ diff --git a/Software/VNA_embedded/Application/Communication/Protocol.hpp b/Software/VNA_embedded/Application/Communication/Protocol.hpp index 58defafb..b84f7efd 100644 --- a/Software/VNA_embedded/Application/Communication/Protocol.hpp +++ b/Software/VNA_embedded/Application/Communication/Protocol.hpp @@ -238,6 +238,15 @@ using DeviceStatus = struct _deviceStatus { uint8_t unlevel:1; uint8_t temp_MCU; } VFF; + struct { + uint8_t source_locked:1; + uint8_t LO_locked:1; + uint8_t ADC_overload:1; + uint8_t unlevel:1; + uint8_t temp_MCU; + uint16_t temp_eCal; // in 1/100 °C + uint16_t power_heater; // in mW + } VFE; }; }; @@ -264,6 +273,16 @@ using ManualStatus = struct _manualstatus { uint8_t source_locked :1; uint8_t LO_locked :1; } VFF; + struct { + int16_t portmin, portmax; + int16_t refmin, refmax; + float portreal, portimag; + float refreal, refimag; + uint8_t source_locked :1; + uint8_t LO_locked :1; + uint16_t temp_eCal; // in 1/100 °C + uint16_t power_heater; // in mW + } VFE; }; }; @@ -322,6 +341,30 @@ using ManualControl = struct _manualControl { uint16_t RefGain :4; uint16_t Samples; } VFF; + struct { + // Source + uint8_t SourceCE :1; + uint8_t SourceRFEN :1; + uint64_t SourceFrequency; + // Source signal path + uint8_t attenuator :7; + uint8_t SourceAmplifier1EN :1; + uint8_t SourceAmplifier2EN :1; + // LO + uint8_t LOCE :1; + uint8_t LORFEN :1; + uint64_t LOFrequency; + // Acquisition + uint16_t PortEN :1; + uint16_t RefEN :1; + uint16_t WindowType :2; + uint16_t PortGain :4; + uint16_t RefGain :4; + uint16_t Samples; + // other settings + uint8_t eCal_state :2; + uint16_t eCal_target; // in 1/100 °C + } VFE; }; }; @@ -405,6 +448,11 @@ using DeviceConfig = struct _deviceconfig { uint16_t portGain :4; uint16_t refGain :4; } VFF; + struct { + uint16_t autogain :1; + uint16_t portGain :4; + uint16_t refGain :4; + } VFE; }; };