Skip to content

Commit 1615bb4

Browse files
committed
only load default calibration when connecting to device
1 parent bf028e2 commit 1615bb4

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

Software/PC_Application/LibreVNA-GUI/VNA/vna.cpp

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -804,17 +804,26 @@ void VNA::initializeDevice()
804804
QSettings s;
805805
auto key = "DefaultCalibration"+window->getDevice()->getSerial();
806806
if (s.contains(key)) {
807-
auto filename = s.value(key).toString();
808-
qDebug() << "Attempting to load default calibration file " << filename;
809-
if(QFile::exists(filename)) {
810-
if(cal.fromFile(filename)) {
811-
qDebug() << "Calibration successful from " << filename;
807+
808+
// only load default calibration once per device. This allows the user to switch to a different calibration
809+
// and have it persist across device initializations. Only when connecting to the device again should the
810+
// default calibration be loaded
811+
if(defaultCalSerial != window->getDevice()->getSerial()) {
812+
// we have never loaded the default calibration for this device, do so now
813+
auto filename = s.value(key).toString();
814+
qDebug() << "Attempting to load default calibration file " << filename;
815+
if(QFile::exists(filename)) {
816+
if(cal.fromFile(filename)) {
817+
qDebug() << "Calibration successful from " << filename;
818+
defaultCalSerial = window->getDevice()->getSerial();
819+
} else {
820+
qDebug() << "Calibration not successfull from: " << filename;
821+
}
812822
} else {
813-
qDebug() << "Calibration not successfull from: " << filename;
823+
qDebug() << "Calibration file not found: " << filename;
814824
}
815-
} else {
816-
qDebug() << "Calibration file not found: " << filename;
817825
}
826+
818827
removeDefaultCal->setEnabled(true);
819828
} else {
820829
qDebug() << "No default calibration file set for this device";
@@ -833,6 +842,8 @@ void VNA::initializeDevice()
833842
void VNA::deviceDisconnected()
834843
{
835844
defaultCalMenu->setEnabled(false);
845+
qDebug() << "disconnected";
846+
defaultCalSerial.clear();
836847
emit sweepStopped();
837848
}
838849

Software/PC_Application/LibreVNA-GUI/VNA/vna.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ private slots:
180180

181181
QMenu *defaultCalMenu;
182182
QAction *assignDefaultCal, *removeDefaultCal;
183+
QString defaultCalSerial;
183184
QAction *saveCal;
184185

185186
Deembedding deembedding;

0 commit comments

Comments
 (0)