mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-02-03 09:44:01 -05:00
BladeRF2 output: fixed gain handling
This commit is contained in:
parent
d75a576f69
commit
5566dc6a7e
@ -48,19 +48,6 @@ BladeRF2Output::BladeRF2Output(DeviceSinkAPI *deviceAPI) :
|
||||
m_running(false)
|
||||
{
|
||||
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()
|
||||
@ -948,18 +935,6 @@ void BladeRF2Output::webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& resp
|
||||
response.getBladeRf2OutputReport()->getSampleRateRange()->setMin(min);
|
||||
response.getBladeRf2OutputReport()->getSampleRateRange()->setMax(max);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,12 +97,6 @@ public:
|
||||
{}
|
||||
};
|
||||
|
||||
struct GainMode
|
||||
{
|
||||
QString m_name;
|
||||
int m_value;
|
||||
};
|
||||
|
||||
BladeRF2Output(DeviceSinkAPI *deviceAPI);
|
||||
virtual ~BladeRF2Output();
|
||||
virtual void destroy();
|
||||
@ -126,7 +120,6 @@ 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 std::vector<GainMode>& getGainModes() { return m_gainModes; }
|
||||
|
||||
virtual bool handleMessage(const Message& message);
|
||||
|
||||
@ -170,7 +163,6 @@ private:
|
||||
QString m_deviceDescription;
|
||||
DeviceBladeRF2Shared m_deviceShared;
|
||||
bool m_running;
|
||||
std::vector<GainMode> m_gainModes;
|
||||
};
|
||||
|
||||
#endif /* PLUGINS_SAMPLESINK_BLADERF2OUTPUT_BLADERF2OUTPUT_H_ */
|
||||
|
@ -46,33 +46,26 @@ BladeRF2OutputGui::BladeRF2OutputGui(DeviceUISet *deviceUISet, QWidget* parent)
|
||||
ui->setupUi(this);
|
||||
|
||||
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->setValueRange(7, f_min/1000, f_max/1000);
|
||||
|
||||
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->setValueRange(8, min, max);
|
||||
|
||||
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->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);
|
||||
ui->gain->setMinimum(min);
|
||||
ui->gain->setMaximum(max);
|
||||
ui->gain->setPageStep(step);
|
||||
ui->gain->setSingleStep(step);
|
||||
qDebug("BladeRF2OutputGui::BladeRF2OutputGui: getGlobalGainRange: [%d,%d] step: %d", min, max, step);
|
||||
ui->gain->setMinimum((min-max)/1000);
|
||||
ui->gain->setMaximum(0);
|
||||
ui->gain->setPageStep(1);
|
||||
ui->gain->setSingleStep(1);
|
||||
|
||||
ui->label_decim->setText(QString::fromUtf8("I\u2191"));
|
||||
|
||||
@ -152,10 +145,10 @@ bool BladeRF2OutputGui::handleMessage(const Message& message)
|
||||
blockApplySettings(true);
|
||||
int min, max, step;
|
||||
m_sampleSink->getGlobalGainRange(min, max, step);
|
||||
ui->gain->setMinimum(min);
|
||||
ui->gain->setMaximum(max);
|
||||
ui->gain->setPageStep(step);
|
||||
ui->gain->setSingleStep(step);
|
||||
ui->gain->setMinimum((min-max)/1000);
|
||||
ui->gain->setMaximum(0);
|
||||
ui->gain->setPageStep(1);
|
||||
ui->gain->setSingleStep(1);
|
||||
displaySettings();
|
||||
blockApplySettings(false);
|
||||
|
||||
@ -164,10 +157,10 @@ bool BladeRF2OutputGui::handleMessage(const Message& message)
|
||||
else if (BladeRF2Output::MsgReportGainRange::match(message))
|
||||
{
|
||||
const BladeRF2Output::MsgReportGainRange& cfg = (BladeRF2Output::MsgReportGainRange&) message;
|
||||
ui->gain->setMinimum(cfg.getMin());
|
||||
ui->gain->setMaximum(cfg.getMax());
|
||||
ui->gain->setSingleStep(cfg.getStep());
|
||||
ui->gain->setPageStep(cfg.getStep());
|
||||
ui->gain->setMinimum((cfg.getMin()-cfg.getMax())/1000);
|
||||
ui->gain->setMaximum(0);
|
||||
ui->gain->setSingleStep(1);
|
||||
ui->gain->setPageStep(1);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -234,12 +227,6 @@ void BladeRF2OutputGui::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);
|
||||
}
|
||||
|
||||
@ -281,31 +268,6 @@ void BladeRF2OutputGui::on_interp_currentIndexChanged(int index)
|
||||
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)
|
||||
{
|
||||
ui->gainText->setText(tr("%1 dB").arg(value));
|
||||
|
@ -78,7 +78,6 @@ private slots:
|
||||
void on_sampleRate_changed(quint64 value);
|
||||
void on_bandwidth_changed(quint64 value);
|
||||
void on_interp_currentIndexChanged(int index);
|
||||
void on_gainMode_currentIndexChanged(int index);
|
||||
void on_gain_valueChanged(int value);
|
||||
void on_startStop_toggled(bool checked);
|
||||
void updateHardware();
|
||||
|
@ -372,11 +372,11 @@
|
||||
</layout>
|
||||
</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">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<item row="0" column="2">
|
||||
<item row="0" column="1">
|
||||
<widget class="QSlider" name="gain">
|
||||
<property name="toolTip">
|
||||
<string>Gain value</string>
|
||||
@ -386,13 +386,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</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">
|
||||
<widget class="QLabel" name="gainLabel">
|
||||
<property name="text">
|
||||
@ -400,7 +393,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="gainText">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
|
@ -31,7 +31,7 @@ void BladeRF2OutputSettings::resetToDefaults()
|
||||
m_devSampleRate = 3072000;
|
||||
m_bandwidth = 1500000;
|
||||
m_gainMode = 0;
|
||||
m_globalGain = 0;
|
||||
m_globalGain = -20;
|
||||
m_biasTee = false;
|
||||
m_log2Interp = 0;
|
||||
}
|
||||
|
@ -1377,12 +1377,6 @@ margin-bottom: 20px;
|
||||
},
|
||||
"globalGainRange" : {
|
||||
"$ref" : "#/definitions/Range"
|
||||
},
|
||||
"gainModes" : {
|
||||
"type" : "array",
|
||||
"items" : {
|
||||
"$ref" : "#/definitions/NamedEnum"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description" : "BladeRF2"
|
||||
@ -23231,7 +23225,7 @@ except ApiException as e:
|
||||
</div>
|
||||
<div id="generator">
|
||||
<div class="content">
|
||||
Generated 2018-09-29T05:36:53.044+02:00
|
||||
Generated 2018-09-29T10:10:59.386+02:00
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -71,7 +71,3 @@ BladeRF2OutputReport:
|
||||
$ref: "/doc/swagger/include/Structs.yaml#/Range"
|
||||
globalGainRange:
|
||||
$ref: "/doc/swagger/include/Structs.yaml#/Range"
|
||||
gainModes:
|
||||
type: array
|
||||
items:
|
||||
$ref: "/doc/swagger/include/Structs.yaml#/NamedEnum"
|
||||
|
@ -71,7 +71,3 @@ BladeRF2OutputReport:
|
||||
$ref: "http://localhost:8081/api/swagger/include/Structs.yaml#/Range"
|
||||
globalGainRange:
|
||||
$ref: "http://localhost:8081/api/swagger/include/Structs.yaml#/Range"
|
||||
gainModes:
|
||||
type: array
|
||||
items:
|
||||
$ref: "http://localhost:8081/api/swagger/include/Structs.yaml#/NamedEnum"
|
||||
|
@ -1377,12 +1377,6 @@ margin-bottom: 20px;
|
||||
},
|
||||
"globalGainRange" : {
|
||||
"$ref" : "#/definitions/Range"
|
||||
},
|
||||
"gainModes" : {
|
||||
"type" : "array",
|
||||
"items" : {
|
||||
"$ref" : "#/definitions/NamedEnum"
|
||||
}
|
||||
}
|
||||
},
|
||||
"description" : "BladeRF2"
|
||||
@ -23231,7 +23225,7 @@ except ApiException as e:
|
||||
</div>
|
||||
<div id="generator">
|
||||
<div class="content">
|
||||
Generated 2018-09-29T05:36:53.044+02:00
|
||||
Generated 2018-09-29T10:10:59.386+02:00
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -36,8 +36,6 @@ SWGBladeRF2OutputReport::SWGBladeRF2OutputReport() {
|
||||
m_bandwidth_range_isSet = false;
|
||||
global_gain_range = nullptr;
|
||||
m_global_gain_range_isSet = false;
|
||||
gain_modes = nullptr;
|
||||
m_gain_modes_isSet = false;
|
||||
}
|
||||
|
||||
SWGBladeRF2OutputReport::~SWGBladeRF2OutputReport() {
|
||||
@ -54,8 +52,6 @@ SWGBladeRF2OutputReport::init() {
|
||||
m_bandwidth_range_isSet = false;
|
||||
global_gain_range = new SWGRange();
|
||||
m_global_gain_range_isSet = false;
|
||||
gain_modes = new QList<SWGNamedEnum*>();
|
||||
m_gain_modes_isSet = false;
|
||||
}
|
||||
|
||||
void
|
||||
@ -72,13 +68,6 @@ SWGBladeRF2OutputReport::cleanup() {
|
||||
if(global_gain_range != nullptr) {
|
||||
delete global_gain_range;
|
||||
}
|
||||
if(gain_modes != nullptr) {
|
||||
auto arr = gain_modes;
|
||||
for(auto o: *arr) {
|
||||
delete o;
|
||||
}
|
||||
delete gain_modes;
|
||||
}
|
||||
}
|
||||
|
||||
SWGBladeRF2OutputReport*
|
||||
@ -100,8 +89,6 @@ SWGBladeRF2OutputReport::fromJsonObject(QJsonObject &pJson) {
|
||||
|
||||
::SWGSDRangel::setValue(&global_gain_range, pJson["globalGainRange"], "SWGRange", "SWGRange");
|
||||
|
||||
|
||||
::SWGSDRangel::setValue(&gain_modes, pJson["gainModes"], "QList", "SWGNamedEnum");
|
||||
}
|
||||
|
||||
QString
|
||||
@ -130,9 +117,6 @@ SWGBladeRF2OutputReport::asJsonObject() {
|
||||
if((global_gain_range != nullptr) && (global_gain_range->isSet())){
|
||||
toJsonValue(QString("globalGainRange"), global_gain_range, obj, QString("SWGRange"));
|
||||
}
|
||||
if(gain_modes->size() > 0){
|
||||
toJsonArray((QList<void*>*)gain_modes, obj, "gainModes", "SWGNamedEnum");
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
@ -177,16 +161,6 @@ SWGBladeRF2OutputReport::setGlobalGainRange(SWGRange* global_gain_range) {
|
||||
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
|
||||
SWGBladeRF2OutputReport::isSet(){
|
||||
@ -196,7 +170,6 @@ SWGBladeRF2OutputReport::isSet(){
|
||||
if(sample_rate_range != nullptr && sample_rate_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(gain_modes->size() > 0){ isObjectUpdated = true; break;}
|
||||
}while(false);
|
||||
return isObjectUpdated;
|
||||
}
|
||||
|
@ -23,9 +23,7 @@
|
||||
|
||||
|
||||
#include "SWGFrequencyRange.h"
|
||||
#include "SWGNamedEnum.h"
|
||||
#include "SWGRange.h"
|
||||
#include <QList>
|
||||
|
||||
#include "SWGObject.h"
|
||||
#include "export.h"
|
||||
@ -57,9 +55,6 @@ public:
|
||||
SWGRange* getGlobalGainRange();
|
||||
void setGlobalGainRange(SWGRange* global_gain_range);
|
||||
|
||||
QList<SWGNamedEnum*>* getGainModes();
|
||||
void setGainModes(QList<SWGNamedEnum*>* gain_modes);
|
||||
|
||||
|
||||
virtual bool isSet() override;
|
||||
|
||||
@ -76,9 +71,6 @@ private:
|
||||
SWGRange* global_gain_range;
|
||||
bool m_global_gain_range_isSet;
|
||||
|
||||
QList<SWGNamedEnum*>* gain_modes;
|
||||
bool m_gain_modes_isSet;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user