Skip to content

Commit

Permalink
option to match span to active calibration
Browse files Browse the repository at this point in the history
  • Loading branch information
jankae committed Jan 27, 2024
1 parent 8a90060 commit 3bc9070
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
27 changes: 27 additions & 0 deletions Software/PC_Application/LibreVNA-GUI/VNA/vna.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ VNA::VNA(AppWindow *window, QString name)
InformationBox::ShowMessage("Invalid calibration", "The selected calibration was created for a different device. You can still load it but the resulting "
"data likely isn't useful.");
}
if(cal.getCaltype().type != Calibration::Type::None) {
if(InformationBox::AskQuestion("Adjust span?", "Do you want to adjust the span to match the loaded calibration file?", false)) {
SpanMatchCal();
}
}
});

connect(saveCal, &QAction::triggered, [=](){
Expand Down Expand Up @@ -330,6 +335,14 @@ VNA::VNA(AppWindow *window, QString name)
connect(bZero, &QPushButton::clicked, this, &VNA::SetZeroSpan);
frequencySweepActions.push_back(tb_sweep->addWidget(bZero));

bMatchCal = new QPushButton("Cal");
bMatchCal->setToolTip("Match span of calibration");
bMatchCal->setMaximumWidth(28);
bMatchCal->setMaximumHeight(24);
bMatchCal->setEnabled(false);
connect(bMatchCal, &QPushButton::clicked, this, &VNA::SpanMatchCal);
frequencySweepActions.push_back(tb_sweep->addWidget(bMatchCal));

cbLogSweep = new QCheckBox("Log");
cbLogSweep->setToolTip("Logarithmic sweep");
connect(cbLogSweep, &QCheckBox::toggled, this, &VNA::SetLogSweep);
Expand Down Expand Up @@ -479,6 +492,7 @@ VNA::VNA(AppWindow *window, QString name)
calImportTerms->setEnabled(false);
calImportMeas->setEnabled(false);
calApplyToTraces->setEnabled(false);
bMatchCal->setEnabled(false);
// saveCal->setEnabled(false);
});
connect(&cal, &Calibration::activated, [=](Calibration::CalType applied){
Expand All @@ -494,6 +508,7 @@ VNA::VNA(AppWindow *window, QString name)
calImportTerms->setEnabled(true);
calImportMeas->setEnabled(true);
calApplyToTraces->setEnabled(true);
bMatchCal->setEnabled(true);
saveCal->setEnabled(true);
});

Expand Down Expand Up @@ -1101,6 +1116,18 @@ void VNA::SpanZoomOut()
ConstrainAndUpdateFrequencies();
}

bool VNA::SpanMatchCal()
{
if(cal.getCaltype().type == Calibration::Type::None) {
// no cal, nothing to adjust
return false;
}
SetStartFreq(cal.getMinFreq());
SetStopFreq(cal.getMaxFreq());
SetPoints(cal.getNumPoints());
return true;
}

void VNA::SetLogSweep(bool log)
{
if(settings.Freq.logSweep != log) {
Expand Down
3 changes: 2 additions & 1 deletion Software/PC_Application/LibreVNA-GUI/VNA/vna.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ private slots:
void SetZeroSpan();
void SpanZoomIn();
void SpanZoomOut();
bool SpanMatchCal();

void SetLogSweep(bool log);
// Acquisition control
Expand Down Expand Up @@ -158,7 +159,7 @@ private slots:

QComboBox *cbSweepType;
QCheckBox *cbLogSweep;
QPushButton *bZero;
QPushButton *bZero, *bMatchCal;

QMenu *defaultCalMenu;
QAction *assignDefaultCal, *removeDefaultCal;
Expand Down

0 comments on commit 3bc9070

Please sign in to comment.