mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2024-12-25 02:18:30 +01:00
Fixed LimeSDR + Fixed FFTSize bug + added ppm option to RTL-SDR & RTL-TCP + Fixed RTL-TCP not saving settings
This commit is contained in:
parent
9eb3ef0500
commit
dcc17cdee7
@ -213,6 +213,11 @@ void MainWindow::fftHandler(dsp::complex_t* samples, int count, void* ctx) {
|
||||
MainWindow* _this = (MainWindow*)ctx;
|
||||
std::lock_guard<std::mutex> lck(_this->fft_mtx);
|
||||
|
||||
// Check if the count is valid
|
||||
if (count > _this->fftSize) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Apply window
|
||||
volk_32fc_32f_multiply_32fc((lv_32fc_t*)_this->fft_in, (lv_32fc_t*)samples, sigpath::signalPath.fftTaps, count);
|
||||
|
||||
@ -657,9 +662,9 @@ void MainWindow::setFFTSize(int size) {
|
||||
gui::waterfall.setRawFFTSize(fftSize);
|
||||
sigpath::signalPath.setFFTSize(fftSize);
|
||||
|
||||
fftwf_destroy_plan(fftwPlan);
|
||||
fftwf_free(fft_in);
|
||||
fftwf_free(fft_out);
|
||||
fftwf_destroy_plan(fftwPlan);
|
||||
|
||||
fft_in = (fftwf_complex*)fftwf_malloc(sizeof(fftwf_complex) * fftSize);
|
||||
fft_out = (fftwf_complex*)fftwf_malloc(sizeof(fftwf_complex) * fftSize);
|
||||
|
@ -1,3 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#define VERSION_STR "1.0.2"
|
||||
#define VERSION_STR "1.0.3"
|
@ -335,7 +335,7 @@ private:
|
||||
// Setup and start stream
|
||||
int sampCount = _this->sampleRate / 200;
|
||||
_this->devStream.isTx = false;
|
||||
_this->devStream.channel = 0;
|
||||
_this->devStream.channel = _this->chanId;
|
||||
_this->devStream.fifoSize = sampCount; // TODO: Check what it's actually supposed to be
|
||||
_this->devStream.throughputVsLatency = 0.5f;
|
||||
_this->devStream.dataFmt = _this->devStream.LMS_FMT_F32;
|
||||
|
@ -162,6 +162,7 @@ public:
|
||||
created = true;
|
||||
config.conf["devices"][selectedDevName]["sampleRate"] = 2400000.0;
|
||||
config.conf["devices"][selectedDevName]["directSampling"] = directSamplingMode;
|
||||
config.conf["devices"][selectedDevName]["ppm"] = 0;
|
||||
config.conf["devices"][selectedDevName]["biasT"] = biasT;
|
||||
config.conf["devices"][selectedDevName]["offsetTuning"] = offsetTuning;
|
||||
config.conf["devices"][selectedDevName]["rtlAgc"] = rtlAgc;
|
||||
@ -187,6 +188,10 @@ public:
|
||||
directSamplingMode = config.conf["devices"][selectedDevName]["directSampling"];
|
||||
}
|
||||
|
||||
if (config.conf["devices"][selectedDevName].contains("ppm")) {
|
||||
ppm = config.conf["devices"][selectedDevName]["ppm"];
|
||||
}
|
||||
|
||||
if (config.conf["devices"][selectedDevName].contains("biasT")) {
|
||||
biasT = config.conf["devices"][selectedDevName]["biasT"];
|
||||
}
|
||||
@ -256,6 +261,7 @@ private:
|
||||
|
||||
rtlsdr_set_sample_rate(_this->openDev, _this->sampleRate);
|
||||
rtlsdr_set_center_freq(_this->openDev, _this->freq);
|
||||
rtlsdr_set_freq_correction(_this->openDev, _this->ppm);
|
||||
rtlsdr_set_tuner_bandwidth(_this->openDev, 0);
|
||||
rtlsdr_set_direct_sampling(_this->openDev, _this->directSamplingMode);
|
||||
rtlsdr_set_bias_tee(_this->openDev, _this->biasT);
|
||||
@ -372,6 +378,21 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::Text("PPM Correction");
|
||||
ImGui::SameLine();
|
||||
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX());
|
||||
if (ImGui::InputInt(CONCAT("##_rtlsdr_ppm_", _this->name), &_this->ppm, 1, 10)) {
|
||||
_this->ppm = std::clamp<int>(_this->ppm, -1000000, 1000000);
|
||||
if (_this->running) {
|
||||
rtlsdr_set_freq_correction(_this->openDev, _this->ppm);
|
||||
}
|
||||
if (_this->selectedDevName != "") {
|
||||
config.acquire();
|
||||
config.conf["devices"][_this->selectedDevName]["ppm"] = _this->ppm;
|
||||
config.release(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (ImGui::Checkbox(CONCAT("Bias T##_rtlsdr_rtl_biast_", _this->name), &_this->biasT)) {
|
||||
if (_this->running) {
|
||||
rtlsdr_set_bias_tee(_this->openDev, _this->biasT);
|
||||
@ -471,6 +492,8 @@ private:
|
||||
int devCount = 0;
|
||||
std::thread workerThread;
|
||||
|
||||
int ppm = 0;
|
||||
|
||||
bool biasT = false;
|
||||
|
||||
int gainId = 0;
|
||||
|
@ -48,6 +48,8 @@ const char* sampleRatesTxt[] = {
|
||||
"3.2MHz"
|
||||
};
|
||||
|
||||
#define SAMPLE_RATE_COUNT (sizeof(sampleRates) / sizeof(double))
|
||||
|
||||
class RTLTCPSourceModule : public ModuleManager::Instance {
|
||||
public:
|
||||
RTLTCPSourceModule(std::string name) {
|
||||
@ -55,8 +57,9 @@ public:
|
||||
|
||||
sampleRate = 2400000.0;
|
||||
|
||||
int srCount = sizeof(sampleRatesTxt) / sizeof(char*);
|
||||
for (int i = 0; i < srCount; i++) {
|
||||
int _24id = 0;
|
||||
for (int i = 0; i < SAMPLE_RATE_COUNT; i++) {
|
||||
if (sampleRates[i] == 2400000) { _24id = i; }
|
||||
srTxt += sampleRatesTxt[i];
|
||||
srTxt += '\0';
|
||||
}
|
||||
@ -65,7 +68,9 @@ public:
|
||||
config.acquire();
|
||||
std::string hostStr = config.conf["host"];
|
||||
port = config.conf["port"];
|
||||
double wantedSr = config.conf["sampleRate"];
|
||||
directSamplingMode = config.conf["directSamplingMode"];
|
||||
ppm = config.conf["ppm"];
|
||||
rtlAGC = config.conf["rtlAGC"];
|
||||
tunerAGC = config.conf["tunerAGC"];
|
||||
gain = std::clamp<int>(config.conf["gainIndex"], 0, 28);
|
||||
@ -75,6 +80,20 @@ public:
|
||||
strcpy(ip, hostStr.c_str());
|
||||
config.release();
|
||||
|
||||
bool found = false;
|
||||
for (int i = 0; i < SAMPLE_RATE_COUNT; i++) {
|
||||
if (sampleRates[i] == wantedSr) {
|
||||
found = true;
|
||||
srId = i;
|
||||
sampleRate = sampleRates[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
srId = _24id;
|
||||
sampleRate = sampleRates[_24id];
|
||||
}
|
||||
|
||||
handler.ctx = this;
|
||||
handler.selectHandler = menuSelected;
|
||||
handler.deselectHandler = menuDeselected;
|
||||
@ -127,6 +146,7 @@ private:
|
||||
spdlog::warn("Setting sample rate to {0}", _this->sampleRate);
|
||||
_this->client.setFrequency(_this->freq);
|
||||
_this->client.setSampleRate(_this->sampleRate);
|
||||
_this->client.setPPM(_this->ppm);
|
||||
_this->client.setDirectSampling(_this->directSamplingMode);
|
||||
_this->client.setAGCMode(_this->rtlAGC);
|
||||
_this->client.setBiasTee(_this->biasTee);
|
||||
@ -191,6 +211,9 @@ private:
|
||||
if (ImGui::Combo(CONCAT("##_rtltcp_sr_", _this->name), &_this->srId, _this->srTxt.c_str())) {
|
||||
_this->sampleRate = sampleRates[_this->srId];
|
||||
core::setInputSampleRate(_this->sampleRate);
|
||||
config.acquire();
|
||||
config.conf["sampleRate"] = _this->sampleRate;
|
||||
config.release(true);
|
||||
}
|
||||
|
||||
if (_this->running) { style::endDisabled(); }
|
||||
@ -203,18 +226,39 @@ private:
|
||||
_this->client.setDirectSampling(_this->directSamplingMode);
|
||||
_this->client.setGainIndex(_this->gain);
|
||||
}
|
||||
config.acquire();
|
||||
config.conf["directSamplingMode"] = _this->directSamplingMode;
|
||||
config.release(true);
|
||||
}
|
||||
|
||||
ImGui::Text("PPM Correction");
|
||||
ImGui::SameLine();
|
||||
ImGui::SetNextItemWidth(menuWidth - ImGui::GetCursorPosX());
|
||||
if (ImGui::InputInt(CONCAT("##_rtltcp_ppm_", _this->name), &_this->ppm, 1, 10)) {
|
||||
if (_this->running) {
|
||||
_this->client.setPPM(_this->ppm);
|
||||
}
|
||||
config.acquire();
|
||||
config.conf["ppm"] = _this->ppm;
|
||||
config.release(true);
|
||||
}
|
||||
|
||||
if (ImGui::Checkbox(CONCAT("Bias-T##_biast_select_", _this->name), &_this->biasTee)) {
|
||||
if (_this->running) {
|
||||
_this->client.setBiasTee(_this->biasTee);
|
||||
}
|
||||
config.acquire();
|
||||
config.conf["biasTee"] = _this->biasTee;
|
||||
config.release(true);
|
||||
}
|
||||
|
||||
if (ImGui::Checkbox(CONCAT("Offset Tuning##_biast_select_", _this->name), &_this->offsetTuning)) {
|
||||
if (_this->running) {
|
||||
_this->client.setOffsetTuning(_this->offsetTuning);
|
||||
}
|
||||
config.acquire();
|
||||
config.conf["offsetTuning"] = _this->offsetTuning;
|
||||
config.release(true);
|
||||
}
|
||||
|
||||
if (ImGui::Checkbox("RTL AGC", &_this->rtlAGC)) {
|
||||
@ -224,6 +268,9 @@ private:
|
||||
_this->client.setGainIndex(_this->gain);
|
||||
}
|
||||
}
|
||||
config.acquire();
|
||||
config.conf["rtlAGC"] = _this->rtlAGC;
|
||||
config.release(true);
|
||||
}
|
||||
|
||||
if (ImGui::Checkbox("Tuner AGC", &_this->tunerAGC)) {
|
||||
@ -233,6 +280,9 @@ private:
|
||||
_this->client.setGainIndex(_this->gain);
|
||||
}
|
||||
}
|
||||
config.acquire();
|
||||
config.conf["tunerAGC"] = _this->tunerAGC;
|
||||
config.release(true);
|
||||
}
|
||||
|
||||
if (_this->tunerAGC) { style::beginDisabled(); }
|
||||
@ -241,6 +291,9 @@ private:
|
||||
if (_this->running) {
|
||||
_this->client.setGainIndex(_this->gain);
|
||||
}
|
||||
config.acquire();
|
||||
config.conf["gainIndex"] = _this->gain;
|
||||
config.release(true);
|
||||
}
|
||||
if (_this->tunerAGC) { style::endDisabled(); }
|
||||
}
|
||||
@ -275,6 +328,7 @@ private:
|
||||
char ip[1024] = "localhost";
|
||||
int port = 1234;
|
||||
int gain = 0;
|
||||
int ppm = 0;
|
||||
bool rtlAGC = false;
|
||||
bool tunerAGC = false;
|
||||
int directSamplingMode = 0;
|
||||
@ -290,7 +344,9 @@ MOD_EXPORT void _INIT_() {
|
||||
json defConf;
|
||||
defConf["host"] = "localhost";
|
||||
defConf["port"] = 1234;
|
||||
defConf["sampleRate"] = 2400000.0;
|
||||
defConf["directSamplingMode"] = 0;
|
||||
defConf["ppm"] = 0;
|
||||
defConf["rtlAGC"] = false;
|
||||
defConf["tunerAGC"] = false;
|
||||
defConf["gainIndex"] = 0;
|
||||
@ -306,6 +362,12 @@ MOD_EXPORT void _INIT_() {
|
||||
if (!config.conf.contains("offsetTuning")) {
|
||||
config.conf["offsetTuning"] = false;
|
||||
}
|
||||
if (!config.conf.contains("ppm")) {
|
||||
config.conf["ppm"] = 0;
|
||||
}
|
||||
if (!config.conf.contains("sampleRate")) {
|
||||
config.conf["sampleRate"] = 2400000.0;
|
||||
}
|
||||
config.release(true);
|
||||
}
|
||||
|
||||
|
@ -166,6 +166,10 @@ public:
|
||||
sendCommand(4, gain);
|
||||
}
|
||||
|
||||
void setPPM(int ppm) {
|
||||
sendCommand(5, (uint32_t)ppm);
|
||||
}
|
||||
|
||||
void setAGCMode(int mode) {
|
||||
sendCommand(8, mode);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user