From 18994840a5624471c4947126d59d6b263223082e Mon Sep 17 00:00:00 2001 From: PianetaRadio <78976006+PianetaRadio@users.noreply.github.com> Date: Wed, 22 Mar 2023 19:43:42 +0100 Subject: [PATCH] Peak hold submeter #35 --- dialogsetup.cpp | 1 + submeter.cpp | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/dialogsetup.cpp b/dialogsetup.cpp index 399e71e..301e1ab 100644 --- a/dialogsetup.cpp +++ b/dialogsetup.cpp @@ -42,6 +42,7 @@ void DialogSetup::on_buttonBox_accepted() guiConf.vfoDisplayMode = ui->radioButton_vfoDispMode_UD->isChecked(); guiConf.darkTheme = ui->radioButton_themeDark->isChecked(); + guiConf.peakHold = ui->checkBox_peakHold->isChecked(); guiConf.debugMode = ui->checkBox_debug->isChecked(); //* Save settings in catradio.ini diff --git a/submeter.cpp b/submeter.cpp index 0676ac9..f97c141 100644 --- a/submeter.cpp +++ b/submeter.cpp @@ -134,7 +134,7 @@ void SubMeter::drawPeak(QPainter *painter) if (meterSWR) min = 1; //SWR meter double length = width()-14; - double increment = length / (max - min); + double increment; double initX; if (currentValue>=peakValue) peakValue = currentValue; @@ -144,7 +144,17 @@ void SubMeter::drawPeak(QPainter *painter) if (peakValue>gate) painter->setBrush(QColor(Qt::red)); else painter->setBrush(progressColor); - initX = (peakValue - min) * increment; + if (meterSWR) + { + increment = length / (10 * log10(maxValue)); + initX = 10 * log10(peakValue) * increment; + } + else + { + increment = length / (max - min); + initX = (peakValue - min) * increment; + } + //initX = (peakValue - min) * increment; QRect rect(initX - 2, height()/3+2+1, 2, height()/3-4-2); painter->drawRect(rect);