1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 17:58:43 -05:00

BladeRF2 input: fixed auto/manual transition gain control

This commit is contained in:
f4exb 2018-09-27 05:44:20 +02:00
parent 3a4324a7fb
commit 3e876141f4
2 changed files with 37 additions and 18 deletions

View File

@ -810,24 +810,6 @@ bool BladeRF2Input::applySettings(const BladeRF2InputSettings& settings, bool fo
m_deviceShared.m_dev->setBiasTeeRx(settings.m_biasTee);
}
if ((m_settings.m_globalGain != settings.m_globalGain) || force)
{
forwardChangeRxBuddies = true;
if (dev)
{
// qDebug("BladeRF2Input::applySettings: channel: %d gain: %d", requestedChannel, settings.m_globalGain);
int status = bladerf_set_gain(dev, BLADERF_CHANNEL_RX(requestedChannel), settings.m_globalGain);
if (status < 0) {
qWarning("BladeRF2Input::applySettings: bladerf_set_gain(%d) failed: %s",
settings.m_globalGain, bladerf_strerror(status));
} else {
qDebug("BladeRF2Input::applySettings: bladerf_set_gain(%d)", settings.m_globalGain);
}
}
}
if ((m_settings.m_gainMode != settings.m_gainMode) || force)
{
forwardChangeRxBuddies = true;
@ -845,6 +827,25 @@ bool BladeRF2Input::applySettings(const BladeRF2InputSettings& settings, bool fo
}
}
if ((m_settings.m_globalGain != settings.m_globalGain)
|| ((m_settings.m_gainMode != settings.m_gainMode) && (settings.m_gainMode == BLADERF_GAIN_MANUAL)) || force)
{
forwardChangeRxBuddies = true;
if (dev)
{
// qDebug("BladeRF2Input::applySettings: channel: %d gain: %d", requestedChannel, settings.m_globalGain);
int status = bladerf_set_gain(dev, BLADERF_CHANNEL_RX(requestedChannel), settings.m_globalGain);
if (status < 0) {
qWarning("BladeRF2Input::applySettings: bladerf_set_gain(%d) failed: %s",
settings.m_globalGain, bladerf_strerror(status));
} else {
qDebug("BladeRF2Input::applySettings: bladerf_set_gain(%d)", settings.m_globalGain);
}
}
}
if (forwardChangeOwnDSP)
{
int sampleRate = settings.m_devSampleRate/(1<<settings.m_log2Decim);

View File

@ -241,6 +241,12 @@ void BladeRF2InputGui::displaySettings()
ui->gainText->setText(tr("%1 dB").arg(m_settings.m_globalGain));
ui->gain->setValue(m_settings.m_globalGain);
if (m_settings.m_gainMode == BLADERF_GAIN_MANUAL) {
ui->gain->setEnabled(true);
} else {
ui->gain->setEnabled(false);
}
blockApplySettings(false);
}
@ -310,6 +316,18 @@ void BladeRF2InputGui::on_gainMode_currentIndexChanged(int index)
if (uindex < modes.size())
{
BladeRF2Input::GainMode mode = modes[index];
if (m_settings.m_gainMode != mode.m_value)
{
if (mode.m_value == BLADERF_GAIN_MANUAL)
{
m_settings.m_globalGain = ui->gain->value();
ui->gain->setEnabled(true);
} else {
ui->gain->setEnabled(false);
}
}
m_settings.m_gainMode = mode.m_value;
sendSettings();
}