1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2025-09-04 14:17:50 -04:00

BladeRF2 output: fixed gain handling

This commit is contained in:
f4exb 2018-09-29 10:53:44 +02:00
parent d75a576f69
commit 5566dc6a7e
12 changed files with 22 additions and 156 deletions

View File

@ -48,19 +48,6 @@ BladeRF2Output::BladeRF2Output(DeviceSinkAPI *deviceAPI) :
m_running(false) m_running(false)
{ {
openDevice(); 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});
}
}
}
} }
BladeRF2Output::~BladeRF2Output() BladeRF2Output::~BladeRF2Output()
@ -948,18 +935,6 @@ void BladeRF2Output::webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& resp
response.getBladeRf2OutputReport()->getSampleRateRange()->setMin(min); response.getBladeRf2OutputReport()->getSampleRateRange()->setMin(min);
response.getBladeRf2OutputReport()->getSampleRateRange()->setMax(max); response.getBladeRf2OutputReport()->getSampleRateRange()->setMax(max);
response.getBladeRf2OutputReport()->getSampleRateRange()->setStep(step); response.getBladeRf2OutputReport()->getSampleRateRange()->setStep(step);
response.getBladeRf2OutputReport()->setGainModes(new QList<SWGSDRangel::SWGNamedEnum*>);
const std::vector<GainMode>& modes = getGainModes();
std::vector<GainMode>::const_iterator it = modes.begin();
for (; it != modes.end(); ++it)
{
response.getBladeRf2OutputReport()->getGainModes()->append(new SWGSDRangel::SWGNamedEnum);
response.getBladeRf2OutputReport()->getGainModes()->back()->setName(new QString(it->m_name));
response.getBladeRf2OutputReport()->getGainModes()->back()->setValue(it->m_value);
}
} }
} }

View File

@ -97,12 +97,6 @@ public:
{} {}
}; };
struct GainMode
{
QString m_name;
int m_value;
};
BladeRF2Output(DeviceSinkAPI *deviceAPI); BladeRF2Output(DeviceSinkAPI *deviceAPI);
virtual ~BladeRF2Output(); virtual ~BladeRF2Output();
virtual void destroy(); virtual void destroy();
@ -126,7 +120,6 @@ public:
void getSampleRateRange(int& min, int& max, int& step); void getSampleRateRange(int& min, int& max, int& step);
void getBandwidthRange(int& min, int& max, int& step); void getBandwidthRange(int& min, int& max, int& step);
void getGlobalGainRange(int& min, int& max, int& step); void getGlobalGainRange(int& min, int& max, int& step);
const std::vector<GainMode>& getGainModes() { return m_gainModes; }
virtual bool handleMessage(const Message& message); virtual bool handleMessage(const Message& message);
@ -170,7 +163,6 @@ private:
QString m_deviceDescription; QString m_deviceDescription;
DeviceBladeRF2Shared m_deviceShared; DeviceBladeRF2Shared m_deviceShared;
bool m_running; bool m_running;
std::vector<GainMode> m_gainModes;
}; };
#endif /* PLUGINS_SAMPLESINK_BLADERF2OUTPUT_BLADERF2OUTPUT_H_ */ #endif /* PLUGINS_SAMPLESINK_BLADERF2OUTPUT_BLADERF2OUTPUT_H_ */

View File

@ -46,33 +46,26 @@ BladeRF2OutputGui::BladeRF2OutputGui(DeviceUISet *deviceUISet, QWidget* parent)
ui->setupUi(this); ui->setupUi(this);
m_sampleSink->getFrequencyRange(f_min, f_max, step); m_sampleSink->getFrequencyRange(f_min, f_max, step);
qDebug("BladeRF2OutputGui::BladeRF2OutputGui: getFrequencyRange: [%lu,%lu] step: %d", f_min, f_max, step);
ui->centerFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold)); ui->centerFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));
ui->centerFrequency->setValueRange(7, f_min/1000, f_max/1000); ui->centerFrequency->setValueRange(7, f_min/1000, f_max/1000);
m_sampleSink->getSampleRateRange(min, max, step); m_sampleSink->getSampleRateRange(min, max, step);
qDebug("BladeRF2OutputGui::BladeRF2OutputGui: getSampleRateRange: [%d,%d] step: %d", min, max, step);
ui->sampleRate->setColorMapper(ColorMapper(ColorMapper::GrayGreenYellow)); ui->sampleRate->setColorMapper(ColorMapper(ColorMapper::GrayGreenYellow));
ui->sampleRate->setValueRange(8, min, max); ui->sampleRate->setValueRange(8, min, max);
m_sampleSink->getBandwidthRange(min, max, step); m_sampleSink->getBandwidthRange(min, max, step);
qDebug("BladeRF2OutputGui::BladeRF2OutputGui: getBandwidthRange: [%d,%d] step: %d", min, max, step);
ui->bandwidth->setColorMapper(ColorMapper(ColorMapper::GrayYellow)); ui->bandwidth->setColorMapper(ColorMapper(ColorMapper::GrayYellow));
ui->bandwidth->setValueRange(5, min/1000, max/1000); ui->bandwidth->setValueRange(5, min/1000, max/1000);
const std::vector<BladeRF2Output::GainMode>& modes = m_sampleSink->getGainModes();
std::vector<BladeRF2Output::GainMode>::const_iterator it = modes.begin();
ui->gainMode->blockSignals(true);
for (; it != modes.end(); ++it) {
ui->gainMode->addItem(it->m_name);
}
ui->gainMode->blockSignals(false);
m_sampleSink->getGlobalGainRange(min, max, step); m_sampleSink->getGlobalGainRange(min, max, step);
ui->gain->setMinimum(min); qDebug("BladeRF2OutputGui::BladeRF2OutputGui: getGlobalGainRange: [%d,%d] step: %d", min, max, step);
ui->gain->setMaximum(max); ui->gain->setMinimum((min-max)/1000);
ui->gain->setPageStep(step); ui->gain->setMaximum(0);
ui->gain->setSingleStep(step); ui->gain->setPageStep(1);
ui->gain->setSingleStep(1);
ui->label_decim->setText(QString::fromUtf8("I\u2191")); ui->label_decim->setText(QString::fromUtf8("I\u2191"));
@ -152,10 +145,10 @@ bool BladeRF2OutputGui::handleMessage(const Message& message)
blockApplySettings(true); blockApplySettings(true);
int min, max, step; int min, max, step;
m_sampleSink->getGlobalGainRange(min, max, step); m_sampleSink->getGlobalGainRange(min, max, step);
ui->gain->setMinimum(min); ui->gain->setMinimum((min-max)/1000);
ui->gain->setMaximum(max); ui->gain->setMaximum(0);
ui->gain->setPageStep(step); ui->gain->setPageStep(1);
ui->gain->setSingleStep(step); ui->gain->setSingleStep(1);
displaySettings(); displaySettings();
blockApplySettings(false); blockApplySettings(false);
@ -164,10 +157,10 @@ bool BladeRF2OutputGui::handleMessage(const Message& message)
else if (BladeRF2Output::MsgReportGainRange::match(message)) else if (BladeRF2Output::MsgReportGainRange::match(message))
{ {
const BladeRF2Output::MsgReportGainRange& cfg = (BladeRF2Output::MsgReportGainRange&) message; const BladeRF2Output::MsgReportGainRange& cfg = (BladeRF2Output::MsgReportGainRange&) message;
ui->gain->setMinimum(cfg.getMin()); ui->gain->setMinimum((cfg.getMin()-cfg.getMax())/1000);
ui->gain->setMaximum(cfg.getMax()); ui->gain->setMaximum(0);
ui->gain->setSingleStep(cfg.getStep()); ui->gain->setSingleStep(1);
ui->gain->setPageStep(cfg.getStep()); ui->gain->setPageStep(1);
return true; return true;
} }
@ -234,12 +227,6 @@ void BladeRF2OutputGui::displaySettings()
ui->gainText->setText(tr("%1 dB").arg(m_settings.m_globalGain)); ui->gainText->setText(tr("%1 dB").arg(m_settings.m_globalGain));
ui->gain->setValue(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); blockApplySettings(false);
} }
@ -281,31 +268,6 @@ void BladeRF2OutputGui::on_interp_currentIndexChanged(int index)
sendSettings(); sendSettings();
} }
void BladeRF2OutputGui::on_gainMode_currentIndexChanged(int index)
{
const std::vector<BladeRF2Output::GainMode>& modes = m_sampleSink->getGainModes();
unsigned int uindex = index < 0 ? 0 : (unsigned int) index;
if (uindex < modes.size())
{
BladeRF2Output::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();
}
}
void BladeRF2OutputGui::on_gain_valueChanged(int value) void BladeRF2OutputGui::on_gain_valueChanged(int value)
{ {
ui->gainText->setText(tr("%1 dB").arg(value)); ui->gainText->setText(tr("%1 dB").arg(value));

View File

@ -78,7 +78,6 @@ private slots:
void on_sampleRate_changed(quint64 value); void on_sampleRate_changed(quint64 value);
void on_bandwidth_changed(quint64 value); void on_bandwidth_changed(quint64 value);
void on_interp_currentIndexChanged(int index); void on_interp_currentIndexChanged(int index);
void on_gainMode_currentIndexChanged(int index);
void on_gain_valueChanged(int value); void on_gain_valueChanged(int value);
void on_startStop_toggled(bool checked); void on_startStop_toggled(bool checked);
void updateHardware(); void updateHardware();

View File

@ -372,11 +372,11 @@
</layout> </layout>
</item> </item>
<item> <item>
<layout class="QGridLayout" name="gridLayout_decim" columnstretch="0,0,0,0"> <layout class="QGridLayout" name="gridLayout_gain" columnstretch="0,0,0">
<property name="spacing"> <property name="spacing">
<number>3</number> <number>3</number>
</property> </property>
<item row="0" column="2"> <item row="0" column="1">
<widget class="QSlider" name="gain"> <widget class="QSlider" name="gain">
<property name="toolTip"> <property name="toolTip">
<string>Gain value</string> <string>Gain value</string>
@ -386,13 +386,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1">
<widget class="QComboBox" name="gainMode">
<property name="toolTip">
<string>Gain mode</string>
</property>
</widget>
</item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="gainLabel"> <widget class="QLabel" name="gainLabel">
<property name="text"> <property name="text">
@ -400,7 +393,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="3"> <item row="0" column="2">
<widget class="QLabel" name="gainText"> <widget class="QLabel" name="gainText">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>

View File

@ -31,7 +31,7 @@ void BladeRF2OutputSettings::resetToDefaults()
m_devSampleRate = 3072000; m_devSampleRate = 3072000;
m_bandwidth = 1500000; m_bandwidth = 1500000;
m_gainMode = 0; m_gainMode = 0;
m_globalGain = 0; m_globalGain = -20;
m_biasTee = false; m_biasTee = false;
m_log2Interp = 0; m_log2Interp = 0;
} }

View File

@ -1377,12 +1377,6 @@ margin-bottom: 20px;
}, },
"globalGainRange" : { "globalGainRange" : {
"$ref" : "#/definitions/Range" "$ref" : "#/definitions/Range"
},
"gainModes" : {
"type" : "array",
"items" : {
"$ref" : "#/definitions/NamedEnum"
}
} }
}, },
"description" : "BladeRF2" "description" : "BladeRF2"
@ -23231,7 +23225,7 @@ except ApiException as e:
</div> </div>
<div id="generator"> <div id="generator">
<div class="content"> <div class="content">
Generated 2018-09-29T05:36:53.044+02:00 Generated 2018-09-29T10:10:59.386+02:00
</div> </div>
</div> </div>
</div> </div>

View File

@ -71,7 +71,3 @@ BladeRF2OutputReport:
$ref: "/doc/swagger/include/Structs.yaml#/Range" $ref: "/doc/swagger/include/Structs.yaml#/Range"
globalGainRange: globalGainRange:
$ref: "/doc/swagger/include/Structs.yaml#/Range" $ref: "/doc/swagger/include/Structs.yaml#/Range"
gainModes:
type: array
items:
$ref: "/doc/swagger/include/Structs.yaml#/NamedEnum"

View File

@ -71,7 +71,3 @@ BladeRF2OutputReport:
$ref: "http://localhost:8081/api/swagger/include/Structs.yaml#/Range" $ref: "http://localhost:8081/api/swagger/include/Structs.yaml#/Range"
globalGainRange: globalGainRange:
$ref: "http://localhost:8081/api/swagger/include/Structs.yaml#/Range" $ref: "http://localhost:8081/api/swagger/include/Structs.yaml#/Range"
gainModes:
type: array
items:
$ref: "http://localhost:8081/api/swagger/include/Structs.yaml#/NamedEnum"

View File

@ -1377,12 +1377,6 @@ margin-bottom: 20px;
}, },
"globalGainRange" : { "globalGainRange" : {
"$ref" : "#/definitions/Range" "$ref" : "#/definitions/Range"
},
"gainModes" : {
"type" : "array",
"items" : {
"$ref" : "#/definitions/NamedEnum"
}
} }
}, },
"description" : "BladeRF2" "description" : "BladeRF2"
@ -23231,7 +23225,7 @@ except ApiException as e:
</div> </div>
<div id="generator"> <div id="generator">
<div class="content"> <div class="content">
Generated 2018-09-29T05:36:53.044+02:00 Generated 2018-09-29T10:10:59.386+02:00
</div> </div>
</div> </div>
</div> </div>

View File

@ -36,8 +36,6 @@ SWGBladeRF2OutputReport::SWGBladeRF2OutputReport() {
m_bandwidth_range_isSet = false; m_bandwidth_range_isSet = false;
global_gain_range = nullptr; global_gain_range = nullptr;
m_global_gain_range_isSet = false; m_global_gain_range_isSet = false;
gain_modes = nullptr;
m_gain_modes_isSet = false;
} }
SWGBladeRF2OutputReport::~SWGBladeRF2OutputReport() { SWGBladeRF2OutputReport::~SWGBladeRF2OutputReport() {
@ -54,8 +52,6 @@ SWGBladeRF2OutputReport::init() {
m_bandwidth_range_isSet = false; m_bandwidth_range_isSet = false;
global_gain_range = new SWGRange(); global_gain_range = new SWGRange();
m_global_gain_range_isSet = false; m_global_gain_range_isSet = false;
gain_modes = new QList<SWGNamedEnum*>();
m_gain_modes_isSet = false;
} }
void void
@ -72,13 +68,6 @@ SWGBladeRF2OutputReport::cleanup() {
if(global_gain_range != nullptr) { if(global_gain_range != nullptr) {
delete global_gain_range; delete global_gain_range;
} }
if(gain_modes != nullptr) {
auto arr = gain_modes;
for(auto o: *arr) {
delete o;
}
delete gain_modes;
}
} }
SWGBladeRF2OutputReport* SWGBladeRF2OutputReport*
@ -100,8 +89,6 @@ SWGBladeRF2OutputReport::fromJsonObject(QJsonObject &pJson) {
::SWGSDRangel::setValue(&global_gain_range, pJson["globalGainRange"], "SWGRange", "SWGRange"); ::SWGSDRangel::setValue(&global_gain_range, pJson["globalGainRange"], "SWGRange", "SWGRange");
::SWGSDRangel::setValue(&gain_modes, pJson["gainModes"], "QList", "SWGNamedEnum");
} }
QString QString
@ -130,9 +117,6 @@ SWGBladeRF2OutputReport::asJsonObject() {
if((global_gain_range != nullptr) && (global_gain_range->isSet())){ if((global_gain_range != nullptr) && (global_gain_range->isSet())){
toJsonValue(QString("globalGainRange"), global_gain_range, obj, QString("SWGRange")); toJsonValue(QString("globalGainRange"), global_gain_range, obj, QString("SWGRange"));
} }
if(gain_modes->size() > 0){
toJsonArray((QList<void*>*)gain_modes, obj, "gainModes", "SWGNamedEnum");
}
return obj; return obj;
} }
@ -177,16 +161,6 @@ SWGBladeRF2OutputReport::setGlobalGainRange(SWGRange* global_gain_range) {
this->m_global_gain_range_isSet = true; this->m_global_gain_range_isSet = true;
} }
QList<SWGNamedEnum*>*
SWGBladeRF2OutputReport::getGainModes() {
return gain_modes;
}
void
SWGBladeRF2OutputReport::setGainModes(QList<SWGNamedEnum*>* gain_modes) {
this->gain_modes = gain_modes;
this->m_gain_modes_isSet = true;
}
bool bool
SWGBladeRF2OutputReport::isSet(){ SWGBladeRF2OutputReport::isSet(){
@ -196,7 +170,6 @@ SWGBladeRF2OutputReport::isSet(){
if(sample_rate_range != nullptr && sample_rate_range->isSet()){ isObjectUpdated = true; break;} if(sample_rate_range != nullptr && sample_rate_range->isSet()){ isObjectUpdated = true; break;}
if(bandwidth_range != nullptr && bandwidth_range->isSet()){ isObjectUpdated = true; break;} if(bandwidth_range != nullptr && bandwidth_range->isSet()){ isObjectUpdated = true; break;}
if(global_gain_range != nullptr && global_gain_range->isSet()){ isObjectUpdated = true; break;} if(global_gain_range != nullptr && global_gain_range->isSet()){ isObjectUpdated = true; break;}
if(gain_modes->size() > 0){ isObjectUpdated = true; break;}
}while(false); }while(false);
return isObjectUpdated; return isObjectUpdated;
} }

View File

@ -23,9 +23,7 @@
#include "SWGFrequencyRange.h" #include "SWGFrequencyRange.h"
#include "SWGNamedEnum.h"
#include "SWGRange.h" #include "SWGRange.h"
#include <QList>
#include "SWGObject.h" #include "SWGObject.h"
#include "export.h" #include "export.h"
@ -57,9 +55,6 @@ public:
SWGRange* getGlobalGainRange(); SWGRange* getGlobalGainRange();
void setGlobalGainRange(SWGRange* global_gain_range); void setGlobalGainRange(SWGRange* global_gain_range);
QList<SWGNamedEnum*>* getGainModes();
void setGainModes(QList<SWGNamedEnum*>* gain_modes);
virtual bool isSet() override; virtual bool isSet() override;
@ -76,9 +71,6 @@ private:
SWGRange* global_gain_range; SWGRange* global_gain_range;
bool m_global_gain_range_isSet; bool m_global_gain_range_isSet;
QList<SWGNamedEnum*>* gain_modes;
bool m_gain_modes_isSet;
}; };
} }