mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-08-10 21:43:31 -04:00
PlutoSDR input: implemented the rest of apply settings
This commit is contained in:
@@ -247,7 +247,6 @@ bool PlutoSDRInput::applySettings(const PlutoSDRInputSettings& settings, bool fo
|
||||
bool suspendOwnThread = false;
|
||||
bool ownThreadWasRunning = false;
|
||||
bool suspendAllOtherThreads = false; // All others means Tx in fact
|
||||
bool doCalibration = false;
|
||||
bool firFilterSet = false;
|
||||
DevicePlutoSDRBox *plutoBox = m_deviceShared.m_deviceParams->getBox();
|
||||
|
||||
@@ -302,6 +301,12 @@ bool PlutoSDRInput::applySettings(const PlutoSDRInputSettings& settings, bool fo
|
||||
|
||||
// TODO: apply settings (all cases)
|
||||
|
||||
if ((m_settings.m_dcBlock != settings.m_dcBlock) ||
|
||||
(m_settings.m_iqCorrection != settings.m_iqCorrection) || force)
|
||||
{
|
||||
m_deviceAPI->configureCorrections(settings.m_dcBlock, m_settings.m_iqCorrection);
|
||||
}
|
||||
|
||||
// Change affecting device sample rate chain potentially affecting other buddies device/host sample rate
|
||||
if ((m_settings.m_devSampleRate != settings.m_devSampleRate) ||
|
||||
(m_settings.m_rateGovernor != settings.m_rateGovernor) ||
|
||||
@@ -361,29 +366,72 @@ bool PlutoSDRInput::applySettings(const PlutoSDRInputSettings& settings, bool fo
|
||||
if (m_plutoSDRInputThread != 0)
|
||||
{
|
||||
m_plutoSDRInputThread->setLog2Decimation(settings.m_log2Decim);
|
||||
qDebug() << "PlutoSDRInput::applySettings: set soft decimation to " << (1<<m_settings.m_log2Decim);
|
||||
qDebug() << "PlutoSDRInput::applySettings: set soft decimation to " << (1<<settings.m_log2Decim);
|
||||
}
|
||||
|
||||
forwardChangeOwnDSP = true;
|
||||
}
|
||||
|
||||
if ((m_settings.m_fcPos != settings.m_fcPos) || force)
|
||||
{
|
||||
if (m_plutoSDRInputThread != 0)
|
||||
{
|
||||
m_plutoSDRInputThread->setFcPos(settings.m_fcPos);
|
||||
qDebug() << "PlutoSDRInput::applySettings: set fcPos to " << (1<<settings.m_fcPos);
|
||||
}
|
||||
}
|
||||
|
||||
if ((m_settings.m_LOppmTenths != settings.m_LOppmTenths) || force)
|
||||
{
|
||||
int64_t newXO = plutoBox->getInitialXO() + ((plutoBox->getInitialXO()*settings.m_LOppmTenths) / 10000000L);
|
||||
std::vector<std::string> params;
|
||||
params.push_back(QString(tr("xo_correction=%1").arg(newXO)).toStdString());
|
||||
plutoBox->set_params(DevicePlutoSDRBox::DEVICE_PHY, params);
|
||||
}
|
||||
|
||||
if ((m_settings.m_centerFrequency != settings.m_centerFrequency) || force)
|
||||
{
|
||||
std::vector<std::string> params;
|
||||
params.push_back(QString(tr("in_voltage_sampling_frequency=%1").arg(settings.m_centerFrequency)).toStdString());
|
||||
params.push_back(QString(tr("out_altvoltage0_RX_LO_frequency=%1").arg(settings.m_centerFrequency)).toStdString());
|
||||
plutoBox->set_params(DevicePlutoSDRBox::DEVICE_PHY, params);
|
||||
|
||||
forwardChangeOwnDSP = true;
|
||||
}
|
||||
|
||||
m_settings = settings;
|
||||
|
||||
// TODO: calibration
|
||||
if (doCalibration)
|
||||
if ((m_settings.m_lpfBW != settings.m_lpfBW) || force)
|
||||
{
|
||||
qDebug("PlutoSDRInput::applySettings: doCalibration");
|
||||
std::vector<std::string> params;
|
||||
params.push_back(QString(tr("in_voltage_rf_bandwidth=%1").arg(settings.m_lpfBW)).toStdString());
|
||||
plutoBox->set_params(DevicePlutoSDRBox::DEVICE_PHY, params);
|
||||
}
|
||||
|
||||
if ((m_settings.m_antennaPath != settings.m_antennaPath) || force)
|
||||
{
|
||||
std::vector<std::string> params;
|
||||
QString rfPortStr;
|
||||
PlutoSDRInputSettings::translateRFPath(settings.m_antennaPath, rfPortStr);
|
||||
params.push_back(QString(tr("in_voltage0_rf_port_select=%1").arg(rfPortStr)).toStdString());
|
||||
plutoBox->set_params(DevicePlutoSDRBox::DEVICE_PHY, params);
|
||||
}
|
||||
|
||||
if ((m_settings.m_gainMode != settings.m_gainMode) || force)
|
||||
{
|
||||
std::vector<std::string> params;
|
||||
QString gainModeStr;
|
||||
PlutoSDRInputSettings::translateGainMode(settings.m_gainMode, gainModeStr);
|
||||
params.push_back(QString(tr("in_voltage0_gain_control_mode=%1").arg(gainModeStr)).toStdString());
|
||||
plutoBox->set_params(DevicePlutoSDRBox::DEVICE_PHY, params);
|
||||
}
|
||||
|
||||
if ((m_settings.m_gain != settings.m_gain) || force)
|
||||
{
|
||||
std::vector<std::string> params;
|
||||
params.push_back(QString(tr("in_voltage0_hardwaregain=%1").arg(settings.m_gain)).toStdString());
|
||||
plutoBox->set_params(DevicePlutoSDRBox::DEVICE_PHY, params);
|
||||
}
|
||||
|
||||
m_settings = settings;
|
||||
|
||||
if (suspendAllOtherThreads)
|
||||
{
|
||||
const std::vector<DeviceSinkAPI*>& sinkBuddies = m_deviceAPI->getSinkBuddies();
|
||||
|
||||
@@ -147,3 +147,71 @@ void PlutoSDRInputSettings::translateGovernor(RateGovernor gov, QString& s)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void PlutoSDRInputSettings::translateRFPath(RFPath path, QString& s)
|
||||
{
|
||||
switch(path)
|
||||
{
|
||||
case RFPATH_A_BAL:
|
||||
s = "A_BALANCED";
|
||||
break;
|
||||
case RFPATH_B_BAL:
|
||||
s = "B_BALANCED";
|
||||
break;
|
||||
case RFPATH_C_BAL:
|
||||
s = "C_BALANCED";
|
||||
break;
|
||||
case RFPATH_A_NEG:
|
||||
s = "A_N";
|
||||
break;
|
||||
case RFPATH_A_POS:
|
||||
s = "A_P";
|
||||
break;
|
||||
case RFPATH_B_NEG:
|
||||
s = "B_N";
|
||||
break;
|
||||
case RFPATH_B_POS:
|
||||
s = "B_P";
|
||||
break;
|
||||
case RFPATH_C_NEG:
|
||||
s = "C_N";
|
||||
break;
|
||||
case RFPATH_C_POS:
|
||||
s = "C_P";
|
||||
break;
|
||||
case RFPATH_TX1MON:
|
||||
s = "TX_MONITOR1";
|
||||
break;
|
||||
case RFPATH_TX2MON:
|
||||
s = "TX_MONITOR2";
|
||||
break;
|
||||
case RFPATH_TX3MON:
|
||||
s = "TX_MONITOR3";
|
||||
break;
|
||||
default:
|
||||
s = "A_BALANCED";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void PlutoSDRInputSettings::translateGainMode(GainMode mode, QString& s)
|
||||
{
|
||||
switch(mode)
|
||||
{
|
||||
case GAIN_MANUAL:
|
||||
s = "manual";
|
||||
break;
|
||||
case GAIN_AGC_SLOW:
|
||||
s = "slow_attack";
|
||||
break;
|
||||
case GAIN_AGC_FAST:
|
||||
s = "fast_attack";
|
||||
break;
|
||||
case GAIN_HYBRID:
|
||||
s = "hybrid";
|
||||
break;
|
||||
default:
|
||||
s = "manual";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,6 +83,8 @@ struct PlutoSDRInputSettings {
|
||||
QByteArray serialize() const;
|
||||
bool deserialize(const QByteArray& data);
|
||||
static void translateGovernor(RateGovernor gov, QString& s);
|
||||
static void translateRFPath(RFPath path, QString& s);
|
||||
static void translateGainMode(GainMode mod, QString& s);
|
||||
};
|
||||
|
||||
#endif /* _PLUTOSDR_PLUTOSDRINPUTSETTINGS_H_ */
|
||||
|
||||
Reference in New Issue
Block a user