From 7333519f602f91500853827bb059c52d8419a899 Mon Sep 17 00:00:00 2001 From: Alex Spataru Date: Tue, 19 Oct 2021 01:24:19 -0500 Subject: [PATCH] Enforce minimum FFT sample size --- assets/qml/JsonEditor/JsonDatasetDelegate.qml | 2 +- src/JSON/Dataset.cpp | 1 + src/Widgets/FFTPlot.cpp | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/assets/qml/JsonEditor/JsonDatasetDelegate.qml b/assets/qml/JsonEditor/JsonDatasetDelegate.qml index 49002977..1948cb15 100644 --- a/assets/qml/JsonEditor/JsonDatasetDelegate.qml +++ b/assets/qml/JsonEditor/JsonDatasetDelegate.qml @@ -193,7 +193,7 @@ Widgets.Window { text: Cpp_JSON_Editor.datasetFFTSamples(group, dataset) onTextChanged: Cpp_JSON_Editor.setDatasetFFTSamples(group, dataset, parseInt(text)) validator: IntValidator { - bottom: 128 + bottom: 8 top: 40 * 1000 } } diff --git a/src/JSON/Dataset.cpp b/src/JSON/Dataset.cpp index eefdc5b4..e81790d7 100644 --- a/src/JSON/Dataset.cpp +++ b/src/JSON/Dataset.cpp @@ -38,6 +38,7 @@ Dataset::Dataset(QObject *parent) , m_max("0") , m_min("0") , m_alarm("0") + , m_fftSamples(8) { } diff --git a/src/Widgets/FFTPlot.cpp b/src/Widgets/FFTPlot.cpp index 21481fa2..fec6fc14 100644 --- a/src/Widgets/FFTPlot.cpp +++ b/src/Widgets/FFTPlot.cpp @@ -93,7 +93,7 @@ FFTPlot::FFTPlot(const int index) if (dataset) { // Calculate FFT size - int size = dataset->fftSamples(); + int size = qMax(8, dataset->fftSamples()); // Ensure that FFT size is valid while (m_transformer.setSize(size) != QFourierTransformer::FixedSize)