From bc00a46200b92ee202055e299ee70d1a855371c6 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Thu, 14 Nov 2024 00:21:18 +0000 Subject: [PATCH] Skip replot() if taking too long --- spectrumscope.cpp | 29 +++++++++++++++++------------ spectrumscope.h | 1 + wfmain.cpp | 4 ++-- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/spectrumscope.cpp b/spectrumscope.cpp index 20d7aebd..4f528f2e 100644 --- a/spectrumscope.cpp +++ b/spectrumscope.cpp @@ -432,6 +432,7 @@ spectrumScope::spectrumScope(bool scope, uchar receiver, uchar vfo, QWidget *par connect(spectrum, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(scroll(QWheelEvent*))); showHideControls(spectrumMode_t::spectModeCenter); + lastData.start(); } @@ -672,11 +673,7 @@ bool spectrumScope::updateScope(scopeData data) showBandIndicators(true); } - qint64 spectime = 0; - - QElapsedTimer elapsed; - QElapsedTimer totalUpdateTime; - totalUpdateTime.start(); + //qint64 spectime = 0; bool updateRange = false; @@ -857,9 +854,6 @@ bool spectrumScope::updateScope(scopeData data) spectrum->yAxis->setRange(plotFloor, plotCeiling); spectrum->xAxis->setRange(data.startFreq, data.endFreq); - elapsed.start(); - spectrum->replot(); - spectime = elapsed.elapsed(); if(specLen == spectWidth) { @@ -882,9 +876,20 @@ bool spectrumScope::updateScope(scopeData data) waterfall->yAxis->setRange(0,wfLength - 1); waterfall->xAxis->setRange(0, spectWidth-1); - elapsed.start(); - waterfall->replot(); - redrawSpeed->setText(QString("%0ms/%1ms").arg(spectime).arg(totalUpdateTime.elapsed())); + + int spectrumTime = static_cast(spectrum->replotTime(false)); + int waterfallTime = static_cast(waterfall->replotTime(false)); + QString missed = ""; + + if (lastData.elapsed() > spectrumTime && lastData.elapsed() > waterfallTime) + { + spectrum->replot(); + waterfall->replot(); + lastData.restart(); + } else { + missed = "*"; + } + redrawSpeed->setText(QString("%0%1ms/%2ms").arg(missed).arg(spectrumTime).arg(waterfallTime)); /* #if defined (USB_CONTROLLER) @@ -918,7 +923,7 @@ bool spectrumScope::updateScope(scopeData data) oorIndicator->setVisible(false); } - emit elapsedTime(receiver, elapsed.elapsed()); + //emit elapsedTime(receiver, elapsed.elapsed()); return true; } diff --git a/spectrumscope.h b/spectrumscope.h index a5afea18..83f508c8 100644 --- a/spectrumscope.h +++ b/spectrumscope.h @@ -306,6 +306,7 @@ private: bool bandIndicatorsVisible=false; rigCapabilities* rigCaps=Q_NULLPTR; bandType currentBand; + QElapsedTimer lastData; }; #endif // SPECTRUMSCOPE_H diff --git a/wfmain.cpp b/wfmain.cpp index ae5ab5ff..e5a40263 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -3578,9 +3578,9 @@ void wfmain:: getInitialRigState() // Only show settingsgroup if rig has sub - ui->scopeSettingsGroup->setVisible(rigCaps->commands.contains(funcScopeWaveData)); + ui->scopeSettingsGroup->setVisible(rigCaps->commands.contains(funcScopeMainSub)); - ui->scopeDualBtn->setVisible(rigCaps->commands.contains(funcScopeSingleDual)); + ui->scopeDualBtn->setVisible(rigCaps->commands.contains(funcVFODualWatch)); ui->antennaGroup->setVisible(rigCaps->commands.contains(funcAntenna)); ui->preampAttGroup->setVisible(rigCaps->commands.contains(funcPreamp));