From 15a71df357a42c61631766aaa548ee3e7b0b53af Mon Sep 17 00:00:00 2001 From: Manuel Pitz Date: Wed, 23 Jun 2021 20:27:09 +0200 Subject: [PATCH] dft: make sure the dft mem is fully initalized --- lib/hooks/dft.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/hooks/dft.cpp b/lib/hooks/dft.cpp index 13b136b00..9f7e86e95 100644 --- a/lib/hooks/dft.cpp +++ b/lib/hooks/dft.cpp @@ -383,9 +383,13 @@ public: maxA = estimate.y; } +<<<<<<< HEAD if (dftCalcCnt > 1) { if (phasorFreq) phasorFreq->writeDataBinary(1, &maxF); +======= + if (windowSize < smpMemPos) { +>>>>>>> dft: make sure the dft mem is fully initalized smp->data[i * 4 + 0].f = maxF; /* Frequency */ smp->data[i * 4 + 1].f = (maxA / pow(2, 0.5)); /* Amplitude */ @@ -398,8 +402,10 @@ public: phasorAmplitude->writeData(1, &(smp->data[i * 4 + 1].f)); } } - dftCalcCnt++; - smp->length = signalIndex.size() * 4; + + smp->length = windowSize < smpMemPos ? signalIndex.size() * 4 : 0; + + dftCalcCount++; } if ((smp->sequence - lastSequence) > 1) @@ -407,7 +413,7 @@ public: lastSequence = smp->sequence; - if (runDft) + if(runDft && windowSize < smpMemPos) return Reason::OK; return Reason::SKIP_SAMPLE;