mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-03-23 00:19:52 +01:00
Merge pull request #76 from thotypous/soapy-select-antenna
Support selecting antenna for SoapySDR source
This commit is contained in:
commit
0e7a8301f7
@ -1,3 +1,4 @@
|
|||||||
|
#include <SoapySDR/Constants.h>
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
#include <spdlog/spdlog.h>
|
#include <spdlog/spdlog.h>
|
||||||
#include <module.h>
|
#include <module.h>
|
||||||
@ -152,6 +153,12 @@ private:
|
|||||||
|
|
||||||
SoapySDR::Device* dev = SoapySDR::Device::make(devArgs);
|
SoapySDR::Device* dev = SoapySDR::Device::make(devArgs);
|
||||||
|
|
||||||
|
antennaList = dev->listAntennas(SOAPY_SDR_RX, channelId);
|
||||||
|
txtAntennaList = "";
|
||||||
|
for (const std::string & ant : antennaList) {
|
||||||
|
txtAntennaList += ant + '\0';
|
||||||
|
}
|
||||||
|
|
||||||
gainList = dev->listGains(SOAPY_SDR_RX, channelId);
|
gainList = dev->listGains(SOAPY_SDR_RX, channelId);
|
||||||
delete[] uiGains;
|
delete[] uiGains;
|
||||||
uiGains = new float[gainList.size()];
|
uiGains = new float[gainList.size()];
|
||||||
@ -201,6 +208,11 @@ private:
|
|||||||
|
|
||||||
config.aquire();
|
config.aquire();
|
||||||
if (config.conf["devices"].contains(name)) {
|
if (config.conf["devices"].contains(name)) {
|
||||||
|
if(config.conf["devices"][name].contains("antenna")) {
|
||||||
|
uiAntennaId = config.conf["devices"][name]["antenna"];
|
||||||
|
} else {
|
||||||
|
uiAntennaId = 0;
|
||||||
|
}
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (auto gain : gainList) {
|
for (auto gain : gainList) {
|
||||||
if (config.conf["devices"][name]["gains"].contains(gain)) {
|
if (config.conf["devices"][name]["gains"].contains(gain)) {
|
||||||
@ -230,6 +242,7 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
uiAntennaId = 0;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (auto gain : gainList) {
|
for (auto gain : gainList) {
|
||||||
uiGains[i] = gainRanges[i].minimum();
|
uiGains[i] = gainRanges[i].minimum();
|
||||||
@ -249,6 +262,7 @@ private:
|
|||||||
void saveCurrent() {
|
void saveCurrent() {
|
||||||
json conf;
|
json conf;
|
||||||
conf["sampleRate"] = sampleRate;
|
conf["sampleRate"] = sampleRate;
|
||||||
|
conf["antenna"] = uiAntennaId;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (auto gain : gainList) {
|
for (auto gain : gainList) {
|
||||||
conf["gains"][gain] = uiGains[i];
|
conf["gains"][gain] = uiGains[i];
|
||||||
@ -284,6 +298,8 @@ private:
|
|||||||
|
|
||||||
_this->dev->setSampleRate(SOAPY_SDR_RX, _this->channelId, _this->sampleRate);
|
_this->dev->setSampleRate(SOAPY_SDR_RX, _this->channelId, _this->sampleRate);
|
||||||
|
|
||||||
|
_this->dev->setAntenna(SOAPY_SDR_RX, _this->channelId, _this->antennaList[_this->uiAntennaId]);
|
||||||
|
|
||||||
if(_this->bandwidthList.size() > 2) {
|
if(_this->bandwidthList.size() > 2) {
|
||||||
if(_this->bandwidthList[_this->uiBandwidthId] == -1)
|
if(_this->bandwidthList[_this->uiBandwidthId] == -1)
|
||||||
_this->dev->setBandwidth(SOAPY_SDR_RX, _this->channelId, _this->selectBwBySr(_this->sampleRates[_this->srId]));
|
_this->dev->setBandwidth(SOAPY_SDR_RX, _this->channelId, _this->selectBwBySr(_this->sampleRates[_this->srId]));
|
||||||
@ -368,6 +384,15 @@ private:
|
|||||||
|
|
||||||
if (_this->running) { style::endDisabled(); }
|
if (_this->running) { style::endDisabled(); }
|
||||||
|
|
||||||
|
ImGui::Text("Antenna");
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX());
|
||||||
|
if (ImGui::Combo(CONCAT("##_antenna_select_", _this->name), &_this->uiAntennaId, _this->txtAntennaList.c_str())) {
|
||||||
|
if (_this->running)
|
||||||
|
_this->dev->setAntenna(SOAPY_SDR_RX, _this->channelId, _this->antennaList[_this->uiAntennaId]);
|
||||||
|
_this->saveCurrent();
|
||||||
|
}
|
||||||
|
|
||||||
float gainNameLen = 0;
|
float gainNameLen = 0;
|
||||||
float len;
|
float len;
|
||||||
for (auto gain : _this->gainList) {
|
for (auto gain : _this->gainList) {
|
||||||
@ -469,6 +494,9 @@ private:
|
|||||||
float* uiGains;
|
float* uiGains;
|
||||||
int channelCount = 1;
|
int channelCount = 1;
|
||||||
int channelId = 0;
|
int channelId = 0;
|
||||||
|
int uiAntennaId = 0;
|
||||||
|
std::vector<std::string> antennaList;
|
||||||
|
std::string txtAntennaList;
|
||||||
std::vector<std::string> gainList;
|
std::vector<std::string> gainList;
|
||||||
std::vector<SoapySDR::Range> gainRanges;
|
std::vector<SoapySDR::Range> gainRanges;
|
||||||
int uiBandwidthId = 0;
|
int uiBandwidthId = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user