Skip to content

Commit

Permalink
added dialogs for hardware version 0xFE
Browse files Browse the repository at this point in the history
  • Loading branch information
jankae committed Nov 7, 2023
1 parent 772ef44 commit 11612e4
Show file tree
Hide file tree
Showing 12 changed files with 1,694 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#include "deviceconfigurationdialogvfe.h"
#include "ui_deviceconfigurationdialogvfe.h"

#include <QtEndian>

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);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#ifndef DEVICECONFIGURATIONDIALOGVFE_H
#define DEVICECONFIGURATIONDIALOGVFE_H

#include "librevnadriver.h"

#include <QDialog>
#include <QHostAddress>

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
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DeviceConfigurationDialogVFE</class>
<widget class="QWidget" name="DeviceConfigurationDialogVFE">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>307</width>
<height>180</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>PGA configuration (reset after reboot)</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QCheckBox" name="autogain">
<property name="text">
<string>Autogain</string>
</property>
</widget>
</item>
<item>
<layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Port gain:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="portgain">
<item>
<property name="text">
<string>1V/V</string>
</property>
</item>
<item>
<property name="text">
<string>10V/V</string>
</property>
</item>
<item>
<property name="text">
<string>20V/V</string>
</property>
</item>
<item>
<property name="text">
<string>30V/V</string>
</property>
</item>
<item>
<property name="text">
<string>40V/V</string>
</property>
</item>
<item>
<property name="text">
<string>60V/V</string>
</property>
</item>
<item>
<property name="text">
<string>80V/V</string>
</property>
</item>
<item>
<property name="text">
<string>120V/V</string>
</property>
</item>
<item>
<property name="text">
<string>157V/V</string>
</property>
</item>
<item>
<property name="text">
<string>0.25V/V</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Reference gain:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="refgain">
<item>
<property name="text">
<string>1V/V</string>
</property>
</item>
<item>
<property name="text">
<string>10V/V</string>
</property>
</item>
<item>
<property name="text">
<string>20V/V</string>
</property>
</item>
<item>
<property name="text">
<string>30V/V</string>
</property>
</item>
<item>
<property name="text">
<string>40V/V</string>
</property>
</item>
<item>
<property name="text">
<string>60V/V</string>
</property>
</item>
<item>
<property name="text">
<string>80V/V</string>
</property>
</item>
<item>
<property name="text">
<string>120V/V</string>
</property>
</item>
<item>
<property name="text">
<string>157V/V</string>
</property>
</item>
<item>
<property name="text">
<string>0.25V/V</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
Loading

0 comments on commit 11612e4

Please sign in to comment.