mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-06-27 21:07:50 +02:00
Formatted the entire codebase and added a CI check for formatting
This commit is contained in:
@ -12,7 +12,7 @@
|
||||
|
||||
#define CONCAT(a, b) ((std::string(a) + b).c_str())
|
||||
|
||||
SDRPP_MOD_INFO {
|
||||
SDRPP_MOD_INFO{
|
||||
/* Name: */ "sdrplay_source",
|
||||
/* Description: */ "SDRplay source module for SDR++",
|
||||
/* Author: */ "Ryzerth",
|
||||
@ -103,13 +103,13 @@ struct ifMode_t {
|
||||
};
|
||||
|
||||
ifMode_t ifModes[] = {
|
||||
{ sdrplay_api_IF_Zero, sdrplay_api_BW_1_536, 2000000, 2000000},
|
||||
{ sdrplay_api_IF_2_048, sdrplay_api_BW_1_536, 8000000, 2000000},
|
||||
{ sdrplay_api_IF_2_048, sdrplay_api_BW_5_000, 8000000, 2000000},
|
||||
{ sdrplay_api_IF_1_620, sdrplay_api_BW_1_536, 6000000, 2000000},
|
||||
{ sdrplay_api_IF_0_450, sdrplay_api_BW_0_600, 2000000, 1000000},
|
||||
{ sdrplay_api_IF_0_450, sdrplay_api_BW_0_300, 2000000, 500000},
|
||||
{ sdrplay_api_IF_0_450, sdrplay_api_BW_0_200, 2000000, 500000},
|
||||
{ sdrplay_api_IF_Zero, sdrplay_api_BW_1_536, 2000000, 2000000 },
|
||||
{ sdrplay_api_IF_2_048, sdrplay_api_BW_1_536, 8000000, 2000000 },
|
||||
{ sdrplay_api_IF_2_048, sdrplay_api_BW_5_000, 8000000, 2000000 },
|
||||
{ sdrplay_api_IF_1_620, sdrplay_api_BW_1_536, 6000000, 2000000 },
|
||||
{ sdrplay_api_IF_0_450, sdrplay_api_BW_0_600, 2000000, 1000000 },
|
||||
{ sdrplay_api_IF_0_450, sdrplay_api_BW_0_300, 2000000, 500000 },
|
||||
{ sdrplay_api_IF_0_450, sdrplay_api_BW_0_200, 2000000, 500000 },
|
||||
};
|
||||
|
||||
const char* ifModeTxt =
|
||||
@ -147,7 +147,7 @@ public:
|
||||
|
||||
handler.ctx = this;
|
||||
handler.selectHandler = menuSelected;
|
||||
handler.deselectHandler = menuDeselected;
|
||||
handler.deselectHandler = menuDeselected;
|
||||
handler.menuHandler = menuHandler;
|
||||
handler.startHandler = start;
|
||||
handler.stopHandler = stop;
|
||||
@ -210,24 +210,36 @@ public:
|
||||
devList.push_back(devArr[i]);
|
||||
std::string name = "";
|
||||
switch (devArr[i].hwVer) {
|
||||
case SDRPLAY_RSP1_ID:
|
||||
name = "RSP1 ("; name += devArr[i].SerNo; name += ')';
|
||||
break;
|
||||
case SDRPLAY_RSP1A_ID:
|
||||
name = "RSP1A ("; name += devArr[i].SerNo; name += ')';
|
||||
break;
|
||||
case SDRPLAY_RSP2_ID:
|
||||
name = "RSP2 ("; name += devArr[i].SerNo; name += ')';
|
||||
break;
|
||||
case SDRPLAY_RSPduo_ID:
|
||||
name = "RSPduo ("; name += devArr[i].SerNo; name += ')';
|
||||
break;
|
||||
case SDRPLAY_RSPdx_ID:
|
||||
name = "RSPdx ("; name += devArr[i].SerNo; name += ')';
|
||||
break;
|
||||
default:
|
||||
name = "Unknown ("; name += devArr[i].SerNo; name += ')';
|
||||
break;
|
||||
case SDRPLAY_RSP1_ID:
|
||||
name = "RSP1 (";
|
||||
name += devArr[i].SerNo;
|
||||
name += ')';
|
||||
break;
|
||||
case SDRPLAY_RSP1A_ID:
|
||||
name = "RSP1A (";
|
||||
name += devArr[i].SerNo;
|
||||
name += ')';
|
||||
break;
|
||||
case SDRPLAY_RSP2_ID:
|
||||
name = "RSP2 (";
|
||||
name += devArr[i].SerNo;
|
||||
name += ')';
|
||||
break;
|
||||
case SDRPLAY_RSPduo_ID:
|
||||
name = "RSPduo (";
|
||||
name += devArr[i].SerNo;
|
||||
name += ')';
|
||||
break;
|
||||
case SDRPLAY_RSPdx_ID:
|
||||
name = "RSPdx (";
|
||||
name += devArr[i].SerNo;
|
||||
name += ')';
|
||||
break;
|
||||
default:
|
||||
name = "Unknown (";
|
||||
name += devArr[i].SerNo;
|
||||
name += ')';
|
||||
break;
|
||||
}
|
||||
devNameList.push_back(name);
|
||||
devListTxt += name;
|
||||
@ -372,9 +384,9 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
if(config.conf["devices"][selectedName].contains("ifModeId")) {
|
||||
ifModeId=config.conf["devices"][selectedName]["ifModeId"];
|
||||
if(ifModeId != 0){
|
||||
if (config.conf["devices"][selectedName].contains("ifModeId")) {
|
||||
ifModeId = config.conf["devices"][selectedName]["ifModeId"];
|
||||
if (ifModeId != 0) {
|
||||
sampleRate = ifModes[ifModeId].effectiveSamplerate;
|
||||
}
|
||||
}
|
||||
@ -473,14 +485,14 @@ public:
|
||||
}
|
||||
|
||||
config.release(created);
|
||||
|
||||
|
||||
if (lnaGain >= lnaSteps) { lnaGain = lnaSteps - 1; }
|
||||
|
||||
// Release device after selecting
|
||||
sdrplay_api_Uninit(openDev.dev);
|
||||
sdrplay_api_ReleaseDevice(&openDev);
|
||||
}
|
||||
|
||||
|
||||
void rspDuoSelectTuner(sdrplay_api_TunerSelectT tuner, sdrplay_api_RspDuo_AmPortSelectT amPort) {
|
||||
if (openDev.tuner != tuner) {
|
||||
spdlog::info("Swapping tuners");
|
||||
@ -500,7 +512,6 @@ public:
|
||||
channelParams->tunerParams.gain.gRdB = gain;
|
||||
sdrplay_api_Update(openDev.dev, openDev.tuner, sdrplay_api_Update_Tuner_Gr, sdrplay_api_Update_Ext1_None);
|
||||
sdrplay_api_Update(openDev.dev, openDev.tuner, sdrplay_api_Update_Tuner_Gr, sdrplay_api_Update_Ext1_None);
|
||||
|
||||
}
|
||||
|
||||
void rspDuoSelectAntennaPort(int port) {
|
||||
@ -534,7 +545,7 @@ private:
|
||||
SDRPlaySourceModule* _this = (SDRPlaySourceModule*)ctx;
|
||||
spdlog::info("SDRPlaySourceModule '{0}': Menu Deselect!", _this->name);
|
||||
}
|
||||
|
||||
|
||||
static void start(void* ctx) {
|
||||
SDRPlaySourceModule* _this = (SDRPlaySourceModule*)ctx;
|
||||
if (_this->running) { return; }
|
||||
@ -620,11 +631,12 @@ private:
|
||||
}
|
||||
|
||||
// General options
|
||||
if(_this->ifModeId == 0){
|
||||
if (_this->ifModeId == 0) {
|
||||
_this->bandwidth = (_this->bandwidthId == 8) ? preferedBandwidth[_this->srId] : bandwidths[_this->bandwidthId];
|
||||
_this->openDevParams->devParams->fsFreq.fsHz = _this->sampleRate;
|
||||
_this->channelParams->tunerParams.bwType = _this->bandwidth;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
_this->openDevParams->devParams->fsFreq.fsHz = ifModes[_this->ifModeId].deviceSamplerate;
|
||||
_this->channelParams->tunerParams.bwType = ifModes[_this->ifModeId].bw;
|
||||
}
|
||||
@ -658,13 +670,13 @@ private:
|
||||
_this->running = true;
|
||||
spdlog::info("SDRPlaySourceModule '{0}': Start!", _this->name);
|
||||
}
|
||||
|
||||
|
||||
static void stop(void* ctx) {
|
||||
SDRPlaySourceModule* _this = (SDRPlaySourceModule*)ctx;
|
||||
if (!_this->running) { return; }
|
||||
_this->running = false;
|
||||
_this->stream.stopWriter();
|
||||
|
||||
|
||||
// Release device after stopping
|
||||
sdrplay_api_Uninit(_this->openDev.dev);
|
||||
sdrplay_api_ReleaseDevice(&_this->openDev);
|
||||
@ -672,7 +684,7 @@ private:
|
||||
_this->stream.clearWriteStop();
|
||||
spdlog::info("SDRPlaySourceModule '{0}': Stop!", _this->name);
|
||||
}
|
||||
|
||||
|
||||
static void tune(double freq, void* ctx) {
|
||||
SDRPlaySourceModule* _this = (SDRPlaySourceModule*)ctx;
|
||||
if (_this->running) {
|
||||
@ -682,7 +694,7 @@ private:
|
||||
_this->freq = freq;
|
||||
spdlog::info("SDRPlaySourceModule '{0}': Tune: {1}!", _this->name, freq);
|
||||
}
|
||||
|
||||
|
||||
static void menuHandler(void* ctx) {
|
||||
SDRPlaySourceModule* _this = (SDRPlaySourceModule*)ctx;
|
||||
float menuWidth = ImGui::GetContentRegionAvailWidth();
|
||||
@ -690,8 +702,8 @@ private:
|
||||
if (_this->running) { style::beginDisabled(); }
|
||||
|
||||
ImGui::SetNextItemWidth(menuWidth);
|
||||
|
||||
|
||||
|
||||
|
||||
if (ImGui::Combo(CONCAT("##sdrplay_dev", _this->name), &_this->devId, _this->devListTxt.c_str())) {
|
||||
_this->selectById(_this->devId);
|
||||
config.acquire();
|
||||
@ -736,28 +748,29 @@ private:
|
||||
_this->selectByName(_this->selectedName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ImGui::Text("IF Mode");
|
||||
ImGui::SameLine();
|
||||
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX());
|
||||
if (ImGui::Combo(CONCAT("##sdrplay_ifmode", _this->name), &_this->ifModeId, ifModeTxt)) {
|
||||
if(_this->ifModeId != 0){
|
||||
if (_this->ifModeId != 0) {
|
||||
_this->bandwidth = ifModes[_this->ifModeId].bw;
|
||||
_this->sampleRate = ifModes[_this->ifModeId].effectiveSamplerate;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
config.acquire();
|
||||
_this->sampleRate = config.conf["devices"][_this->selectedName]["sampleRate"];
|
||||
_this->bandwidthId = config.conf["devices"][_this->selectedName]["bwMode"];
|
||||
config.release(false);
|
||||
_this->bandwidth = (_this->bandwidthId == 8) ? preferedBandwidth[_this->srId] : bandwidths[_this->bandwidthId];
|
||||
}
|
||||
}
|
||||
core::setInputSampleRate(_this->sampleRate);
|
||||
config.acquire();
|
||||
config.conf["devices"][_this->selectedName]["ifModeId"] = _this->ifModeId;
|
||||
config.release(true);
|
||||
}
|
||||
|
||||
if (_this->running) { style::endDisabled(); }
|
||||
if (_this->running) { style::endDisabled(); }
|
||||
|
||||
if (_this->selectedName != "") {
|
||||
ImGui::PushItemWidth(menuWidth - ImGui::CalcTextSize("LNA Gain").x - 10);
|
||||
@ -850,29 +863,29 @@ private:
|
||||
}
|
||||
|
||||
switch (_this->openDev.hwVer) {
|
||||
case SDRPLAY_RSP1_ID:
|
||||
_this->RSP1Menu(menuWidth);
|
||||
break;
|
||||
case SDRPLAY_RSP1A_ID:
|
||||
_this->RSP1AMenu(menuWidth);
|
||||
break;
|
||||
case SDRPLAY_RSP2_ID:
|
||||
_this->RSP2Menu(menuWidth);
|
||||
break;
|
||||
case SDRPLAY_RSPduo_ID:
|
||||
_this->RSPduoMenu(menuWidth);
|
||||
break;
|
||||
case SDRPLAY_RSPdx_ID:
|
||||
_this->RSPdxMenu(menuWidth);
|
||||
break;
|
||||
default:
|
||||
_this->RSPUnsupportedMenu(menuWidth);
|
||||
break;
|
||||
case SDRPLAY_RSP1_ID:
|
||||
_this->RSP1Menu(menuWidth);
|
||||
break;
|
||||
case SDRPLAY_RSP1A_ID:
|
||||
_this->RSP1AMenu(menuWidth);
|
||||
break;
|
||||
case SDRPLAY_RSP2_ID:
|
||||
_this->RSP2Menu(menuWidth);
|
||||
break;
|
||||
case SDRPLAY_RSPduo_ID:
|
||||
_this->RSPduoMenu(menuWidth);
|
||||
break;
|
||||
case SDRPLAY_RSPdx_ID:
|
||||
_this->RSPdxMenu(menuWidth);
|
||||
break;
|
||||
default:
|
||||
_this->RSPUnsupportedMenu(menuWidth);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
ImGui::TextColored(ImVec4(1.0f, 0.0f, 0.0f, 1.0f), "No device available");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool agcParamMenu(bool& valid) {
|
||||
@ -881,7 +894,7 @@ private:
|
||||
ImGui::OpenPopup("Edit##sdrplay_source_edit_agc_params_");
|
||||
if (ImGui::BeginPopup("Edit##sdrplay_source_edit_agc_params_", ImGuiWindowFlags_NoResize)) {
|
||||
|
||||
ImGui::BeginTable(("sdrplay_source_agc_param_tbl"+name).c_str(), 2);
|
||||
ImGui::BeginTable(("sdrplay_source_agc_param_tbl" + name).c_str(), 2);
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
@ -938,7 +951,7 @@ private:
|
||||
}
|
||||
return open;
|
||||
}
|
||||
|
||||
|
||||
void RSP1Menu(float menuWidth) {
|
||||
// No options?
|
||||
}
|
||||
@ -1103,8 +1116,8 @@ private:
|
||||
ImGui::TextColored(ImVec4(1.0f, 0.0f, 0.0f, 1.0f), "Device currently unsupported");
|
||||
}
|
||||
|
||||
static void streamCB(short *xi, short *xq, sdrplay_api_StreamCbParamsT *params,
|
||||
unsigned int numSamples, unsigned int reset, void *cbContext) {
|
||||
static void streamCB(short* xi, short* xq, sdrplay_api_StreamCbParamsT* params,
|
||||
unsigned int numSamples, unsigned int reset, void* cbContext) {
|
||||
SDRPlaySourceModule* _this = (SDRPlaySourceModule*)cbContext;
|
||||
// TODO: Optimise using volk and math
|
||||
if (!_this->running) { return; }
|
||||
@ -1121,7 +1134,7 @@ private:
|
||||
}
|
||||
|
||||
static void eventCB(sdrplay_api_EventT eventId, sdrplay_api_TunerSelectT tuner,
|
||||
sdrplay_api_EventParamsT *params, void *cbContext) {
|
||||
sdrplay_api_EventParamsT* params, void* cbContext) {
|
||||
SDRPlaySourceModule* _this = (SDRPlaySourceModule*)cbContext;
|
||||
}
|
||||
|
||||
@ -1137,7 +1150,7 @@ private:
|
||||
sdrplay_api_CallbackFnsT cbFuncs;
|
||||
|
||||
sdrplay_api_DeviceT openDev;
|
||||
sdrplay_api_DeviceParamsT * openDevParams;
|
||||
sdrplay_api_DeviceParamsT* openDevParams;
|
||||
sdrplay_api_RxChannelParamsT* channelParams;
|
||||
|
||||
sdrplay_api_Bw_MHzT bandwidth;
|
||||
@ -1149,7 +1162,7 @@ private:
|
||||
int lnaGain = 9;
|
||||
int gain = 59;
|
||||
int lnaSteps = 9;
|
||||
|
||||
|
||||
bool agc = false;
|
||||
bool agcParamEdit = false;
|
||||
int agcAttack = 500;
|
||||
|
Reference in New Issue
Block a user