Skip to content

Commit

Permalink
Airspy: Make settings assignments atomic. Part of #1329
Browse files Browse the repository at this point in the history
  • Loading branch information
f4exb committed Oct 22, 2022
1 parent c3f098a commit 1544ea3
Show file tree
Hide file tree
Showing 6 changed files with 218 additions and 88 deletions.
35 changes: 33 additions & 2 deletions plugins/samplesource/airspy/airspygui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ void AirspyGui::resetToDefaults()
{
m_settings.resetToDefaults();
displaySettings();
m_forceSettings = true;
sendSettings();
}

Expand Down Expand Up @@ -119,7 +120,13 @@ bool AirspyGui::handleMessage(const Message& message)
if (AirspyInput::MsgConfigureAirspy::match(message))
{
const AirspyInput::MsgConfigureAirspy& cfg = (AirspyInput::MsgConfigureAirspy&) message;
m_settings = cfg.getSettings();

if (cfg.getForce()) {
m_settings = cfg.getSettings();
} else {
m_settings.applySettings(cfg.getSettingsKeys(), cfg.getSettings());
}

blockApplySettings(true);
displaySettings();
blockApplySettings(false);
Expand Down Expand Up @@ -267,49 +274,57 @@ void AirspyGui::sendSettings()
void AirspyGui::on_centerFrequency_changed(quint64 value)
{
m_settings.m_centerFrequency = value * 1000;
m_settingsKeys.append("centerFrequency");
sendSettings();
}

void AirspyGui::on_LOppm_valueChanged(int value)
{
m_settings.m_LOppmTenths = value;
ui->LOppmText->setText(QString("%1").arg(QString::number(m_settings.m_LOppmTenths/10.0, 'f', 1)));
m_settingsKeys.append("LOppmTenths");
sendSettings();
}

void AirspyGui::on_dcOffset_toggled(bool checked)
{
m_settings.m_dcBlock = checked;
m_settingsKeys.append("dcBlock");
sendSettings();
}

void AirspyGui::on_iqImbalance_toggled(bool checked)
{
m_settings.m_iqCorrection = checked;
m_settingsKeys.append("iqCorrection");
sendSettings();
}

void AirspyGui::on_sampleRate_currentIndexChanged(int index)
{
m_settings.m_devSampleRateIndex = index;
m_settingsKeys.append("devSampleRateIndex");
sendSettings();
}

void AirspyGui::on_biasT_stateChanged(int state)
{
m_settings.m_biasT = (state == Qt::Checked);
m_settingsKeys.append("biasT");
sendSettings();
}

void AirspyGui::on_lnaAGC_stateChanged(int state)
{
m_settings.m_lnaAGC = (state == Qt::Checked);
m_settingsKeys.append("lnaAGC");
sendSettings();
}

void AirspyGui::on_mixAGC_stateChanged(int state)
{
m_settings.m_mixerAGC = (state == Qt::Checked);
m_settingsKeys.append("mixerAGC");
sendSettings();
}

Expand All @@ -318,19 +333,23 @@ void AirspyGui::on_decim_currentIndexChanged(int index)
if ((index <0) || (index > 6))
return;
m_settings.m_log2Decim = index;
m_settingsKeys.append("log2Decim");
sendSettings();
}

void AirspyGui::on_fcPos_currentIndexChanged(int index)
{
if (index == 0) {
m_settings.m_fcPos = AirspySettings::FC_POS_INFRA;
m_settingsKeys.append("fcPos");
sendSettings();
} else if (index == 1) {
m_settings.m_fcPos = AirspySettings::FC_POS_SUPRA;
m_settingsKeys.append("fcPos");
sendSettings();
} else if (index == 2) {
m_settings.m_fcPos = AirspySettings::FC_POS_CENTER;
m_settingsKeys.append("fcPos");
sendSettings();
}
}
Expand All @@ -342,6 +361,7 @@ void AirspyGui::on_lna_valueChanged(int value)

ui->lnaGainText->setText(tr("%1dB").arg(value));
m_settings.m_lnaGain = value;
m_settingsKeys.append("lnaGain");
sendSettings();
}

Expand All @@ -352,6 +372,7 @@ void AirspyGui::on_mix_valueChanged(int value)

ui->mixText->setText(tr("%1dB").arg(value));
m_settings.m_mixerGain = value;
m_settingsKeys.append("mixerGain");
sendSettings();
}

Expand All @@ -362,6 +383,7 @@ void AirspyGui::on_vga_valueChanged(int value)

ui->vgaText->setText(tr("%1dB").arg(value));
m_settings.m_vgaGain = value;
m_settingsKeys.append("vgaGain");
sendSettings();
}

Expand All @@ -382,14 +404,19 @@ void AirspyGui::on_transverter_clicked()
qDebug("AirspyGui::on_transverter_clicked: %lld Hz %s", m_settings.m_transverterDeltaFrequency, m_settings.m_transverterMode ? "on" : "off");
updateFrequencyLimits();
m_settings.m_centerFrequency = ui->centerFrequency->getValueNew()*1000;
m_settingsKeys.append("transverterMode");
m_settingsKeys.append("m_transverterDeltaFrequency");
m_settingsKeys.append("m_iqOrder");
m_settingsKeys.append("centerFrequency");
sendSettings();
}

void AirspyGui::updateHardware()
{
qDebug() << "AirspyGui::updateHardware";
AirspyInput::MsgConfigureAirspy* message = AirspyInput::MsgConfigureAirspy::create(m_settings, m_forceSettings);
AirspyInput::MsgConfigureAirspy* message = AirspyInput::MsgConfigureAirspy::create(m_settings, m_settingsKeys, m_forceSettings);
m_sampleSource->getInputMessageQueue()->push(message);
m_settingsKeys.clear();
m_forceSettings = false;
m_updateTimer.stop();
}
Expand Down Expand Up @@ -466,6 +493,10 @@ void AirspyGui::openDeviceSettingsDialog(const QPoint& p)
m_settings.m_reverseAPIPort = dialog.getReverseAPIPort();
m_settings.m_reverseAPIDeviceIndex = dialog.getReverseAPIDeviceIndex();

m_settingsKeys.append("useReverseAPI");
m_settingsKeys.append("reverseAPIAddress");
m_settingsKeys.append("reverseAPIPort");
m_settingsKeys.append("reverseAPIDeviceIndex");
sendSettings();
}

Expand Down
1 change: 1 addition & 0 deletions plugins/samplesource/airspy/airspygui.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class AirspyGui : public DeviceGUI {
bool m_doApplySettings;
bool m_forceSettings;
AirspySettings m_settings;
QList<QString> m_settingsKeys;
QTimer m_updateTimer;
QTimer m_statusTimer;
std::vector<uint32_t> m_rates;
Expand Down
Loading

0 comments on commit 1544ea3

Please sign in to comment.