mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-26 09:48:45 -05:00
BladerRF2 input support. Fixed gain modes handling. Cosmetic changes
This commit is contained in:
parent
81ad05cb64
commit
4634fb481d
@ -50,6 +50,19 @@ BladeRF2Input::BladeRF2Input(DeviceSourceAPI *deviceAPI) :
|
||||
{
|
||||
openDevice();
|
||||
|
||||
if (m_deviceShared.m_dev)
|
||||
{
|
||||
const bladerf_gain_modes *modes = 0;
|
||||
int nbModes = m_deviceShared.m_dev->getGainModesRx(&modes);
|
||||
|
||||
if (modes)
|
||||
{
|
||||
for (int i = 0; i < nbModes; i++) {
|
||||
m_gainModes.push_back(GainMode{QString(modes[i].name), modes[i].mode});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_fileSink = new FileRecord(QString("test_%1.sdriq").arg(m_deviceAPI->getDeviceUID()));
|
||||
m_deviceAPI->addSink(m_fileSink);
|
||||
}
|
||||
@ -510,19 +523,6 @@ void BladeRF2Input::getGlobalGainRange(int& min, int& max, int& step)
|
||||
}
|
||||
}
|
||||
|
||||
const bladerf_gain_modes *BladeRF2Input::getGainModes(int& nbGains)
|
||||
{
|
||||
const bladerf_gain_modes *modes = 0;
|
||||
|
||||
if (m_deviceShared.m_dev) {
|
||||
nbGains = m_deviceShared.m_dev->getGainModesRx(&modes);
|
||||
} else {
|
||||
nbGains = 0;
|
||||
}
|
||||
|
||||
return modes;
|
||||
}
|
||||
|
||||
bool BladeRF2Input::handleMessage(const Message& message)
|
||||
{
|
||||
if (MsgConfigureBladeRF2::match(message))
|
||||
@ -1025,17 +1025,14 @@ void BladeRF2Input::webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& respo
|
||||
|
||||
response.getBladeRf2InputReport()->setGainModes(new QList<SWGSDRangel::SWGNamedEnum*>);
|
||||
|
||||
int nbModes;
|
||||
const bladerf_gain_modes *modes = getGainModes(nbModes);
|
||||
const std::vector<GainMode>& modes = getGainModes();
|
||||
std::vector<GainMode>::const_iterator it = modes.begin();
|
||||
|
||||
if (modes)
|
||||
{
|
||||
for (int i = 0; i < nbModes; modes++)
|
||||
for (; it != modes.end(); ++it)
|
||||
{
|
||||
response.getBladeRf2InputReport()->getGainModes()->append(new SWGSDRangel::SWGNamedEnum);
|
||||
response.getBladeRf2InputReport()->getGainModes()->back()->setName(new QString(modes[i].name));
|
||||
response.getBladeRf2InputReport()->getGainModes()->back()->setValue(modes[i].mode);
|
||||
}
|
||||
response.getBladeRf2InputReport()->getGainModes()->back()->setName(new QString(it->m_name));
|
||||
response.getBladeRf2InputReport()->getGainModes()->back()->setValue(it->m_value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -119,6 +119,12 @@ public:
|
||||
{}
|
||||
};
|
||||
|
||||
struct GainMode
|
||||
{
|
||||
QString m_name;
|
||||
int m_value;
|
||||
};
|
||||
|
||||
BladeRF2Input(DeviceSourceAPI *deviceAPI);
|
||||
virtual ~BladeRF2Input();
|
||||
virtual void destroy();
|
||||
@ -142,7 +148,7 @@ public:
|
||||
void getSampleRateRange(int& min, int& max, int& step);
|
||||
void getBandwidthRange(int& min, int& max, int& step);
|
||||
void getGlobalGainRange(int& min, int& max, int& step);
|
||||
const bladerf_gain_modes *getGainModes(int& nbGains);
|
||||
const std::vector<GainMode>& getGainModes() { return m_gainModes; }
|
||||
|
||||
virtual bool handleMessage(const Message& message);
|
||||
|
||||
@ -178,8 +184,7 @@ private:
|
||||
DeviceBladeRF2Shared m_deviceShared;
|
||||
BladeRF2InputThread *m_thread;
|
||||
FileRecord *m_fileSink; //!< File sink to record device I/Q output
|
||||
bladerf_gain_modes **m_gainModes;
|
||||
int m_nbGainModes;
|
||||
std::vector<GainMode> m_gainModes;
|
||||
|
||||
bool openDevice();
|
||||
void closeDevice();
|
||||
|
@ -56,20 +56,18 @@ BladeRF2InputGui::BladeRF2InputGui(DeviceUISet *deviceUISet, QWidget* parent) :
|
||||
|
||||
m_sampleSource->getBandwidthRange(min, max, step);
|
||||
ui->bandwidth->setColorMapper(ColorMapper(ColorMapper::GrayYellow));
|
||||
ui->bandwidth->setValueRange(6, min/1000, max/1000);
|
||||
ui->bandwidth->setValueRange(5, min/1000, max/1000);
|
||||
|
||||
m_gainModes = m_sampleSource->getGainModes(m_nbGainModes);
|
||||
const std::vector<BladeRF2Input::GainMode>& modes = m_sampleSource->getGainModes();
|
||||
std::vector<BladeRF2Input::GainMode>::const_iterator it = modes.begin();
|
||||
|
||||
if (m_gainModes)
|
||||
{
|
||||
ui->gainMode->blockSignals(true);
|
||||
|
||||
for (int i = 0; i < m_nbGainModes; i++) {
|
||||
ui->gainMode->addItem(tr("%1").arg(m_gainModes[i].name));
|
||||
for (; it != modes.end(); ++it) {
|
||||
ui->gainMode->addItem(it->m_name);
|
||||
}
|
||||
|
||||
ui->gainMode->blockSignals(false);
|
||||
}
|
||||
|
||||
m_sampleSource->getGlobalGainRange(min, max, step);
|
||||
ui->gain->setMinimum(min);
|
||||
@ -77,6 +75,8 @@ BladeRF2InputGui::BladeRF2InputGui(DeviceUISet *deviceUISet, QWidget* parent) :
|
||||
ui->gain->setPageStep(step);
|
||||
ui->gain->setSingleStep(step);
|
||||
|
||||
ui->label_decim->setText(QString::fromUtf8("D\u2193"));
|
||||
|
||||
connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateHardware()));
|
||||
connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus()));
|
||||
m_statusTimer.start(500);
|
||||
@ -238,7 +238,7 @@ void BladeRF2InputGui::displaySettings()
|
||||
ui->decim->setCurrentIndex(m_settings.m_log2Decim);
|
||||
ui->fcPos->setCurrentIndex((int) m_settings.m_fcPos);
|
||||
|
||||
ui->gainText->setText(tr("%1").arg(m_settings.m_globalGain));
|
||||
ui->gainText->setText(tr("%1 dB").arg(m_settings.m_globalGain));
|
||||
ui->gain->setValue(m_settings.m_globalGain);
|
||||
|
||||
blockApplySettings(false);
|
||||
@ -304,16 +304,20 @@ void BladeRF2InputGui::on_fcPos_currentIndexChanged(int index)
|
||||
|
||||
void BladeRF2InputGui::on_gainMode_currentIndexChanged(int index)
|
||||
{
|
||||
if (index < m_nbGainModes)
|
||||
const std::vector<BladeRF2Input::GainMode>& modes = m_sampleSource->getGainModes();
|
||||
unsigned int uindex = index < 0 ? 0 : (unsigned int) index;
|
||||
|
||||
if (uindex < modes.size())
|
||||
{
|
||||
m_settings.m_gainMode = m_gainModes[index].mode;
|
||||
BladeRF2Input::GainMode mode = modes[index];
|
||||
m_settings.m_gainMode = mode.m_value;
|
||||
sendSettings();
|
||||
}
|
||||
}
|
||||
|
||||
void BladeRF2InputGui::on_gain_valueChanged(int value)
|
||||
{
|
||||
ui->gainText->setText(tr("%1").arg(value));
|
||||
ui->gainText->setText(tr("%1 dB").arg(value));
|
||||
m_settings.m_globalGain = value;
|
||||
sendSettings();
|
||||
}
|
||||
|
@ -65,8 +65,6 @@ private:
|
||||
quint64 m_deviceCenterFrequency; //!< Center frequency in device
|
||||
int m_lastEngineState;
|
||||
MessageQueue m_inputMessageQueue;
|
||||
const struct bladerf_gain_modes *m_gainModes;
|
||||
int m_nbGainModes;
|
||||
|
||||
void displaySettings();
|
||||
void sendSettings();
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>310</width>
|
||||
<height>250</height>
|
||||
<width>350</width>
|
||||
<height>200</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@ -18,8 +18,8 @@
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>310</width>
|
||||
<height>250</height>
|
||||
<width>350</width>
|
||||
<height>200</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
@ -265,6 +265,9 @@
|
||||
<property name="cursor">
|
||||
<cursorShape>PointingHandCursor</cursorShape>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>RF bandwidth</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="7">
|
||||
@ -330,6 +333,9 @@
|
||||
<property name="cursor">
|
||||
<cursorShape>PointingHandCursor</cursorShape>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Device sample rate</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@ -384,7 +390,7 @@
|
||||
<item>
|
||||
<widget class="QLabel" name="label_decim">
|
||||
<property name="text">
|
||||
<string>Dec</string>
|
||||
<string>D</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -442,19 +448,26 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_decim" columnstretch="0,0,0,0,0,0">
|
||||
<layout class="QGridLayout" name="gridLayout_decim" columnstretch="0,0,0,0">
|
||||
<property name="spacing">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<item row="0" column="2">
|
||||
<widget class="QSlider" name="gain">
|
||||
<property name="toolTip">
|
||||
<string>Gain value</string>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="gainMode"/>
|
||||
<widget class="QComboBox" name="gainMode">
|
||||
<property name="toolTip">
|
||||
<string>Gain mode</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="gainLabel">
|
||||
@ -467,12 +480,12 @@
|
||||
<widget class="QLabel" name="gainText">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>25</width>
|
||||
<width>45</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>000</string>
|
||||
<string>000 dB</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
|
Loading…
Reference in New Issue
Block a user