SSB demod: show LSB and DSB values appropriately

This commit is contained in:
f4exb 2017-07-22 04:23:10 +02:00
parent dd4ab0f0b5
commit de74f27c9a
5 changed files with 79 additions and 56 deletions

View File

@ -162,7 +162,20 @@ void SSBDemodGUI::on_dsb_toggled(bool dsb)
{ {
m_dsb = dsb; m_dsb = dsb;
if (!m_dsb) if (m_dsb)
{
if (ui->BW->value() < 0) {
ui->BW->setValue(-ui->BW->value());
}
m_channelMarker.setSidebands(ChannelMarker::dsb);
QString bwStr = QString::number(ui->BW->value()/10.0, 'f', 1);
ui->BWText->setText(tr("%1%2k").arg(QChar(0xB1, 0x00)).arg(bwStr));
ui->lowCut->setValue(0);
ui->lowCut->setEnabled(false);
}
else
{ {
if (ui->BW->value() < 0) { if (ui->BW->value() < 0) {
m_channelMarker.setSidebands(ChannelMarker::lsb); m_channelMarker.setSidebands(ChannelMarker::lsb);
@ -170,20 +183,12 @@ void SSBDemodGUI::on_dsb_toggled(bool dsb)
m_channelMarker.setSidebands(ChannelMarker::usb); m_channelMarker.setSidebands(ChannelMarker::usb);
} }
ui->glSpectrum->setCenterFrequency(m_rate/4); QString bwStr = QString::number(ui->BW->value()/10.0, 'f', 1);
ui->glSpectrum->setSampleRate(m_rate/2); ui->BWText->setText(tr("%1k").arg(bwStr));
ui->glSpectrum->setSsbSpectrum(true); ui->lowCut->setEnabled(true);
on_lowCut_valueChanged(m_channelMarker.getLowCutoff()/100); on_lowCut_valueChanged(m_channelMarker.getLowCutoff()/100);
} }
else
{
m_channelMarker.setSidebands(ChannelMarker::dsb);
ui->glSpectrum->setCenterFrequency(0);
ui->glSpectrum->setSampleRate(m_rate);
ui->glSpectrum->setSsbSpectrum(false);
}
applySettings(); applySettings();
setNewRate(m_spanLog2); setNewRate(m_spanLog2);
@ -197,27 +202,19 @@ void SSBDemodGUI::on_deltaFrequency_changed(qint64 value)
void SSBDemodGUI::on_BW_valueChanged(int value) void SSBDemodGUI::on_BW_valueChanged(int value)
{ {
QString s = QString::number(value/10.0, 'f', 1); QString s = QString::number(value/10.0, 'f', 1);
ui->BWText->setText(tr("%1k").arg(s));
m_channelMarker.setBandwidth(value * 100 * 2); m_channelMarker.setBandwidth(value * 100 * 2);
if (!m_dsb) if (m_dsb)
{ {
if (value < 0) ui->BWText->setText(tr("%1%2k").arg(QChar(0xB1, 0x00)).arg(s));
{
m_channelMarker.setSidebands(ChannelMarker::lsb);
} }
else else
{ {
m_channelMarker.setSidebands(ChannelMarker::usb); ui->BWText->setText(tr("%1k").arg(s));
} }
}
else
{
m_channelMarker.setSidebands(ChannelMarker::dsb);
}
on_lowCut_valueChanged(m_channelMarker.getLowCutoff()/100); on_lowCut_valueChanged(m_channelMarker.getLowCutoff()/100);
setNewRate(m_spanLog2);
} }
int SSBDemodGUI::getEffectiveLowCutoff(int lowCutoff) int SSBDemodGUI::getEffectiveLowCutoff(int lowCutoff)
@ -333,11 +330,8 @@ SSBDemodGUI::SSBDemodGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidg
ui->deltaFrequency->setValueRange(false, 7, -9999999, 9999999); ui->deltaFrequency->setValueRange(false, 7, -9999999, 9999999);
ui->channelPowerMeter->setColorTheme(LevelMeterSignalDB::ColorGreenAndBlue); ui->channelPowerMeter->setColorTheme(LevelMeterSignalDB::ColorGreenAndBlue);
ui->glSpectrum->setCenterFrequency(m_rate/2);
ui->glSpectrum->setSampleRate(m_rate);
ui->glSpectrum->setDisplayWaterfall(true); ui->glSpectrum->setDisplayWaterfall(true);
ui->glSpectrum->setDisplayMaxHold(true); ui->glSpectrum->setDisplayMaxHold(true);
ui->glSpectrum->setSsbSpectrum(true);
ui->glSpectrum->connectTimer(m_pluginAPI->getMainWindow()->getMasterTimer()); ui->glSpectrum->connectTimer(m_pluginAPI->getMainWindow()->getMasterTimer());
connect(&m_pluginAPI->getMainWindow()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick())); connect(&m_pluginAPI->getMainWindow()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick()));
@ -405,35 +399,46 @@ bool SSBDemodGUI::setNewRate(int spanLog2)
m_channelMarker.setLowCutoff(m_rate); m_channelMarker.setLowCutoff(m_rate);
} }
ui->BW->setMinimum(-m_rate/100);
ui->lowCut->setMinimum(-m_rate/100);
ui->BW->setMaximum(m_rate/100);
ui->lowCut->setMaximum(m_rate/100);
QString s = QString::number(m_rate/1000.0, 'f', 1); QString s = QString::number(m_rate/1000.0, 'f', 1);
ui->spanText->setText(tr("%1k").arg(s));
//ui->glSpectrum->setCenterFrequency(m_rate/2); if (m_dsb)
//ui->glSpectrum->setSampleRate(m_rate);
if (!m_dsb)
{ {
if (ui->BW->value() < 0) { ui->BW->setMinimum(0);
m_channelMarker.setSidebands(ChannelMarker::lsb); ui->BW->setMaximum(m_rate/100);
} else { ui->lowCut->setMinimum(0);
m_channelMarker.setSidebands(ChannelMarker::usb); ui->lowCut->setMaximum(m_rate/100);
}
ui->glSpectrum->setCenterFrequency(m_rate/2);
ui->glSpectrum->setSampleRate(m_rate);
ui->glSpectrum->setSsbSpectrum(true);
}
else
{
m_channelMarker.setSidebands(ChannelMarker::dsb); m_channelMarker.setSidebands(ChannelMarker::dsb);
ui->spanText->setText(tr("%1%2k").arg(QChar(0xB1, 0x00)).arg(s));
ui->glSpectrum->setCenterFrequency(0); ui->glSpectrum->setCenterFrequency(0);
ui->glSpectrum->setSampleRate(2*m_rate); ui->glSpectrum->setSampleRate(2*m_rate);
ui->glSpectrum->setSsbSpectrum(false); ui->glSpectrum->setSsbSpectrum(false);
ui->glSpectrum->setLsbDisplay(false);
}
else
{
ui->BW->setMinimum(-m_rate/100);
ui->BW->setMaximum(m_rate/100);
ui->lowCut->setMinimum(-m_rate/100);
ui->lowCut->setMaximum(m_rate/100);
if (ui->BW->value() < 0)
{
m_channelMarker.setSidebands(ChannelMarker::lsb);
ui->glSpectrum->setLsbDisplay(true);
}
else
{
m_channelMarker.setSidebands(ChannelMarker::usb);
ui->glSpectrum->setLsbDisplay(false);
}
ui->spanText->setText(tr("%1k").arg(s));
ui->glSpectrum->setCenterFrequency(m_rate/2);
ui->glSpectrum->setSampleRate(m_rate);
ui->glSpectrum->setSsbSpectrum(true);
} }
return true; return true;

View File

@ -52,6 +52,7 @@ GLSpectrum::GLSpectrum(QWidget* parent) :
m_waterfallTexturePos(0), m_waterfallTexturePos(0),
m_displayWaterfall(true), m_displayWaterfall(true),
m_ssbSpectrum(false), m_ssbSpectrum(false),
m_lsbDisplay(false),
m_histogramBuffer(NULL), m_histogramBuffer(NULL),
m_histogram(NULL), m_histogram(NULL),
m_histogramHoldoff(NULL), m_histogramHoldoff(NULL),
@ -140,7 +141,7 @@ GLSpectrum::~GLSpectrum()
} }
} }
void GLSpectrum::setCenterFrequency(quint64 frequency) void GLSpectrum::setCenterFrequency(qint64 frequency)
{ {
m_centerFrequency = frequency; m_centerFrequency = frequency;
m_changesPending = true; m_changesPending = true;
@ -209,6 +210,12 @@ void GLSpectrum::setSsbSpectrum(bool ssbSpectrum)
update(); update();
} }
void GLSpectrum::setLsbDisplay(bool lsbDisplay)
{
m_lsbDisplay = lsbDisplay;
update();
}
void GLSpectrum::setInvertedWaterfall(bool inv) void GLSpectrum::setInvertedWaterfall(bool inv)
{ {
m_invertedWaterfall = inv; m_invertedWaterfall = inv;
@ -1059,6 +1066,7 @@ void GLSpectrum::applyChanges()
m_frequencyScale.setSize(width() - leftMargin - rightMargin); m_frequencyScale.setSize(width() - leftMargin - rightMargin);
m_frequencyScale.setRange(Unit::Frequency, m_centerFrequency - m_sampleRate / 2, m_centerFrequency + m_sampleRate / 2); m_frequencyScale.setRange(Unit::Frequency, m_centerFrequency - m_sampleRate / 2, m_centerFrequency + m_sampleRate / 2);
m_frequencyScale.setMakeOpposite(m_lsbDisplay);
m_glWaterfallBoxMatrix.setToIdentity(); m_glWaterfallBoxMatrix.setToIdentity();
m_glWaterfallBoxMatrix.translate( m_glWaterfallBoxMatrix.translate(
@ -1155,6 +1163,7 @@ void GLSpectrum::applyChanges()
m_frequencyScale.setSize(width() - leftMargin - rightMargin); m_frequencyScale.setSize(width() - leftMargin - rightMargin);
m_frequencyScale.setRange(Unit::Frequency, m_centerFrequency - m_sampleRate / 2.0, m_centerFrequency + m_sampleRate / 2.0); m_frequencyScale.setRange(Unit::Frequency, m_centerFrequency - m_sampleRate / 2.0, m_centerFrequency + m_sampleRate / 2.0);
m_frequencyScale.setMakeOpposite(m_lsbDisplay);
m_glWaterfallBoxMatrix.setToIdentity(); m_glWaterfallBoxMatrix.setToIdentity();
m_glWaterfallBoxMatrix.translate( m_glWaterfallBoxMatrix.translate(
@ -1206,6 +1215,7 @@ void GLSpectrum::applyChanges()
m_frequencyScale.setSize(width() - leftMargin - rightMargin); m_frequencyScale.setSize(width() - leftMargin - rightMargin);
m_frequencyScale.setRange(Unit::Frequency, m_centerFrequency - m_sampleRate / 2, m_centerFrequency + m_sampleRate / 2); m_frequencyScale.setRange(Unit::Frequency, m_centerFrequency - m_sampleRate / 2, m_centerFrequency + m_sampleRate / 2);
m_frequencyScale.setMakeOpposite(m_lsbDisplay);
m_glHistogramSpectrumMatrix.setToIdentity(); m_glHistogramSpectrumMatrix.setToIdentity();
m_glHistogramSpectrumMatrix.translate( m_glHistogramSpectrumMatrix.translate(

View File

@ -43,7 +43,7 @@ public:
GLSpectrum(QWidget* parent = NULL); GLSpectrum(QWidget* parent = NULL);
~GLSpectrum(); ~GLSpectrum();
void setCenterFrequency(quint64 frequency); void setCenterFrequency(qint64 frequency);
void setSampleRate(qint32 sampleRate); void setSampleRate(qint32 sampleRate);
void setReferenceLevel(Real referenceLevel); void setReferenceLevel(Real referenceLevel);
void setPowerRange(Real powerRange); void setPowerRange(Real powerRange);
@ -52,6 +52,7 @@ public:
void setHistoStroke(int stroke); void setHistoStroke(int stroke);
void setDisplayWaterfall(bool display); void setDisplayWaterfall(bool display);
void setSsbSpectrum(bool ssbSpectrum); void setSsbSpectrum(bool ssbSpectrum);
void setLsbDisplay(bool lsbDisplay);
void setInvertedWaterfall(bool inv); void setInvertedWaterfall(bool inv);
void setDisplayMaxHold(bool display); void setDisplayMaxHold(bool display);
void setDisplayCurrent(bool display); void setDisplayCurrent(bool display);
@ -140,6 +141,7 @@ private:
QMatrix4x4 m_glWaterfallBoxMatrix; QMatrix4x4 m_glWaterfallBoxMatrix;
bool m_displayWaterfall; bool m_displayWaterfall;
bool m_ssbSpectrum; bool m_ssbSpectrum;
bool m_lsbDisplay;
QRgb m_histogramPalette[240]; QRgb m_histogramPalette[240];
QImage* m_histogramBuffer; QImage* m_histogramBuffer;

View File

@ -29,9 +29,12 @@ static double trunc(double d)
QString ScaleEngine::formatTick(double value, int decimalPlaces, bool fancyTime) QString ScaleEngine::formatTick(double value, int decimalPlaces, bool fancyTime)
{ {
if((m_physicalUnit != Unit::Time) || (!fancyTime) || 1) { if((m_physicalUnit != Unit::Time) || (!fancyTime) || 1)
return QString("%1").arg(value, 0, 'f', decimalPlaces); {
} else { return QString("%1").arg(m_makeOpposite ? -value : value, 0, 'f', decimalPlaces);
}
else
{
QString str; QString str;
double orig = fabs(value); double orig = fabs(value);
double tmp; double tmp;
@ -60,7 +63,7 @@ QString ScaleEngine::formatTick(double value, int decimalPlaces, bool fancyTime)
value *= -1.0; value *= -1.0;
} }
tmp = value; tmp = m_makeOpposite ? -value : value;
str += QString("%1").arg(tmp, 2, 'f', decimalPlaces, QChar('0')); str += QString("%1").arg(tmp, 2, 'f', decimalPlaces, QChar('0'));
return str; return str;
@ -496,7 +499,8 @@ ScaleEngine::ScaleEngine() :
m_majorTickValueDistance(1.0), m_majorTickValueDistance(1.0),
m_firstMajorTickValue(1.0), m_firstMajorTickValue(1.0),
m_numMinorTicks(1), m_numMinorTicks(1),
m_decimalPlaces(1) m_decimalPlaces(1),
m_makeOpposite(false)
{ {
} }

View File

@ -56,6 +56,7 @@ private:
double m_firstMajorTickValue; double m_firstMajorTickValue;
int m_numMinorTicks; int m_numMinorTicks;
int m_decimalPlaces; int m_decimalPlaces;
bool m_makeOpposite; // will show -value instead of value
QString formatTick(double value, int decimalPlaces, bool fancyTime = true); QString formatTick(double value, int decimalPlaces, bool fancyTime = true);
void calcCharSize(); void calcCharSize();
@ -76,6 +77,7 @@ public:
void setSize(float size); void setSize(float size);
float getSize() { return m_size; } float getSize() { return m_size; }
void setRange(Unit::Physical physicalUnit, float rangeMin, float rangeMax); void setRange(Unit::Physical physicalUnit, float rangeMin, float rangeMax);
void setMakeOpposite(bool makeOpposite) { m_makeOpposite = makeOpposite; }
float getPosFromValue(double value); float getPosFromValue(double value);
float getValueFromPos(double pos); float getValueFromPos(double pos);