1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-23 01:55:48 -05:00

Fix power report and bandwidth widget.

This commit is contained in:
srcejon 2024-03-13 22:41:34 +00:00
parent 6a2a4d1281
commit eea3214ec0
4 changed files with 22 additions and 14 deletions

View File

@ -418,10 +418,10 @@ void ChannelPower::webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& resp
double magAvg, magPulseAvg, magMaxPeak, magMinPeak;
getMagLevels(magAvg, magPulseAvg, magMaxPeak, magMinPeak);
response.getChannelPowerReport()->setChannelPowerDb(CalcDb::dbPower(magAvg));
response.getChannelPowerReport()->setChannelPowerMaxDb(CalcDb::dbPower(magMaxPeak));
response.getChannelPowerReport()->setChannelPowerMinDb(CalcDb::dbPower(magMinPeak));
response.getChannelPowerReport()->setChannelPowerPulseDb(CalcDb::dbPower(magPulseAvg));
response.getChannelPowerReport()->setChannelPowerDb(CalcDb::dbPower(magAvg * magAvg));
response.getChannelPowerReport()->setChannelPowerMaxDb(CalcDb::dbPower(magMaxPeak * magMaxPeak));
response.getChannelPowerReport()->setChannelPowerMinDb(CalcDb::dbPower(magMinPeak * magMinPeak));
response.getChannelPowerReport()->setChannelPowerPulseDb(CalcDb::dbPower(magPulseAvg * magPulseAvg));
response.getChannelPowerReport()->setChannelSampleRate(m_basebandSink->getChannelSampleRate());
}

View File

@ -92,7 +92,7 @@ bool ChannelPowerGUI::handleMessage(const Message& message)
m_basebandSampleRate = notif.getSampleRate();
ui->deltaFrequency->setValueRange(false, 7, -m_basebandSampleRate/2, m_basebandSampleRate/2);
ui->deltaFrequencyLabel->setToolTip(tr("Range %1 %L2 Hz").arg(QChar(0xB1)).arg(m_basebandSampleRate/2));
ui->rfBW->setValueRange(false, ceil(log10(m_basebandSampleRate)), 0, m_basebandSampleRate);
ui->rfBW->setValueRange(floor(log10(m_basebandSampleRate))+1, 0, m_basebandSampleRate);
updateAbsoluteCenterFrequency();
return true;
}
@ -260,7 +260,7 @@ ChannelPowerGUI::ChannelPowerGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet,
ui->deltaFrequency->setValueRange(false, 7, -9999999, 9999999);
ui->rfBW->setColorMapper(ColorMapper(ColorMapper::GrayGold));
ui->rfBW->setValueRange(false, 7, -9999999, 9999999);
ui->rfBW->setValueRange(7, 0, 9999999);
m_channelMarker.blockSignals(true);
m_channelMarker.setColor(Qt::yellow);
@ -378,11 +378,13 @@ void ChannelPowerGUI::tick()
powDbMinPeak = std::numeric_limits<double>::quiet_NaN();
powDbPathLoss = std::numeric_limits<double>::quiet_NaN();
const int precision = 2;
if (!std::isnan(magAvg))
{
powDbAvg = CalcDb::dbPower(magAvg * magAvg);
if (m_tickCount % 4 == 0) {
ui->average->setText(QString::number(powDbAvg, 'f', 1));
ui->average->setText(QString::number(powDbAvg, 'f', precision));
}
}
else
@ -393,7 +395,7 @@ void ChannelPowerGUI::tick()
{
powDbPulseAvg = CalcDb::dbPower(magPulseAvg * magPulseAvg);
if (m_tickCount % 4 == 0) {
ui->pulseAverage->setText(QString::number(powDbPulseAvg, 'f', 1));
ui->pulseAverage->setText(QString::number(powDbPulseAvg, 'f', precision));
}
}
else
@ -404,7 +406,7 @@ void ChannelPowerGUI::tick()
{
powDbMaxPeak = CalcDb::dbPower(magMaxPeak * magMaxPeak);
if (m_tickCount % 4 == 0) {
ui->maxPeak->setText(QString::number(powDbMaxPeak, 'f', 1));
ui->maxPeak->setText(QString::number(powDbMaxPeak, 'f', precision));
}
}
else
@ -415,7 +417,7 @@ void ChannelPowerGUI::tick()
{
powDbMinPeak = CalcDb::dbPower(magMinPeak * magMinPeak);
if (m_tickCount % 4 == 0) {
ui->minPeak->setText(QString::number(powDbMinPeak, 'f', 1));
ui->minPeak->setText(QString::number(powDbMinPeak, 'f', precision));
}
}
else
@ -434,7 +436,7 @@ void ChannelPowerGUI::on_clearMeasurements_clicked()
void ChannelPowerGUI::makeUIConnections()
{
QObject::connect(ui->deltaFrequency, &ValueDialZ::changed, this, &ChannelPowerGUI::on_deltaFrequency_changed);
QObject::connect(ui->rfBW, &ValueDialZ::changed, this, &ChannelPowerGUI::on_rfBW_changed);
QObject::connect(ui->rfBW, &ValueDial::changed, this, &ChannelPowerGUI::on_rfBW_changed);
QObject::connect(ui->pulseTH, QOverload<int>::of(&QDial::valueChanged), this, &ChannelPowerGUI::on_pulseTH_valueChanged);
QObject::connect(ui->averagePeriod, QOverload<int>::of(&QDial::valueChanged), this, &ChannelPowerGUI::on_averagePeriod_valueChanged);
QObject::connect(ui->clearChannelPower, &QPushButton::clicked, this, &ChannelPowerGUI::on_clearMeasurements_clicked);

View File

@ -139,7 +139,7 @@
</widget>
</item>
<item>
<widget class="ValueDialZ" name="rfBW" native="true">
<widget class="ValueDial" name="rfBW" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
@ -589,6 +589,12 @@
<header>gui/valuedialz.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ValueDial</class>
<extends>QWidget</extends>
<header>gui/valuedial.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>deltaFrequency</tabstop>

View File

@ -33,7 +33,7 @@ ChannelPowerSettings::ChannelPowerSettings() :
void ChannelPowerSettings::resetToDefaults()
{
m_inputFrequencyOffset = 0;
m_rfBandwidth = 16000.0f;
m_rfBandwidth = 10000.0f;
m_pulseThreshold= -50.0f;
m_averagePeriodUS = 100000;
m_rgbColor = QColor(102, 40, 220).rgb();
@ -99,7 +99,7 @@ bool ChannelPowerSettings::deserialize(const QByteArray& data)
QString strtmp;
d.readS32(1, &m_inputFrequencyOffset, 0);
d.readFloat(2, &m_rfBandwidth, 16000.0f);
d.readFloat(2, &m_rfBandwidth, 10000.0f);
d.readFloat(3, &m_pulseThreshold, 50.0f);
d.readS32(4, &m_averagePeriodUS, 100000);