kopia lustrzana https://github.com/PianetaRadio/CatRadio
rodzic
8ee38b8b3a
commit
c22d15ea35
|
@ -3,7 +3,7 @@ CatRadio
|
|||
(+ New, * Updated, - Removed)
|
||||
|
||||
1.4.0 - 2023-mm-dd
|
||||
+ Meter peak indicator
|
||||
+ Meter peak hold indicator
|
||||
+ Debug mode
|
||||
* Power status improvement
|
||||
* Bug fix: COM port list
|
||||
|
|
|
@ -174,6 +174,8 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
ui->progressBar_Smeter->setValue(-54);
|
||||
ui->progressBar_Smeter->resetPeakValue();
|
||||
ui->progressBar_Smeter->setPeakFactor(rigCom.rigRefresh/1000.0);
|
||||
ui->progressBar_subMeter->resetPeakValue();
|
||||
ui->progressBar_subMeter->setPeakFactor(rigCom.rigRefresh/1000.0);
|
||||
|
||||
//VFO
|
||||
ui->lineEdit_vfoMain->setValue(0);
|
||||
|
@ -277,6 +279,7 @@ void MainWindow::guiInit()
|
|||
//* Meters & Sub-meter comboBox
|
||||
//ui->progressBar_Smeter->setMaxValue(5); //FIXME tx_range_list
|
||||
ui->progressBar_Smeter->setPeak(guiConf.peakHold);
|
||||
ui->progressBar_subMeter->setPeak(guiConf.peakHold);
|
||||
ui->comboBox_Meter->clear();
|
||||
if (rig_has_get_level(my_rig, RIG_METER_SWR)) ui->comboBox_Meter->addItem("SWR");
|
||||
if (rig_has_get_level(my_rig, RIG_METER_ALC)) ui->comboBox_Meter->addItem("ALC");
|
||||
|
@ -702,6 +705,8 @@ void MainWindow::setSubMeter()
|
|||
ui->progressBar_subMeter->setShortStep(0.1);
|
||||
ui->progressBar_subMeter->setValue(0);
|
||||
}
|
||||
|
||||
ui->progressBar_subMeter->resetPeakValue();
|
||||
}
|
||||
|
||||
|
||||
|
|
54
submeter.cpp
54
submeter.cpp
|
@ -20,7 +20,6 @@
|
|||
#include "submeter.h"
|
||||
#include <QPainter>
|
||||
#include <math.h>
|
||||
#include <QDebug>
|
||||
|
||||
SubMeter::SubMeter(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
|
@ -40,6 +39,10 @@ SubMeter::SubMeter(QWidget *parent) : QWidget(parent)
|
|||
meterSWR = 0;
|
||||
|
||||
currentValue = 0;
|
||||
peakValue = minValue;
|
||||
peakFactor = 0.1;
|
||||
|
||||
peakHold = true;
|
||||
}
|
||||
|
||||
void SubMeter::paintEvent(QPaintEvent *)
|
||||
|
@ -54,6 +57,7 @@ void SubMeter::paintEvent(QPaintEvent *)
|
|||
|
||||
drawMeter(&painter);
|
||||
drawProgress(&painter);
|
||||
if (peakHold) drawPeak(&painter);
|
||||
drawScale(&painter);
|
||||
}
|
||||
|
||||
|
@ -116,6 +120,38 @@ void SubMeter::drawProgress(QPainter *painter)
|
|||
painter->restore();
|
||||
}
|
||||
|
||||
void SubMeter::drawPeak(QPainter *painter)
|
||||
{
|
||||
double max, min;
|
||||
double gate;
|
||||
|
||||
painter->save();
|
||||
painter->setPen(Qt::NoPen);
|
||||
|
||||
max = maxValue;
|
||||
min = minValue;
|
||||
gate = gateValue;
|
||||
if (meterSWR) min = 1; //SWR meter
|
||||
|
||||
double length = width()-14;
|
||||
double increment = length / (max - min);
|
||||
double initX;
|
||||
|
||||
if (currentValue>=peakValue) peakValue = currentValue;
|
||||
else peakValue = peakValue - peakFactor*(peakValue - currentValue);
|
||||
if (peakValue>max) peakValue = max;
|
||||
|
||||
if (peakValue>gate) painter->setBrush(QColor(Qt::red));
|
||||
else painter->setBrush(progressColor);
|
||||
|
||||
initX = (peakValue - min) * increment;
|
||||
|
||||
QRect rect(initX - 2, height()/3+2+1, 2, height()/3-4-2);
|
||||
painter->drawRect(rect);
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
void SubMeter::drawScale(QPainter *painter)
|
||||
{
|
||||
painter->save();
|
||||
|
@ -276,3 +312,19 @@ void SubMeter::setMeterSWR(bool swr)
|
|||
{
|
||||
meterSWR = swr;
|
||||
}
|
||||
|
||||
void SubMeter::setPeak(bool Peak)
|
||||
{
|
||||
peakHold = Peak;
|
||||
}
|
||||
|
||||
void SubMeter::setPeakFactor(double factor)
|
||||
{
|
||||
peakFactor = factor;
|
||||
}
|
||||
|
||||
void SubMeter::resetPeakValue()
|
||||
{
|
||||
if (!meterSWR) peakValue = minValue;
|
||||
else peakValue = 1.0;
|
||||
}
|
||||
|
|
|
@ -46,10 +46,15 @@ public slots:
|
|||
|
||||
void setMeterSWR(bool swr);
|
||||
|
||||
void setPeak(bool Peak);
|
||||
void setPeakFactor(double factor);
|
||||
void resetPeakValue();
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *);
|
||||
void drawMeter(QPainter *painter);
|
||||
void drawProgress(QPainter *painter);
|
||||
void drawPeak(QPainter *painter);
|
||||
void drawScale(QPainter *painter);
|
||||
|
||||
private:
|
||||
|
@ -64,6 +69,10 @@ private:
|
|||
|
||||
double value; //target value
|
||||
double currentValue; //current value
|
||||
double peakValue; //peak value
|
||||
double peakFactor; //peak factor
|
||||
|
||||
bool peakHold; //Peak hold
|
||||
|
||||
QColor bgColor; //background color
|
||||
QColor lineColor; //line color
|
||||
|
|
Ładowanie…
Reference in New Issue