mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2024-11-06 18:57:39 +01:00
text in rtlsdr
This commit is contained in:
parent
0769b61dd2
commit
e79fa4145b
@ -66,6 +66,8 @@ public:
|
|||||||
handler.tuneHandler = tune;
|
handler.tuneHandler = tune;
|
||||||
handler.stream = &stream;
|
handler.stream = &stream;
|
||||||
|
|
||||||
|
strcpy(dbTxt, "--");
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
sampleRateListTxt += sampleRatesTxt[i];
|
sampleRateListTxt += sampleRatesTxt[i];
|
||||||
sampleRateListTxt += '\0';
|
sampleRateListTxt += '\0';
|
||||||
@ -162,6 +164,7 @@ public:
|
|||||||
config.conf["devices"][selectedDevName]["gain"] = gainId;
|
config.conf["devices"][selectedDevName]["gain"] = gainId;
|
||||||
}
|
}
|
||||||
if (gainId >= gainList.size()) { gainId = gainList.size() - 1; }
|
if (gainId >= gainList.size()) { gainId = gainList.size() - 1; }
|
||||||
|
updateGainTxt();
|
||||||
|
|
||||||
// Load config
|
// Load config
|
||||||
if (config.conf["devices"][selectedDevName].contains("sampleRate")) {
|
if (config.conf["devices"][selectedDevName].contains("sampleRate")) {
|
||||||
@ -193,6 +196,7 @@ public:
|
|||||||
|
|
||||||
if (config.conf["devices"][selectedDevName].contains("gain")) {
|
if (config.conf["devices"][selectedDevName].contains("gain")) {
|
||||||
gainId = config.conf["devices"][selectedDevName]["gain"];
|
gainId = config.conf["devices"][selectedDevName]["gain"];
|
||||||
|
updateGainTxt();
|
||||||
}
|
}
|
||||||
|
|
||||||
config.release(created);
|
config.release(created);
|
||||||
@ -277,7 +281,7 @@ private:
|
|||||||
static void tune(double freq, void* ctx) {
|
static void tune(double freq, void* ctx) {
|
||||||
RTLSDRSourceModule* _this = (RTLSDRSourceModule*)ctx;
|
RTLSDRSourceModule* _this = (RTLSDRSourceModule*)ctx;
|
||||||
if (_this->running) {
|
if (_this->running) {
|
||||||
rtlsdr_set_center_freq(_this->openDev, freq);
|
rtlsdr_set_center_freq(_this->openDev, _this->freq);
|
||||||
}
|
}
|
||||||
_this->freq = freq;
|
_this->freq = freq;
|
||||||
spdlog::info("RTLSDRSourceModule '{0}': Tune: {1}!", _this->name, freq);
|
spdlog::info("RTLSDRSourceModule '{0}': Tune: {1}!", _this->name, freq);
|
||||||
@ -364,7 +368,8 @@ private:
|
|||||||
|
|
||||||
if (_this->tunerAgc) { style::beginDisabled(); }
|
if (_this->tunerAgc) { style::beginDisabled(); }
|
||||||
ImGui::SetNextItemWidth(menuWidth);
|
ImGui::SetNextItemWidth(menuWidth);
|
||||||
if (ImGui::SliderInt(CONCAT("##_rtlsdr_gain_", _this->name), &_this->gainId, 0, _this->gainList.size() - 1, "")) {
|
if (ImGui::SliderInt(CONCAT("##_rtlsdr_gain_", _this->name), &_this->gainId, 0, _this->gainList.size() - 1, _this->dbTxt)) {
|
||||||
|
_this->updateGainTxt();
|
||||||
if (_this->running) {
|
if (_this->running) {
|
||||||
rtlsdr_set_tuner_gain(_this->openDev, _this->gainList[_this->gainId]);
|
rtlsdr_set_tuner_gain(_this->openDev, _this->gainList[_this->gainId]);
|
||||||
}
|
}
|
||||||
@ -391,6 +396,10 @@ private:
|
|||||||
if (!_this->stream.swap(sampCount)) { return; }
|
if (!_this->stream.swap(sampCount)) { return; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void updateGainTxt() {
|
||||||
|
sprintf(dbTxt, "%.1f dB", (float)gainList[gainId] / 10.0f);
|
||||||
|
}
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
rtlsdr_dev_t* openDev;
|
rtlsdr_dev_t* openDev;
|
||||||
bool enabled = true;
|
bool enabled = true;
|
||||||
@ -418,6 +427,8 @@ private:
|
|||||||
// Handler stuff
|
// Handler stuff
|
||||||
int asyncCount = 0;
|
int asyncCount = 0;
|
||||||
|
|
||||||
|
char dbTxt[128];
|
||||||
|
|
||||||
std::vector<std::string> devNames;
|
std::vector<std::string> devNames;
|
||||||
std::string devListTxt;
|
std::string devListTxt;
|
||||||
std::string sampleRateListTxt;
|
std::string sampleRateListTxt;
|
||||||
|
@ -127,6 +127,7 @@ public:
|
|||||||
if (err != sdrplay_api_Success) {
|
if (err != sdrplay_api_Success) {
|
||||||
const char* errStr = sdrplay_api_GetErrorString(err);
|
const char* errStr = sdrplay_api_GetErrorString(err);
|
||||||
spdlog::error("Could not select RSP device: {0}", errStr);
|
spdlog::error("Could not select RSP device: {0}", errStr);
|
||||||
|
deviceOpen = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,6 +135,7 @@ public:
|
|||||||
if (err != sdrplay_api_Success) {
|
if (err != sdrplay_api_Success) {
|
||||||
const char* errStr = sdrplay_api_GetErrorString(err);
|
const char* errStr = sdrplay_api_GetErrorString(err);
|
||||||
spdlog::error("Could not get device params for RSP device: {0}", errStr);
|
spdlog::error("Could not get device params for RSP device: {0}", errStr);
|
||||||
|
deviceOpen = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,6 +143,7 @@ public:
|
|||||||
if (err != sdrplay_api_Success) {
|
if (err != sdrplay_api_Success) {
|
||||||
const char* errStr = sdrplay_api_GetErrorString(err);
|
const char* errStr = sdrplay_api_GetErrorString(err);
|
||||||
spdlog::error("Could not init RSP device: {0}", errStr);
|
spdlog::error("Could not init RSP device: {0}", errStr);
|
||||||
|
deviceOpen = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,13 +189,16 @@ private:
|
|||||||
_this->openDevParams->devParams->fsFreq.fsHz = 8000000;
|
_this->openDevParams->devParams->fsFreq.fsHz = 8000000;
|
||||||
_this->openDevParams->rxChannelA->tunerParams.bwType = sdrplay_api_BW_8_000;
|
_this->openDevParams->rxChannelA->tunerParams.bwType = sdrplay_api_BW_8_000;
|
||||||
_this->openDevParams->rxChannelA->tunerParams.rfFreq.rfHz = _this->freq;
|
_this->openDevParams->rxChannelA->tunerParams.rfFreq.rfHz = _this->freq;
|
||||||
|
_this->openDevParams->rxChannelA->tunerParams.gain.gRdB = 0;
|
||||||
_this->openDevParams->rxChannelA->tunerParams.gain.LNAstate = 0;
|
_this->openDevParams->rxChannelA->tunerParams.gain.LNAstate = 0;
|
||||||
|
_this->openDevParams->rxChannelA->ctrlParams.agc.enable = sdrplay_api_AGC_DISABLE;
|
||||||
//_this->openDevParams->devParams->
|
//_this->openDevParams->devParams->
|
||||||
|
|
||||||
sdrplay_api_Update(_this->openDev.dev, _this->openDev.tuner, sdrplay_api_Update_Dev_Fs, sdrplay_api_Update_Ext1_None);
|
sdrplay_api_Update(_this->openDev.dev, _this->openDev.tuner, sdrplay_api_Update_Dev_Fs, sdrplay_api_Update_Ext1_None);
|
||||||
sdrplay_api_Update(_this->openDev.dev, _this->openDev.tuner, sdrplay_api_Update_Tuner_BwType, sdrplay_api_Update_Ext1_None);
|
sdrplay_api_Update(_this->openDev.dev, _this->openDev.tuner, sdrplay_api_Update_Tuner_BwType, sdrplay_api_Update_Ext1_None);
|
||||||
sdrplay_api_Update(_this->openDev.dev, _this->openDev.tuner, sdrplay_api_Update_Tuner_Frf, sdrplay_api_Update_Ext1_None);
|
sdrplay_api_Update(_this->openDev.dev, _this->openDev.tuner, sdrplay_api_Update_Tuner_Frf, sdrplay_api_Update_Ext1_None);
|
||||||
sdrplay_api_Update(_this->openDev.dev, _this->openDev.tuner, sdrplay_api_Update_Tuner_Gr, sdrplay_api_Update_Ext1_None);
|
sdrplay_api_Update(_this->openDev.dev, _this->openDev.tuner, sdrplay_api_Update_Tuner_Gr, sdrplay_api_Update_Ext1_None);
|
||||||
|
sdrplay_api_Update(_this->openDev.dev, _this->openDev.tuner, sdrplay_api_Update_Ctrl_Agc, sdrplay_api_Update_Ext1_None);
|
||||||
|
|
||||||
_this->running = true;
|
_this->running = true;
|
||||||
spdlog::info("SDRPlaySourceModule '{0}': Start!", _this->name);
|
spdlog::info("SDRPlaySourceModule '{0}': Start!", _this->name);
|
||||||
@ -233,10 +239,60 @@ private:
|
|||||||
|
|
||||||
if (ImGui::Combo(CONCAT("##sdrplay_dev", _this->name), &_this->devId, _this->devListTxt.c_str())) {
|
if (ImGui::Combo(CONCAT("##sdrplay_dev", _this->name), &_this->devId, _this->devListTxt.c_str())) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_this->deviceOpen) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ImGui::TextColored(ImVec4(1.0f, 0.0f, 0.0f, 1.0f), "No device available");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_this->running) { style::endDisabled(); }
|
if (_this->running) { style::endDisabled(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RSP1Menu(float menuWidth) {
|
||||||
|
ImGui::TextColored(ImVec4(1.0f, 0.0f, 0.0f, 1.0f), "Device currently unsupported");
|
||||||
|
}
|
||||||
|
|
||||||
|
void RSP1AMenu(float menuWidth) {
|
||||||
|
ImGui::TextColored(ImVec4(1.0f, 0.0f, 0.0f, 1.0f), "Device currently unsupported");
|
||||||
|
}
|
||||||
|
|
||||||
|
void RSP2Menu(float menuWidth) {
|
||||||
|
ImGui::TextColored(ImVec4(1.0f, 0.0f, 0.0f, 1.0f), "Device currently unsupported");
|
||||||
|
}
|
||||||
|
|
||||||
|
void RSPduoMenu(float menuWidth) {
|
||||||
|
ImGui::TextColored(ImVec4(1.0f, 0.0f, 0.0f, 1.0f), "Device currently unsupported");
|
||||||
|
}
|
||||||
|
|
||||||
|
void RSPdxMenu(float menuWidth) {
|
||||||
|
ImGui::TextColored(ImVec4(1.0f, 0.0f, 0.0f, 1.0f), "Device currently unsupported");
|
||||||
|
}
|
||||||
|
|
||||||
|
void RSPUnsupportedMenu(float menuWidth) {
|
||||||
|
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,
|
static void streamCB(short *xi, short *xq, sdrplay_api_StreamCbParamsT *params,
|
||||||
unsigned int numSamples, unsigned int reset, void *cbContext) {
|
unsigned int numSamples, unsigned int reset, void *cbContext) {
|
||||||
|
Loading…
Reference in New Issue
Block a user