1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2025-09-02 13:17:48 -04:00

M17 demod: BER graph fixes

This commit is contained in:
f4exb 2022-07-08 15:00:21 +02:00
parent 3d00755438
commit 9c6ce3ad9e
2 changed files with 43 additions and 23 deletions

View File

@ -24,7 +24,7 @@
#include <QFileDialog> #include <QFileDialog>
#include <complex> #include <complex>
#include <math.h>
#include "device/deviceuiset.h" #include "device/deviceuiset.h"
#include "dsp/scopevisxy.h" #include "dsp/scopevisxy.h"
@ -719,8 +719,8 @@ void M17DemodGUI::tick()
{ {
uint32_t bertErrors, bertBits; uint32_t bertErrors, bertBits;
m_m17Demod->getBERT(bertErrors, bertBits); m_m17Demod->getBERT(bertErrors, bertBits);
uint32_t bertErrorsDelta = bertErrors - m_lastBERErrors; uint32_t bertErrorsDelta = bertErrors >= m_lastBERErrors ? bertErrors - m_lastBERErrors : 0;
uint32_t bertBitsDelta = bertBits - m_lastBERBits; uint32_t bertBitsDelta = bertBits >= m_lastBERBits ? bertBits - m_lastBERBits : 0;
m_lastBERErrors = bertErrors; m_lastBERErrors = bertErrors;
m_lastBERBits = bertBits; m_lastBERBits = bertBits;
@ -787,28 +787,38 @@ void M17DemodGUI::tick()
if (m_showBERNumbersOrRates) if (m_showBERNumbersOrRates)
{ {
berChartYAxis = new QValueAxis(); berChartYAxis = new QValueAxis();
if (min != 0) {
((QValueAxis*) berChartYAxis)->setMin(min);
}
if (max != 0) {
((QValueAxis*) berChartYAxis)->setMax(max);
}
} }
else else
{ {
berChartYAxis = new QLogValueAxis(); berChartYAxis = new QLogValueAxis();
((QLogValueAxis*) berChartYAxis)->setLabelFormat("%.2e"); ((QLogValueAxis*) berChartYAxis)->setLabelFormat("%.0e");
((QLogValueAxis*) berChartYAxis)->setBase(10.0); ((QLogValueAxis*) berChartYAxis)->setBase(10.0);
((QLogValueAxis*) berChartYAxis)->setMinorTickCount(-1); ((QLogValueAxis*) berChartYAxis)->setMinorTickCount(-1);
if (fmin != 0) { // make sure a major tick is always on the graph
((QLogValueAxis*) berChartYAxis)->setMin(fmin); if ((fmin != 0) && (fmax != 0))
} {
if (fmax < 10*fmin)
{
int lmin = log10(fmin);
int lmax = log10(fmax);
if (fmax != 0) { if (lmin == lmax)
((QLogValueAxis*) berChartYAxis)->setMax(fmax); {
((QLogValueAxis*) berChartYAxis)->setMin(fmin);
((QLogValueAxis*) berChartYAxis)->setMax(pow(10.0, lmin));
}
else
{
((QLogValueAxis*) berChartYAxis)->setMin(fmin);
((QLogValueAxis*) berChartYAxis)->setMax(fmax);
}
}
else
{
((QLogValueAxis*) berChartYAxis)->setMin(fmin);
((QLogValueAxis*) berChartYAxis)->setMax(fmax);
}
} }
} }
@ -834,7 +844,7 @@ QString M17DemodGUI::getStatus(int status, int sync_word_type, bool streamElsePa
{ {
if (status == 0) { if (status == 0) {
return "Unlocked"; return "Unlocked";
} else if ((status == 5) && (sync_word_type == 3)) { } else if (((status == 5) || (status == 4)) && (sync_word_type == 3)) {
return "BERT"; return "BERT";
} else if (streamElsePacket) { } else if (streamElsePacket) {
return "Stream"; return "Stream";
@ -912,9 +922,14 @@ QLineSeries *M17DemodGUI::addBERSeriesRate(bool total, qreal& min, qreal& max)
if ((berPoint.m_totalErrors != 0) && (berPoint.m_totalBits != 0)) if ((berPoint.m_totalErrors != 0) && (berPoint.m_totalBits != 0))
{ {
qreal y = ((qreal) berPoint.m_totalErrors) / ((qreal) berPoint.m_totalBits); qreal y = ((qreal) berPoint.m_totalErrors) / ((qreal) berPoint.m_totalBits);
min = std::min(min, y);
max = std::max(max, y);
series->append(x, y); series->append(x, y);
max = std::max(max, y);
if (min == 0) {
min = y;
} else {
min = std::min(min, y);
}
} }
} }
else else
@ -922,9 +937,14 @@ QLineSeries *M17DemodGUI::addBERSeriesRate(bool total, qreal& min, qreal& max)
if ((berPoint.m_currentErrors != 0) && (berPoint.m_currentBits != 0)) if ((berPoint.m_currentErrors != 0) && (berPoint.m_currentBits != 0))
{ {
qreal y = ((qreal) berPoint.m_currentErrors) / ((qreal) berPoint.m_currentBits); qreal y = ((qreal) berPoint.m_currentErrors) / ((qreal) berPoint.m_currentBits);
min = std::min(min, y);
max = std::max(max, y);
series->append(x, y); series->append(x, y);
max = std::max(max, y);
if (min == 0) {
min = y;
} else {
min = std::min(min, y);
}
} }
} }
} }

View File

@ -138,7 +138,7 @@ void M17DemodProcessor::diagnostic_callback(
qDebug() << "M17DemodProcessor::diagnostic_callback: " << oss.str().c_str(); qDebug() << "M17DemodProcessor::diagnostic_callback: " << oss.str().c_str();
} }
if ((!dcd) || (status == 0)) { // && m_this->m_prbs.sync()) { // Seems like there should be a better way to do this. if ((!dcd) && m_this->m_prbs.sync()) { // Seems like there should be a better way to do this.
m_this->m_prbs.reset(); m_this->m_prbs.reset();
} }