mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-07-26 12:04:13 -04:00
plutosdr: Update RX gain limits dynamically from hardware
Query the PlutoSDR hardware for the current RX gain range and use it to configure the GUI gain control dynamically. The AD936x gain limits vary with LO frequency. Previously the GUI used a fixed gain range, allowing users to select values that the hardware would reject after changing bands. The gain slider now refreshes its minimum, maximum, and step size whenever the device center frequency is updated. Also change the gain setting serialization to use a signed integer so negative gain values are preserved for operating modes that support them. Changes include: - Add DevicePlutoSDRBox::getGainRange() to read in_voltage0_hardwaregain_available. - Expose gain range through PlutoSDRInput. - Refresh GUI gain limits when the device frequency changes. - Avoid unnecessary widget updates when limits are unchanged. - Store/restore gain as a signed value. - Add default RX gain limit constants for fallback when the device cannot provide its range. Signed-off-by: Robin Getz <rgetz503@gmail.com>
This commit is contained in:
@@ -70,6 +70,8 @@ PlutoSDRInputGui::PlutoSDRInputGui(DeviceUISet *deviceUISet, QWidget* parent) :
|
||||
((PlutoSDRInput *) m_sampleSource)->getbbLPRange(minLimit, maxLimit);
|
||||
ui->lpf->setValueRange(5, minLimit/1000, maxLimit/1000);
|
||||
|
||||
refreshGainLimits();
|
||||
|
||||
ui->lpFIR->setColorMapper(ColorMapper(ColorMapper::GrayYellow));
|
||||
ui->lpFIR->setValueRange(5, 1U, 56000U); // will be dynamically recalculated
|
||||
|
||||
@@ -390,6 +392,22 @@ void PlutoSDRInputGui::displaySampleRate()
|
||||
ui->sampleRate->blockSignals(false);
|
||||
}
|
||||
|
||||
void PlutoSDRInputGui::refreshGainLimits()
|
||||
{
|
||||
qint64 minGain, stepGain, maxGain;
|
||||
((PlutoSDRInput *) m_sampleSource)->getGainRange(minGain, stepGain, maxGain);
|
||||
|
||||
// Only update the gui when necessary, avoid unnecessary widget updates
|
||||
if (ui->gain->minimum() != minGain ||
|
||||
ui->gain->maximum() != maxGain ||
|
||||
ui->gain->singleStep() != stepGain)
|
||||
{
|
||||
ui->gain->setMinimum(minGain);
|
||||
ui->gain->setMaximum(maxGain);
|
||||
ui->gain->setSingleStep(stepGain);
|
||||
}
|
||||
}
|
||||
|
||||
void PlutoSDRInputGui::displayFcTooltip()
|
||||
{
|
||||
int32_t fShift = DeviceSampleSource::calculateFrequencyShift(
|
||||
@@ -600,6 +618,7 @@ void PlutoSDRInputGui::updateSampleRateAndFrequency()
|
||||
{
|
||||
m_deviceUISet->getSpectrum()->setSampleRate(m_sampleRate);
|
||||
m_deviceUISet->getSpectrum()->setCenterFrequency(m_deviceCenterFrequency);
|
||||
refreshGainLimits();
|
||||
displaySampleRate();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user