From afd5699ff1d8d7e75d01409c01d5b44c1372d80f Mon Sep 17 00:00:00 2001 From: Ryzerth Date: Mon, 11 Jan 2021 03:19:09 +0100 Subject: [PATCH] Added new contributors + fixed waterfall bug --- core/src/credits.cpp | 5 +++-- core/src/gui/widgets/waterfall.cpp | 32 ++++++++++++++++++++---------- readme.md | 3 ++- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/core/src/credits.cpp b/core/src/credits.cpp index 53b4df78..4f11e900 100644 --- a/core/src/credits.cpp +++ b/core/src/credits.cpp @@ -8,9 +8,10 @@ namespace sdrpp_credits { "Benjamin Kyd", "Cropinghigh", "Howard0su", - "Tobias Mädel", + "Martin Hauke", "Raov", - "Szymon Zakrent" + "Szymon Zakrent", + "Tobias Mädel" }; const char* libraries[] = { diff --git a/core/src/gui/widgets/waterfall.cpp b/core/src/gui/widgets/waterfall.cpp index dc23a1cd..9db2227a 100644 --- a/core/src/gui/widgets/waterfall.cpp +++ b/core/src/gui/widgets/waterfall.cpp @@ -537,11 +537,14 @@ namespace ImGui { float* WaterFall::getFFTBuffer() { if (rawFFTs == NULL) { return NULL; } buf_mtx.lock(); - currentFFTLine--; - fftLines++; - currentFFTLine = ((currentFFTLine + waterfallHeight) % waterfallHeight); - fftLines = std::min(fftLines, waterfallHeight); - return &rawFFTs[currentFFTLine * rawFFTSize]; + if (waterfallVisible) { + currentFFTLine--; + fftLines++; + currentFFTLine = ((currentFFTLine + waterfallHeight) % waterfallHeight); + fftLines = std::min(fftLines, waterfallHeight); + return &rawFFTs[currentFFTLine * rawFFTSize]; + } + return rawFFTs; } void WaterFall::pushFFT() { @@ -550,9 +553,10 @@ namespace ImGui { int drawDataSize = (viewBandwidth / wholeBandwidth) * rawFFTSize; int drawDataStart = (((double)rawFFTSize / 2.0) * (offsetRatio + 1)) - (drawDataSize / 2); - doZoom(drawDataStart, drawDataSize, dataWidth, &rawFFTs[currentFFTLine * rawFFTSize], latestFFT); + if (waterfallVisible) { + doZoom(drawDataStart, drawDataSize, dataWidth, &rawFFTs[currentFFTLine * rawFFTSize], latestFFT); memmove(&waterfallFb[dataWidth], waterfallFb, dataWidth * (waterfallHeight - 1) * sizeof(uint32_t)); float pixel; float dataRange = waterfallMax - waterfallMin; @@ -563,6 +567,10 @@ namespace ImGui { } waterfallUpdate = true; } + else { + doZoom(drawDataStart, drawDataSize, dataWidth, rawFFTs, latestFFT); + fftLines = 1; + } buf_mtx.unlock(); } @@ -745,10 +753,12 @@ namespace ImGui { std::lock_guard lck(buf_mtx); rawFFTSize = size; if (rawFFTs != NULL) { - rawFFTs = (float*)realloc(rawFFTs, rawFFTSize * waterfallHeight * sizeof(float)); + int wfSize = std::max(1, waterfallHeight); + rawFFTs = (float*)realloc(rawFFTs, rawFFTSize * wfSize * sizeof(float)); } else { - rawFFTs = (float*)malloc(rawFFTSize * waterfallHeight * sizeof(float)); + int wfSize = std::max(1, waterfallHeight); + rawFFTs = (float*)malloc(rawFFTSize * wfSize * sizeof(float)); } memset(rawFFTs, 0, rawFFTSize * waterfallHeight * sizeof(float)); } @@ -866,15 +876,17 @@ namespace ImGui { }; void WaterFall::showWaterfall() { - waterfallVisible = true; buf_mtx.lock(); + waterfallVisible = true; onResize(); + memset(rawFFTs, 0, waterfallHeight * rawFFTSize * sizeof(float)); + updateWaterfallFb(); buf_mtx.unlock(); } void WaterFall::hideWaterfall() { - waterfallVisible = false; buf_mtx.lock(); + waterfallVisible = false; onResize(); buf_mtx.unlock(); } diff --git a/readme.md b/readme.md index bc9053fd..4e8b6ad5 100644 --- a/readme.md +++ b/readme.md @@ -226,9 +226,10 @@ I will soon publish a contributing.md listing the code style to use. * [Benjamin Kyd](https://github.com/benkyd) * [cropinghigh](https://github.com/cropinghigh) * [Howard0su](https://github.com/howard0su) -* [Tobias Mädel](https://github.com/Manawyrm) +* [Martin Hauke](https://github.com/mnhauke) * [Raov](https://twitter.com/raov_birbtog) * [Szymon Zakrent](https://github.com/zakrent) +* [Tobias Mädel](https://github.com/Manawyrm) ## Libaries used