From 3d7cfffe13e43bd3817fcc72421590d6938efea4 Mon Sep 17 00:00:00 2001 From: Ryzerth Date: Mon, 12 Jul 2021 16:53:59 +0200 Subject: [PATCH] potential fix for the RTL-SDR not tuning (mayhaps?) --- core/src/gui/widgets/waterfall.cpp | 6 +++--- rtl_sdr_source/src/main.cpp | 11 ++++++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/core/src/gui/widgets/waterfall.cpp b/core/src/gui/widgets/waterfall.cpp index 61087170..b198fe1a 100644 --- a/core/src/gui/widgets/waterfall.cpp +++ b/core/src/gui/widgets/waterfall.cpp @@ -202,7 +202,7 @@ namespace ImGui { window->DrawList->AddImage((void*)(intptr_t)textureId, wfMin, wfMax); ImVec2 mPos = ImGui::GetMousePos(); - if (IS_IN_AREA(mPos, wfMin, wfMax) && !gui::mainWindow.lockWaterfallControls) { + if (IS_IN_AREA(mPos, wfMin, wfMax) && !gui::mainWindow.lockWaterfallControls && !inputHandled) { for (auto const& [name, vfo] : vfos) { window->DrawList->AddRectFilled(vfo->wfRectMin, vfo->wfRectMax, vfo->color); if (!vfo->lineVisible) { continue; } @@ -749,7 +749,7 @@ namespace ImGui { } // Handle fft resize - if (!gui::mainWindow.lockWaterfallControls) { + if (!gui::mainWindow.lockWaterfallControls && !inputHandled) { ImVec2 winSize = ImGui::GetWindowSize(); ImVec2 mousePos = ImGui::GetMousePos(); mousePos.x -= widgetPos.x; @@ -1169,7 +1169,7 @@ namespace ImGui { window->DrawList->AddLine(lineMin, lineMax, selected ? IM_COL32(255, 0, 0, 255) : IM_COL32(255, 255, 0, 255)); } - if (!gui::mainWindow.lockWaterfallControls) { + if (!gui::mainWindow.lockWaterfallControls && !gui::waterfall.inputHandled) { ImVec2 mousePos = ImGui::GetMousePos(); if (reference != REF_LOWER && !bandwidthLocked && !leftClamped) { if (IS_IN_AREA(mousePos, lbwSelMin, lbwSelMax)) { ImGui::SetMouseCursor(ImGuiMouseCursor_ResizeEW); } diff --git a/rtl_sdr_source/src/main.cpp b/rtl_sdr_source/src/main.cpp index 68076352..576a5044 100644 --- a/rtl_sdr_source/src/main.cpp +++ b/rtl_sdr_source/src/main.cpp @@ -296,7 +296,16 @@ private: static void tune(double freq, void* ctx) { RTLSDRSourceModule* _this = (RTLSDRSourceModule*)ctx; if (_this->running) { - rtlsdr_set_center_freq(_this->openDev, freq); + uint32_t newFreq = freq; + int i; + for (i = 0; i < 10; i++) { + rtlsdr_set_center_freq(_this->openDev, freq); + if (rtlsdr_get_center_freq(_this->openDev) == newFreq) { break; } + } + if (i > 1) { + spdlog::warn("RTL-SDR took {0} attempts to tune...", i); + } + } _this->freq = freq; spdlog::info("RTLSDRSourceModule '{0}': Tune: {1}!", _this->name, freq);