diff --git a/sdrbase/dsp/spectrumcalibrationpoint.cpp b/sdrbase/dsp/spectrumcalibrationpoint.cpp index 8761da5b1..0e9a997ce 100644 --- a/sdrbase/dsp/spectrumcalibrationpoint.cpp +++ b/sdrbase/dsp/spectrumcalibrationpoint.cpp @@ -24,7 +24,7 @@ QByteArray SpectrumCalibrationPoint::serialize() const s.writeS64(1, m_frequency); s.writeFloat(2, m_powerRelativeReference); - s.writeFloat(3, m_powerAbsoluteReference); + s.writeFloat(3, m_powerCalibratedReference); return s.final(); } @@ -41,7 +41,7 @@ bool SpectrumCalibrationPoint::deserialize(const QByteArray& data) { d.readS64(1, &m_frequency, 0); d.readFloat(2, &m_powerRelativeReference, 1.0f); - d.readFloat(3, &m_powerAbsoluteReference, 1.0f); + d.readFloat(3, &m_powerCalibratedReference, 1.0f); return true; } diff --git a/sdrbase/dsp/spectrumcalibrationpoint.h b/sdrbase/dsp/spectrumcalibrationpoint.h index 2b0c65b28..14291209c 100644 --- a/sdrbase/dsp/spectrumcalibrationpoint.h +++ b/sdrbase/dsp/spectrumcalibrationpoint.h @@ -25,13 +25,13 @@ struct SDRBASE_API SpectrumCalibrationPoint { qint64 m_frequency; //!< frequency in Hz - float m_powerRelativeReference; //!< relative power level on 0..1 scale - float m_powerAbsoluteReference; //!< absolute power level in mW + float m_powerRelativeReference; //!< relative power level on 0..1 scale + float m_powerCalibratedReference; //!< calibrated power level on 0..x scale. x limited to 10000 (40dB) in the GUI. SpectrumCalibrationPoint() : m_frequency(0), m_powerRelativeReference(1.0f), - m_powerAbsoluteReference(1.0f) + m_powerCalibratedReference(1.0f) {} SpectrumCalibrationPoint( @@ -41,7 +41,7 @@ struct SDRBASE_API SpectrumCalibrationPoint ) : m_frequency(frequency), m_powerRelativeReference(powerRelativeReference), - m_powerAbsoluteReference(powerAbsoluteReference) + m_powerCalibratedReference(powerAbsoluteReference) {} SpectrumCalibrationPoint(const SpectrumCalibrationPoint& other) = default; diff --git a/sdrbase/dsp/spectrumsettings.cpp b/sdrbase/dsp/spectrumsettings.cpp index 95fc978a0..1d0502689 100644 --- a/sdrbase/dsp/spectrumsettings.cpp +++ b/sdrbase/dsp/spectrumsettings.cpp @@ -62,6 +62,8 @@ void SpectrumSettings::resetToDefaults() m_wsSpectrumAddress = "127.0.0.1"; m_wsSpectrumPort = 8887; m_markersDisplay = MarkersDisplayNone; + m_useCalibration = false; + m_calibrationInterpMode = CalibInterpLinear; } QByteArray SpectrumSettings::serialize() const @@ -95,6 +97,8 @@ QByteArray SpectrumSettings::serialize() const s.writeS32(26, m_fpsPeriodMs); s.writeBool(27, m_wsSpectrum); s.writeS32(28, (int) m_markersDisplay); + s.writeBool(29, m_useCalibration); + s.writeS32(30, (int) m_calibrationInterpMode); s.writeS32(100, m_histogramMarkers.size()); for (int i = 0; i < m_histogramMarkers.size(); i++) { @@ -136,7 +140,7 @@ QDataStream& operator<<(QDataStream& out, const SpectrumCalibrationPoint& calibr { out << calibrationPoint.m_frequency; out << calibrationPoint.m_powerRelativeReference; - out << calibrationPoint.m_powerAbsoluteReference; + out << calibrationPoint.m_powerCalibratedReference; return out; } @@ -189,6 +193,9 @@ bool SpectrumSettings::deserialize(const QByteArray& data) d.readBool(27, &m_wsSpectrum, false); d.readS32(28, &tmp, 0); m_markersDisplay = (MarkersDisplay) tmp; + d.readBool(29, &m_useCalibration, false); + d.readS32(30, &tmp, 0); + m_calibrationInterpMode = (CalibrationInterpolationMode) tmp; int histogramMarkersSize; d.readS32(100, &histogramMarkersSize, 0); @@ -254,7 +261,7 @@ QDataStream& operator>>(QDataStream& in, SpectrumCalibrationPoint& calibrationPo { in >> calibrationPoint.m_frequency; in >> calibrationPoint.m_powerRelativeReference; - in >> calibrationPoint.m_powerAbsoluteReference; + in >> calibrationPoint.m_powerCalibratedReference; return in; } @@ -295,6 +302,7 @@ void SpectrumSettings::formatTo(SWGSDRangel::SWGObject *swgObject) const swgSpectrum->setUsb(m_usb ? 1 : 0); swgSpectrum->setWaterfallShare(m_waterfallShare); swgSpectrum->setMarkersDisplay((int) m_markersDisplay); + swgSpectrum->setUseCalibration(m_useCalibration ? 1 : 0); if (m_histogramMarkers.size() > 0) { @@ -348,7 +356,7 @@ void SpectrumSettings::formatTo(SWGSDRangel::SWGObject *swgObject) const swgSpectrum->getCalibrationPoints()->append(new SWGSDRangel::SWGSpectrumCalibrationPoint); swgSpectrum->getCalibrationPoints()->back()->setFrequency(calibrationPoint.m_frequency); swgSpectrum->getCalibrationPoints()->back()->setPowerRelativeReference(calibrationPoint.m_powerRelativeReference); - swgSpectrum->getCalibrationPoints()->back()->setPowerAbsoluteReference(calibrationPoint.m_powerAbsoluteReference); + swgSpectrum->getCalibrationPoints()->back()->setPowerAbsoluteReference(calibrationPoint.m_powerCalibratedReference); } } } @@ -444,6 +452,9 @@ void SpectrumSettings::updateFrom(const QStringList& keys, const SWGSDRangel::SW if (keys.contains("spectrumConfig.markersDisplay")) { m_markersDisplay = (SpectrumSettings::MarkersDisplay) swgSpectrum->getMarkersDisplay(); } + if (keys.contains("spectrumConfig.useCalibration")) { + m_useCalibration = swgSpectrum->getUseCalibration() != 0; + } if (keys.contains("spectrumConfig.histogramMarkers")) { @@ -511,7 +522,7 @@ void SpectrumSettings::updateFrom(const QStringList& keys, const SWGSDRangel::SW m_calibrationPoints.push_back(SpectrumCalibrationPoint()); m_calibrationPoints.back().m_frequency = swgCalibrationPoint->getFrequency(); m_calibrationPoints.back().m_powerRelativeReference = swgCalibrationPoint->getPowerRelativeReference(); - m_calibrationPoints.back().m_powerAbsoluteReference = swgCalibrationPoint->getPowerAbsoluteReference(); + m_calibrationPoints.back().m_powerCalibratedReference = swgCalibrationPoint->getPowerAbsoluteReference(); } } } diff --git a/sdrbase/dsp/spectrumsettings.h b/sdrbase/dsp/spectrumsettings.h index 02f2b859a..f5dfba8e8 100644 --- a/sdrbase/dsp/spectrumsettings.h +++ b/sdrbase/dsp/spectrumsettings.h @@ -46,6 +46,12 @@ public: MarkersDisplayAnnotations }; + enum CalibrationInterpolationMode + { + CalibInterpLinear, //!< linear power, linear frequency + CalibInterpLogLinear //!< log power, linear frequency + }; + int m_fftSize; int m_fftOverlap; FFTWindow::Function m_fftWindow; @@ -78,6 +84,8 @@ public: QList m_annoationMarkers; MarkersDisplay m_markersDisplay; QList m_calibrationPoints; + bool m_useCalibration; + CalibrationInterpolationMode m_calibrationInterpMode; //!< How is power interpolated between calibration points static const int m_log2FFTSizeMin = 6; // 64 static const int m_log2FFTSizeMax = 15; // 32k diff --git a/sdrbase/resources/webapi/doc/html2/index.html b/sdrbase/resources/webapi/doc/html2/index.html index d8d874ee9..1f4433d50 100644 --- a/sdrbase/resources/webapi/doc/html2/index.html +++ b/sdrbase/resources/webapi/doc/html2/index.html @@ -6155,6 +6155,10 @@ margin-bottom: 20px; "type" : "integer", "description" : "Display markers (SpectrumSettings::MarkersDisplay)\n * 0 - Mome\n * 1 - Spectrum markers (histogram and waterfall)\n * 2 - Spectrum annotation markers\n" }, + "useCalibration" : { + "type" : "integer", + "description" : "boolean" + }, "histogramMarkers" : { "type" : "array", "items" : { @@ -51996,7 +52000,7 @@ except ApiException as e:
- Generated 2022-01-29T10:45:16.003+01:00 + Generated 2022-01-30T07:47:20.311+01:00
diff --git a/sdrbase/resources/webapi/doc/swagger/include/GLSpectrum.yaml b/sdrbase/resources/webapi/doc/swagger/include/GLSpectrum.yaml index 266dfd2fb..2795c9cd3 100644 --- a/sdrbase/resources/webapi/doc/swagger/include/GLSpectrum.yaml +++ b/sdrbase/resources/webapi/doc/swagger/include/GLSpectrum.yaml @@ -160,6 +160,9 @@ GLSpectrum: * 0 - Mome * 1 - Spectrum markers (histogram and waterfall) * 2 - Spectrum annotation markers + useCalibration: + type: integer + description: boolean histogramMarkers: type: array items: diff --git a/sdrgui/gui/glspectrum.cpp b/sdrgui/gui/glspectrum.cpp index 3d43246c2..e67d5e723 100644 --- a/sdrgui/gui/glspectrum.cpp +++ b/sdrgui/gui/glspectrum.cpp @@ -34,6 +34,7 @@ MESSAGE_CLASS_DEFINITION(GLSpectrum::MsgReportSampleRate, Message) MESSAGE_CLASS_DEFINITION(GLSpectrum::MsgReportWaterfallShare, Message) MESSAGE_CLASS_DEFINITION(GLSpectrum::MsgReportFFTOverlap, Message) MESSAGE_CLASS_DEFINITION(GLSpectrum::MsgReportPowerScale, Message) +MESSAGE_CLASS_DEFINITION(GLSpectrum::MsgReportCalibrationShift, Message) const float GLSpectrum::m_maxFrequencyZoom = 10.0f; const float GLSpectrum::m_annotationMarkerHeight = 20.0f; @@ -86,6 +87,10 @@ GLSpectrum::GLSpectrum(QWidget* parent) : m_displayStreamIndex(0), m_matrixLoc(0), m_colorLoc(0), + m_useCalibration(false), + m_calibrationGain(1.0), + m_calibrationShiftdB(0.0), + m_calibrationInterpMode(SpectrumSettings::CalibInterpLinear), m_messageQueueToGUI(nullptr) { setAutoFillBackground(false); @@ -202,6 +207,11 @@ void GLSpectrum::setCenterFrequency(qint64 frequency) { m_mutex.lock(); m_centerFrequency = frequency; + + if (m_useCalibration) { + updateCalibrationPoints(); + } + m_changesPending = true; m_mutex.unlock(); update(); @@ -244,9 +254,11 @@ void GLSpectrum::setSampleRate(qint32 sampleRate) { m_mutex.lock(); m_sampleRate = sampleRate; + if (m_messageQueueToGUI) { m_messageQueueToGUI->push(new MsgReportSampleRate(m_sampleRate)); } + m_changesPending = true; m_mutex.unlock(); update(); @@ -385,6 +397,20 @@ void GLSpectrum::setLinear(bool linear) update(); } +void GLSpectrum::setUseCalibration(bool useCalibration) +{ + m_mutex.lock(); + m_useCalibration = useCalibration; + + if (m_messageQueueToGUI) { + m_messageQueueToGUI->push(new MsgReportCalibrationShift(m_useCalibration ? m_calibrationShiftdB : 0.0)); + } + + m_changesPending = true; + m_mutex.unlock(); + update(); +} + void GLSpectrum::addChannelMarker(ChannelMarker* channelMarker) { m_mutex.lock(); @@ -458,6 +484,26 @@ void GLSpectrum::setMarkersDisplay(SpectrumSettings::MarkersDisplay markersDispl update(); } +void GLSpectrum::setCalibrationPoints(const QList& calibrationPoints) +{ + m_mutex.lock(); + m_calibrationPoints = calibrationPoints; + updateCalibrationPoints(); + m_changesPending = true; + m_mutex.unlock(); + update(); +} + +void GLSpectrum::setCalibrationInterpMode(SpectrumSettings::CalibrationInterpolationMode mode) +{ + m_mutex.lock(); + m_calibrationInterpMode = mode; + updateCalibrationPoints(); + m_changesPending = true; + m_mutex.unlock(); + update(); +} + float GLSpectrum::getPowerMax() const { return m_linear ? m_powerScale.getRangeMax() : CalcDb::powerFromdB(m_powerScale.getRangeMax()); @@ -1212,17 +1258,18 @@ void GLSpectrum::drawSpectrumMarkers() if (m_histogramMarkers.at(i).m_markerType == SpectrumHistogramMarker::SpectrumMarkerTypePower) { - float power = m_currentSpectrum[m_histogramMarkers.at(i).m_fftBin]; + float power = m_linear ? + m_currentSpectrum[m_histogramMarkers.at(i).m_fftBin] * (m_useCalibration ? m_calibrationGain : 1.0f): + m_currentSpectrum[m_histogramMarkers.at(i).m_fftBin] + (m_useCalibration ? m_calibrationShiftdB : 0.0f); ypoint.ry() = (m_powerScale.getRangeMax() - power) / m_powerScale.getRange(); ypoint.ry() = ypoint.ry() < 0 ? - 0 : ypoint.ry() > 1 ? - 1 : ypoint.ry(); - powerStr = displayScaledF( + 0 : + ypoint.ry() > 1 ? 1 : ypoint.ry(); + powerStr = displayPower( power, m_linear ? 'e' : 'f', - m_linear ? 3 : 1, - false + m_linear ? 3 : 1 ); } else if (m_histogramMarkers.at(i).m_markerType == SpectrumHistogramMarker::SpectrumMarkerTypePowerMax) @@ -1235,16 +1282,19 @@ void GLSpectrum::drawSpectrumMarkers() m_histogramMarkers[i].m_holdReset = false; } + float powerMax = m_linear ? + m_histogramMarkers[i].m_powerMax * (m_useCalibration ? m_calibrationGain : 1.0f) : + m_histogramMarkers[i].m_powerMax + (m_useCalibration ? m_calibrationShiftdB : 0.0f); + ypoint.ry() = - (m_powerScale.getRangeMax() - m_histogramMarkers[i].m_powerMax) / m_powerScale.getRange(); + (m_powerScale.getRangeMax() - powerMax) / m_powerScale.getRange(); ypoint.ry() = ypoint.ry() < 0 ? 0 : ypoint.ry() > 1 ? 1 : ypoint.ry(); - powerStr = displayScaledF( - m_histogramMarkers[i].m_powerMax, + powerStr = displayPower( + powerMax, m_linear ? 'e' : 'f', - m_linear ? 3 : 1, - false + m_linear ? 3 : 1 ); } @@ -1306,7 +1356,7 @@ void GLSpectrum::drawSpectrumMarkers() QString deltaPowerStr; if (m_linear) { - deltaPowerStr = displayScaledF(poweri - power0, 'e', 3, false); + deltaPowerStr = QString::number(poweri - power0, 'e', 3); } else { deltaPowerStr = QString::number(poweri - power0, 'f', 1); } @@ -1562,10 +1612,15 @@ void GLSpectrum::applyChanges() m_powerScale.setSize(m_histogramHeight); - if (m_linear) { - m_powerScale.setRange(Unit::Scientific, m_referenceLevel - m_powerRange, m_referenceLevel); - } else { - m_powerScale.setRange(Unit::Decibel, m_referenceLevel - m_powerRange, m_referenceLevel); + if (m_linear) + { + Real referenceLevel = m_useCalibration ? m_referenceLevel * m_calibrationGain : m_referenceLevel; + m_powerScale.setRange(Unit::Scientific, 0.0f, referenceLevel); + } + else + { + Real referenceLevel = m_useCalibration ? m_referenceLevel + m_calibrationShiftdB : m_referenceLevel; + m_powerScale.setRange(Unit::Decibel, referenceLevel - m_powerRange, referenceLevel); } m_leftMargin = m_timeScale.getScaleWidth(); @@ -1717,7 +1772,8 @@ void GLSpectrum::applyChanges() m_histogramHeight = height() - m_topMargin - m_frequencyScaleHeight; m_powerScale.setSize(m_histogramHeight); - m_powerScale.setRange(Unit::Decibel, m_referenceLevel - m_powerRange, m_referenceLevel); + Real referenceLevel = m_useCalibration ? m_referenceLevel + m_calibrationShiftdB : m_referenceLevel; + m_powerScale.setRange(Unit::Decibel, referenceLevel - m_powerRange, referenceLevel); m_leftMargin = m_powerScale.getScaleWidth(); m_leftMargin += 2 * M; @@ -2175,7 +2231,9 @@ void GLSpectrum::updateHistogramMarkers() { for (int i = 0; i < m_histogramMarkers.size(); i++) { - float powerI = m_linear ? m_histogramMarkers[i].m_power : CalcDb::dbPower(m_histogramMarkers[i].m_power); + float powerI = m_linear ? + m_histogramMarkers.at(i).m_power * (m_useCalibration ? m_calibrationGain : 1.0f) : + CalcDb::dbPower(m_histogramMarkers.at(i).m_power) + (m_useCalibration ? m_calibrationShiftdB : 0.0f); m_histogramMarkers[i].m_point.rx() = (m_histogramMarkers[i].m_frequency - m_frequencyScale.getRangeMin()) / m_frequencyScale.getRange(); m_histogramMarkers[i].m_point.ry() = @@ -2196,11 +2254,10 @@ void GLSpectrum::updateHistogramMarkers() 'f', getPrecision((m_centerFrequency*1000)/m_sampleRate), false); - m_histogramMarkers[i].m_powerStr = displayScaledF( + m_histogramMarkers[i].m_powerStr = displayPower( powerI, m_linear ? 'e' : 'f', - m_linear ? 3 : 1, - false); + m_linear ? 3 : 1); if (i > 0) { @@ -2211,16 +2268,12 @@ void GLSpectrum::updateHistogramMarkers() getPrecision(deltaFrequency/m_sampleRate), true); float power0 = m_linear ? - m_histogramMarkers.at(0).m_power : - CalcDb::dbPower(m_histogramMarkers.at(0).m_power); - float powerI = m_linear ? - m_histogramMarkers.at(i).m_power : - CalcDb::dbPower(m_histogramMarkers.at(i).m_power); - m_histogramMarkers.back().m_deltaPowerStr = displayScaledF( + m_histogramMarkers.at(0).m_power * (m_useCalibration ? m_calibrationGain : 1.0f) : + CalcDb::dbPower(m_histogramMarkers.at(0).m_power) + (m_useCalibration ? m_calibrationShiftdB : 0.0f); + m_histogramMarkers.back().m_deltaPowerStr = displayPower( powerI - power0, m_linear ? 'e' : 'f', - m_linear ? 3 : 1, - false); + m_linear ? 3 : 1); } } } @@ -2316,7 +2369,86 @@ void GLSpectrum::updateMarkersDisplay() void GLSpectrum::updateCalibrationPoints() { - // TODO + if (m_calibrationPoints.size() == 0) + { + m_calibrationGain = 1.0; + m_calibrationShiftdB = 0.0; + } + else if (m_calibrationPoints.size() == 1) + { + m_calibrationGain = m_calibrationPoints.first().m_powerCalibratedReference / + m_calibrationPoints.first().m_powerRelativeReference; + m_calibrationShiftdB = CalcDb::dbPower(m_calibrationGain); + } + else + { + QList sortedCalibrationPoints = m_calibrationPoints; + std::sort(sortedCalibrationPoints.begin(), sortedCalibrationPoints.end(), calibrationPointsLessThan); + + if (m_centerFrequency <= sortedCalibrationPoints.first().m_frequency) + { + m_calibrationGain = m_calibrationPoints.first().m_powerCalibratedReference / + m_calibrationPoints.first().m_powerRelativeReference; + m_calibrationShiftdB = CalcDb::dbPower(m_calibrationGain); + } + else if (m_centerFrequency >= sortedCalibrationPoints.last().m_frequency) + { + m_calibrationGain = m_calibrationPoints.last().m_powerCalibratedReference / + m_calibrationPoints.last().m_powerRelativeReference; + m_calibrationShiftdB = CalcDb::dbPower(m_calibrationGain); + } + else + { + int lowIndex = 0; + int highIndex = sortedCalibrationPoints.size() - 1; + + for (int index = 0; index < sortedCalibrationPoints.size(); index++) + { + if (m_centerFrequency < sortedCalibrationPoints[index].m_frequency) + { + highIndex = index; + break; + } + else + { + lowIndex = index; + } + } + + // frequency interpolation is always linear + double deltaFrequency = sortedCalibrationPoints[highIndex].m_frequency - + sortedCalibrationPoints[lowIndex].m_frequency; + double shiftFrequency = m_centerFrequency - sortedCalibrationPoints[lowIndex].m_frequency; + double interpolationRatio = shiftFrequency / deltaFrequency; + + // calculate low and high gains in linear mode + double gainLow = sortedCalibrationPoints[lowIndex].m_powerCalibratedReference / + sortedCalibrationPoints[lowIndex].m_powerRelativeReference; + double gainHigh = sortedCalibrationPoints[highIndex].m_powerCalibratedReference / + sortedCalibrationPoints[highIndex].m_powerRelativeReference; + + // power interpolation depends on interpolation options + if (m_calibrationInterpMode == SpectrumSettings::CalibInterpLinear) + { + m_calibrationGain = gainLow + interpolationRatio*(gainHigh - gainLow); // linear driven + m_calibrationShiftdB = CalcDb::dbPower(m_calibrationGain); + } + else if (m_calibrationInterpMode == SpectrumSettings::CalibInterpLogLinear) + { + m_calibrationShiftdB = CalcDb::dbPower(gainLow) + + interpolationRatio*(CalcDb::dbPower(gainHigh) - CalcDb::dbPower(gainLow)); // log driven + m_calibrationGain = CalcDb::powerFromdB(m_calibrationShiftdB); + } + } + } + + updateHistogramMarkers(); + + if (m_messageQueueToGUI && m_useCalibration) { + m_messageQueueToGUI->push(new MsgReportCalibrationShift(m_calibrationShiftdB)); + } + + m_changesPending = true; } void GLSpectrum::mouseMoveEvent(QMouseEvent* event) @@ -2507,11 +2639,10 @@ void GLSpectrum::mousePressEvent(QMouseEvent* event) getPrecision((m_centerFrequency*1000)/m_sampleRate), false); m_histogramMarkers.back().m_power = power; - m_histogramMarkers.back().m_powerStr = displayScaledF( + m_histogramMarkers.back().m_powerStr = displayPower( powerVal, m_linear ? 'e' : 'f', - m_linear ? 3 : 1, - false); + m_linear ? 3 : 1); if (m_histogramMarkers.size() > 1) { @@ -2524,11 +2655,10 @@ void GLSpectrum::mousePressEvent(QMouseEvent* event) float power0 = m_linear ? m_histogramMarkers.at(0).m_power : CalcDb::dbPower(m_histogramMarkers.at(0).m_power); - m_histogramMarkers.back().m_deltaPowerStr = displayScaledF( + m_histogramMarkers.back().m_deltaPowerStr = displayPower( power - power0, m_linear ? 'e' : 'f', - m_linear ? 3 : 1, - false); + m_linear ? 3 : 1); } doUpdate = true; @@ -2776,10 +2906,8 @@ void GLSpectrum::timeZoom(bool zoomInElseOut) m_fftOverlap = m_fftOverlap + (zoomInElseOut ? 1 : -1); m_changesPending = true; - if (m_messageQueueToGUI) - { - MsgReportFFTOverlap *msg = new MsgReportFFTOverlap(m_fftOverlap); - m_messageQueueToGUI->push(msg); + if (m_messageQueueToGUI) { + m_messageQueueToGUI->push(new MsgReportFFTOverlap(m_fftOverlap)); } } @@ -2797,10 +2925,8 @@ void GLSpectrum::powerZoom(float pw, bool zoomInElseOut) m_referenceLevel = m_referenceLevel < -110 ? -110 : m_referenceLevel > 0 ? 0 : m_referenceLevel; m_changesPending = true; - if (m_messageQueueToGUI) - { - MsgReportPowerScale *msg = new MsgReportPowerScale(m_referenceLevel, m_powerRange); - m_messageQueueToGUI->push(msg); + if (m_messageQueueToGUI) { + m_messageQueueToGUI->push(new MsgReportPowerScale(m_referenceLevel, m_powerRange)); } } @@ -2993,6 +3119,11 @@ QString GLSpectrum::displayScaled(int64_t value, char type, int precision, bool } } +QString GLSpectrum::displayPower(float value, char type, int precision) +{ + return tr("%1").arg(QString::number(value, type, precision)); +} + QString GLSpectrum::displayScaledF(float value, char type, int precision, bool showMult) { float posValue = (value < 0) ? -value : value; @@ -3106,6 +3237,10 @@ void GLSpectrum::drawTextOverlay( void GLSpectrum::formatTextInfo(QString& info) { + if (m_useCalibration) { + info.append(tr("CAL:%1dB ").arg(QString::number(m_calibrationShiftdB, 'f', 1))); + } + if (m_frequencyZoomFactor != 1.0f) { info.append(tr("%1x ").arg(QString::number(m_frequencyZoomFactor, 'f', 1))); } diff --git a/sdrgui/gui/glspectrum.h b/sdrgui/gui/glspectrum.h index ade155298..7663a4e5c 100644 --- a/sdrgui/gui/glspectrum.h +++ b/sdrgui/gui/glspectrum.h @@ -110,6 +110,20 @@ public: Real m_range; }; + class MsgReportCalibrationShift : public Message { + MESSAGE_CLASS_DECLARATION + + public: + MsgReportCalibrationShift(Real calibrationShiftdB) : + Message(), + m_calibrationShiftdB(calibrationShiftdB) + {} + + Real getCalibrationShiftdB() const { return m_calibrationShiftdB; } + private: + Real m_calibrationShiftdB; + }; + GLSpectrum(QWidget* parent = nullptr); virtual ~GLSpectrum(); @@ -136,6 +150,7 @@ public: void setDisplayGridIntensity(int intensity); void setDisplayTraceIntensity(int intensity); void setLinear(bool linear); + void setUseCalibration(bool useCalibration); qint32 getSampleRate() const { return m_sampleRate; } void addChannelMarker(ChannelMarker* channelMarker); @@ -171,6 +186,10 @@ public: void updateCalibrationPoints(); SpectrumSettings::MarkersDisplay& getMarkersDisplay() { return m_markersDisplay; } void setMarkersDisplay(SpectrumSettings::MarkersDisplay markersDisplay); + QList& getCalibrationPoints() { return m_calibrationPoints; } + void setCalibrationPoints(const QList& calibrationPoints); + SpectrumSettings::CalibrationInterpolationMode& getCalibrationInterpMode() { return m_calibrationInterpMode; } + void setCalibrationInterpMode(SpectrumSettings::CalibrationInterpolationMode mode); private: struct ChannelMarkerState { @@ -203,6 +222,7 @@ private: QList m_sortedAnnotationMarkers; QList m_visibleAnnotationMarkers; SpectrumSettings::MarkersDisplay m_markersDisplay; + QList m_calibrationPoints; CursorState m_cursorState; int m_cursorChannel; @@ -297,6 +317,10 @@ private: GLShaderTextured m_glShaderInfo; int m_matrixLoc; int m_colorLoc; + bool m_useCalibration; + Real m_calibrationGain; + Real m_calibrationShiftdB; + SpectrumSettings::CalibrationInterpolationMode m_calibrationInterpMode; IncrementalArray m_q3TickTime; IncrementalArray m_q3TickFrequency; IncrementalArray m_q3TickPower; @@ -334,8 +358,9 @@ private: void enterEvent(QEvent* event); void leaveEvent(QEvent* event); - QString displayScaled(int64_t value, char type, int precision, bool showMult); - QString displayScaledF(float value, char type, int precision, bool showMult); + static QString displayScaled(int64_t value, char type, int precision, bool showMult); + static QString displayScaledF(float value, char type, int precision, bool showMult); + static QString displayPower(float value, char type, int precision); int getPrecision(int value); void drawTextOverlay( //!< Draws a text overlay const QString& text, @@ -358,6 +383,11 @@ private: } } + static bool calibrationPointsLessThan(const SpectrumCalibrationPoint& m1, const SpectrumCalibrationPoint& m2) + { + return m1.m_frequency < m2.m_frequency; + } + private slots: void cleanup(); void tick(); diff --git a/sdrgui/gui/glspectrumgui.cpp b/sdrgui/gui/glspectrumgui.cpp index 3408e1b54..c7f36b739 100644 --- a/sdrgui/gui/glspectrumgui.cpp +++ b/sdrgui/gui/glspectrumgui.cpp @@ -41,7 +41,8 @@ GLSpectrumGUI::GLSpectrumGUI(QWidget* parent) : ui(new Ui::GLSpectrumGUI), m_spectrumVis(nullptr), m_glSpectrum(nullptr), - m_doApplySettings(true) + m_doApplySettings(true), + m_calibrationShiftdB(0.0) { ui->setupUi(this); on_linscale_toggled(false); @@ -138,7 +139,7 @@ void GLSpectrumGUI::updateSettings() void GLSpectrumGUI::displaySettings() { blockApplySettings(true); - ui->refLevel->setValue(m_settings.m_refLevel); + ui->refLevel->setValue(m_settings.m_refLevel + m_calibrationShiftdB); ui->levelRange->setValue(m_settings.m_powerRange); ui->decay->setSliderPosition(m_settings.m_decay); ui->decayDivisor->setSliderPosition(m_settings.m_decayDivisor); @@ -191,6 +192,7 @@ void GLSpectrumGUI::displaySettings() ui->averagingMode->setCurrentIndex((int) m_settings.m_averagingMode); ui->linscale->setChecked(m_settings.m_linear); setAveragingToolitp(); + ui->calibration->setChecked(m_settings.m_useCalibration); ui->fftWindow->blockSignals(false); ui->averaging->blockSignals(false); @@ -251,11 +253,14 @@ void GLSpectrumGUI::applySpectrumSettings() m_glSpectrum->setPowerRange(powerRange); m_glSpectrum->setFPSPeriodMs(m_settings.m_fpsPeriodMs); m_glSpectrum->setLinear(m_settings.m_linear); + m_glSpectrum->setUseCalibration(m_settings.m_useCalibration); m_glSpectrum->setHistogramMarkers(m_settings.m_histogramMarkers); m_glSpectrum->setWaterfallMarkers(m_settings.m_waterfallMarkers); m_glSpectrum->setAnnotationMarkers(m_settings.m_annoationMarkers); m_glSpectrum->setMarkersDisplay(m_settings.m_markersDisplay); + m_glSpectrum->setCalibrationPoints(m_settings.m_calibrationPoints); + m_glSpectrum->setCalibrationInterpMode(m_settings.m_calibrationInterpMode); } void GLSpectrumGUI::on_fftWindow_currentIndexChanged(int index) @@ -315,7 +320,7 @@ void GLSpectrumGUI::on_autoscale_clicked(bool checked) m_settings.m_refLevel = maxLvl; m_settings.m_powerRange = maxLvl - minLvl; - ui->refLevel->setValue(m_settings.m_refLevel); + ui->refLevel->setValue(m_settings.m_refLevel + m_calibrationShiftdB); ui->levelRange->setValue(m_settings.m_powerRange); // qDebug("GLSpectrumGUI::on_autoscale_clicked: max: %d min %d max: %e min: %e", // maxLvl, minLvl, maxAvg, minAvg); @@ -398,7 +403,7 @@ void GLSpectrumGUI::on_markers_clicked(bool checked) void GLSpectrumGUI::on_refLevel_valueChanged(int value) { - m_settings.m_refLevel = value; + m_settings.m_refLevel = value - m_calibrationShiftdB; applySettings(); } @@ -501,6 +506,12 @@ void GLSpectrumGUI::on_freeze_toggled(bool checked) m_spectrumVis->getInputMessageQueue()->push(msg); } +void GLSpectrumGUI::on_calibration_toggled(bool checked) +{ + m_settings.m_useCalibration = checked; + applySettings(); +} + void GLSpectrumGUI::setAveragingCombo() { int index = ui->averaging->currentIndex(); @@ -679,12 +690,21 @@ bool GLSpectrumGUI::handleMessage(const Message& message) m_settings.m_powerRange = report.getRange(); ui->refLevel->blockSignals(true); ui->levelRange->blockSignals(true); - ui->refLevel->setValue(m_settings.m_refLevel); + ui->refLevel->setValue(m_settings.m_refLevel + m_calibrationShiftdB); ui->levelRange->setValue(m_settings.m_powerRange); ui->levelRange->blockSignals(false); ui->refLevel->blockSignals(false); return true; } + else if (GLSpectrum::MsgReportCalibrationShift::match(message)) + { + const GLSpectrum::MsgReportCalibrationShift& report = (GLSpectrum::MsgReportCalibrationShift&) message; + m_calibrationShiftdB = report.getCalibrationShiftdB(); + ui->refLevel->blockSignals(true); + ui->refLevel->setValue(m_settings.m_refLevel + m_calibrationShiftdB); + ui->refLevel->blockSignals(false); + return true; + } else if (SpectrumVis::MsgStartStop::match(message)) { const SpectrumVis::MsgStartStop& msg = (SpectrumVis::MsgStartStop&) message; @@ -733,7 +753,8 @@ void GLSpectrumGUI::openWebsocketSpectrumSettingsDialog(const QPoint& p) void GLSpectrumGUI::openCalibrationPointsDialog(const QPoint& p) { SpectrumCalibrationPointsDialog dialog( - m_settings.m_calibrationPoints, + m_glSpectrum->getCalibrationPoints(), + m_glSpectrum->getCalibrationInterpMode(), m_glSpectrum->getHistogramMarkers().size() > 0 ? &m_glSpectrum->getHistogramMarkers()[0] : nullptr, this ); @@ -747,6 +768,8 @@ void GLSpectrumGUI::openCalibrationPointsDialog(const QPoint& p) m_settings.m_waterfallMarkers = m_glSpectrum->getWaterfallMarkers(); m_settings.m_annoationMarkers = m_glSpectrum->getAnnotationMarkers(); m_settings.m_markersDisplay = m_glSpectrum->getMarkersDisplay(); + m_settings.m_calibrationPoints = m_glSpectrum->getCalibrationPoints(); + m_settings.m_calibrationInterpMode = m_glSpectrum->getCalibrationInterpMode(); applySettings(); } diff --git a/sdrgui/gui/glspectrumgui.h b/sdrgui/gui/glspectrumgui.h index 090a0859c..4e1f7cf07 100644 --- a/sdrgui/gui/glspectrumgui.h +++ b/sdrgui/gui/glspectrumgui.h @@ -70,6 +70,7 @@ private: MessageQueue m_messageQueue; SpectrumSettings m_settings; bool m_doApplySettings; + Real m_calibrationShiftdB; static const int m_fpsMs[]; void blockApplySettings(bool block); @@ -111,6 +112,7 @@ private slots: void on_grid_toggled(bool checked); void on_clearSpectrum_clicked(bool checked); void on_freeze_toggled(bool checked); + void on_calibration_toggled(bool checked); void handleInputMessages(); void openWebsocketSpectrumSettingsDialog(const QPoint& p); diff --git a/sdrgui/gui/glspectrumgui.ui b/sdrgui/gui/glspectrumgui.ui index cad74c59d..43f83b5e3 100644 --- a/sdrgui/gui/glspectrumgui.ui +++ b/sdrgui/gui/glspectrumgui.ui @@ -428,10 +428,10 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - -110 + -150 - 0 + 40 @@ -571,7 +571,7 @@ - Left: toggle relative / mW units - Right: open calibration dialog + Left: toggle relative / calibrated power - Right: open calibration dialog diff --git a/sdrgui/gui/spectrumcalibrationpointsdialog.cpp b/sdrgui/gui/spectrumcalibrationpointsdialog.cpp index 61065b40b..b81df40bf 100644 --- a/sdrgui/gui/spectrumcalibrationpointsdialog.cpp +++ b/sdrgui/gui/spectrumcalibrationpointsdialog.cpp @@ -30,19 +30,33 @@ SpectrumCalibrationPointsDialog::SpectrumCalibrationPointsDialog( QList& calibrationPoints, + SpectrumSettings::CalibrationInterpolationMode& calibrationInterpMode, const SpectrumHistogramMarker *markerZero, - QWidget* parent) : + QWidget* parent +) : QDialog(parent), ui(new Ui::SpectrumCalibrationPointsDialog), m_calibrationPoints(calibrationPoints), + m_calibrationInterpMode(calibrationInterpMode), m_markerZero(markerZero), m_calibrationPointIndex(0), - m_centerFrequency(0) + m_centerFrequency(0), + m_globalCorrection(0.0) { ui->setupUi(this); ui->calibPointFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold)); ui->calibPointFrequency->setValueRange(false, 10, -9999999999L, 9999999999L); + ui->calibrationGlobalCorr->setColorMapper(ColorMapper(ColorMapper::GrayYellow)); + ui->calibrationGlobalCorr->setValueRange(false, 5, -15000L, 4000L, 2); + ui->relativePower->setColorMapper(ColorMapper(ColorMapper::GrayYellow)); + ui->relativePower->setValueRange(false, 5, -15000L, 4000L, 2); + ui->calibratedPower->setColorMapper(ColorMapper(ColorMapper::GrayYellow)); + ui->calibratedPower->setValueRange(false, 5, -15000L, 4000L, 2); ui->calibPoint->setMaximum(m_calibrationPoints.size() - 1); + ui->calibInterpMode->blockSignals(true); + ui->calibInterpMode->setCurrentIndex((int) m_calibrationInterpMode); + ui->calibInterpMode->blockSignals(false); + ui->calibrationGlobalCorr->setValue(m_globalCorrection * 100.0); displayCalibrationPoint(); } @@ -54,14 +68,14 @@ void SpectrumCalibrationPointsDialog::displayCalibrationPoint() ui->calibPointFrequency->blockSignals(true); ui->calibPoint->blockSignals(true); ui->relativePower->blockSignals(true); - ui->absolutePower->blockSignals(true); + ui->calibratedPower->blockSignals(true); if (m_calibrationPoints.size() == 0) { ui->calibPoint->setEnabled(false); ui->calibPointDel->setEnabled(false); ui->relativePower->setEnabled(false); - ui->absolutePower->setEnabled(false); + ui->calibratedPower->setEnabled(false); ui->calibPointFrequency->setEnabled(false); ui->importMarkerZero->setEnabled(false); ui->centerFrequency->setEnabled(false); @@ -71,25 +85,23 @@ void SpectrumCalibrationPointsDialog::displayCalibrationPoint() ui->calibPoint->setEnabled(true); ui->calibPointDel->setEnabled(true); ui->relativePower->setEnabled(true); - ui->absolutePower->setEnabled(true); + ui->calibratedPower->setEnabled(true); ui->calibPointFrequency->setEnabled(true); ui->importMarkerZero->setEnabled(true); ui->centerFrequency->setEnabled(true); ui->calibPoint->setValue(m_calibrationPointIndex); ui->calibPointText->setText(tr("%1").arg(m_calibrationPointIndex)); - float powerDB = CalcDb::dbPower(m_calibrationPoints[m_calibrationPointIndex].m_powerRelativeReference); - ui->relativePower->setValue(powerDB*10); - ui->relativePowerText->setText(QString::number(powerDB, 'f', 1)); - powerDB = CalcDb::dbPower(m_calibrationPoints[m_calibrationPointIndex].m_powerAbsoluteReference); - ui->absolutePower->setValue(powerDB*10); - ui->absolutePowerText->setText(QString::number(powerDB, 'f', 1)); + double powerDB = CalcDb::dbPower(m_calibrationPoints[m_calibrationPointIndex].m_powerRelativeReference); + ui->relativePower->setValue(round(powerDB*100.0)); // fixed point 2 decimals + powerDB = CalcDb::dbPower(m_calibrationPoints[m_calibrationPointIndex].m_powerCalibratedReference); + ui->calibratedPower->setValue(round(powerDB*100.0)); // fixed point 2 decimals ui->calibPointFrequency->setValue(m_calibrationPoints[m_calibrationPointIndex].m_frequency); } ui->calibPointFrequency->blockSignals(false); ui->calibPoint->blockSignals(false); ui->relativePower->blockSignals(false); - ui->absolutePower->blockSignals(false); + ui->calibratedPower->blockSignals(false); } void SpectrumCalibrationPointsDialog::on_calibPoint_valueChanged(int value) @@ -126,27 +138,25 @@ void SpectrumCalibrationPointsDialog::on_calibPointDel_clicked() displayCalibrationPoint(); } -void SpectrumCalibrationPointsDialog::on_relativePower_valueChanged(int value) +void SpectrumCalibrationPointsDialog::on_relativePower_changed(qint64 value) { if (m_calibrationPoints.size() == 0) { return; } - float powerDB = value / 10.0f; - ui->relativePowerText->setText(QString::number(powerDB, 'f', 1)); + float powerDB = value / 100.0f; m_calibrationPoints[m_calibrationPointIndex].m_powerRelativeReference = CalcDb::powerFromdB(powerDB); emit updateCalibrationPoints(); } -void SpectrumCalibrationPointsDialog::on_absolutePower_valueChanged(int value) +void SpectrumCalibrationPointsDialog::on_calibratedPower_changed(qint64 value) { if (m_calibrationPoints.size() == 0) { return; } - float powerDB = value / 10.0f; - ui->absolutePowerText->setText(QString::number(powerDB, 'f', 1)); - m_calibrationPoints[m_calibrationPointIndex].m_powerAbsoluteReference = CalcDb::powerFromdB(powerDB); + float powerDB = value / 100.0f; + m_calibrationPoints[m_calibrationPointIndex].m_powerCalibratedReference = CalcDb::powerFromdB(powerDB); emit updateCalibrationPoints(); } @@ -160,6 +170,19 @@ void SpectrumCalibrationPointsDialog::on_calibPointFrequency_changed(qint64 valu emit updateCalibrationPoints(); } +void SpectrumCalibrationPointsDialog::on_calibPointDuplicate_clicked() +{ + if (m_calibrationPoints.size() == 0) { + return; + } + + m_calibrationPoints.push_back(SpectrumCalibrationPoint(m_calibrationPoints[m_calibrationPointIndex])); + ui->calibPoint->setMaximum(m_calibrationPoints.size() - 1); + ui->calibPoint->setMinimum(0); + m_calibrationPointIndex = m_calibrationPoints.size() - 1; + displayCalibrationPoint(); +} + void SpectrumCalibrationPointsDialog::on_importMarkerZero_clicked() { if ((m_calibrationPoints.size() == 0) || (m_markerZero == nullptr)) { @@ -183,6 +206,37 @@ void SpectrumCalibrationPointsDialog::on_centerFrequency_clicked() emit updateCalibrationPoints(); } +void SpectrumCalibrationPointsDialog::on_calibInterpMode_currentIndexChanged(int index) +{ + m_calibrationInterpMode = (SpectrumSettings::CalibrationInterpolationMode) index; + emit updateCalibrationPoints(); +} + +void SpectrumCalibrationPointsDialog::on_calibrationGlobalCorr_changed(qint64 value) +{ + m_globalCorrection = value / 100.0; +} + +void SpectrumCalibrationPointsDialog::on_globalRelativeCorrection_clicked() +{ + for (auto& calibrationPoint : m_calibrationPoints) { + calibrationPoint.m_powerRelativeReference *= CalcDb::powerFromdB(m_globalCorrection); + } + + displayCalibrationPoint(); + emit updateCalibrationPoints(); +} + +void SpectrumCalibrationPointsDialog::on_globalCalibratedCorrection_clicked() +{ + for (auto& calibrationPoint : m_calibrationPoints) { + calibrationPoint.m_powerCalibratedReference *= CalcDb::powerFromdB(m_globalCorrection); + } + + displayCalibrationPoint(); + emit updateCalibrationPoints(); +} + void SpectrumCalibrationPointsDialog::on_calibPointsExport_clicked() { QFileDialog fileDialog( @@ -211,7 +265,7 @@ void SpectrumCalibrationPointsDialog::on_calibPointsExport_clicked() { stream << calibrationPint.m_frequency << "," << calibrationPint.m_powerRelativeReference << "," - << calibrationPint.m_powerAbsoluteReference << "\n"; + << calibrationPint.m_powerCalibratedReference << "\n"; } stream.flush(); @@ -263,7 +317,7 @@ void SpectrumCalibrationPointsDialog::on_calibPointsImport_clicked() m_calibrationPoints.push_back(SpectrumCalibrationPoint()); m_calibrationPoints.back().m_frequency = cols[frequencyCol].toLongLong(); m_calibrationPoints.back().m_powerRelativeReference = cols[referenceCol].toFloat(); - m_calibrationPoints.back().m_powerAbsoluteReference = cols[absoluteCol].toFloat(); + m_calibrationPoints.back().m_powerCalibratedReference = cols[absoluteCol].toFloat(); } m_calibrationPointIndex = 0; diff --git a/sdrgui/gui/spectrumcalibrationpointsdialog.h b/sdrgui/gui/spectrumcalibrationpointsdialog.h index 37ae4055e..2b186eb34 100644 --- a/sdrgui/gui/spectrumcalibrationpointsdialog.h +++ b/sdrgui/gui/spectrumcalibrationpointsdialog.h @@ -38,6 +38,7 @@ class SDRGUI_API SpectrumCalibrationPointsDialog : public QDialog { public: explicit SpectrumCalibrationPointsDialog( QList& calibrationPoints, + SpectrumSettings::CalibrationInterpolationMode& calibrationInterpMode, const SpectrumHistogramMarker *markerZero, QWidget* parent = nullptr ); @@ -47,9 +48,11 @@ public: private: Ui::SpectrumCalibrationPointsDialog* ui; QList& m_calibrationPoints; + SpectrumSettings::CalibrationInterpolationMode& m_calibrationInterpMode; const SpectrumHistogramMarker *m_markerZero; int m_calibrationPointIndex; qint64 m_centerFrequency; + double m_globalCorrection; void displayCalibrationPoint(); @@ -57,11 +60,16 @@ private slots: void on_calibPoint_valueChanged(int value); void on_calibPointAdd_clicked(); void on_calibPointDel_clicked(); - void on_relativePower_valueChanged(int value); - void on_absolutePower_valueChanged(int value); + void on_relativePower_changed(qint64 value); + void on_calibratedPower_changed(qint64 value); void on_calibPointFrequency_changed(qint64 value); + void on_calibPointDuplicate_clicked(); void on_importMarkerZero_clicked(); void on_centerFrequency_clicked(); + void on_calibInterpMode_currentIndexChanged(int index); + void on_calibrationGlobalCorr_changed(qint64 value); + void on_globalRelativeCorrection_clicked(); + void on_globalCalibratedCorrection_clicked(); void on_calibPointsExport_clicked(); void on_calibPointsImport_clicked(); diff --git a/sdrgui/gui/spectrumcalibrationpointsdialog.ui b/sdrgui/gui/spectrumcalibrationpointsdialog.ui index 5afafab3f..2b6df6046 100644 --- a/sdrgui/gui/spectrumcalibrationpointsdialog.ui +++ b/sdrgui/gui/spectrumcalibrationpointsdialog.ui @@ -6,8 +6,8 @@ 0 0 - 469 - 131 + 466 + 159 @@ -203,7 +203,7 @@ - R + Rel Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter @@ -211,29 +211,38 @@ - + + + + 0 + 0 + + + + + 32 + 16 + + + + + DejaVu Sans Mono + 12 + + + + PointingHandCursor + + + Qt::StrongFocus + Relative power (dB) - - -1500 - - - 0 - - - 1 - - - -200 - - - Qt::Horizontal - - + 32 @@ -241,10 +250,10 @@ - -100.0 + dB - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter @@ -256,7 +265,7 @@ - + 15 @@ -264,7 +273,7 @@ - A + Cal Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter @@ -272,26 +281,38 @@ - + + + + 0 + 0 + + + + + 32 + 16 + + + + + DejaVu Sans Mono + 12 + + + + PointingHandCursor + + + Qt::StrongFocus + - Absolute power (dBm) - - - -1500 - - - 400 - - - 1 - - - Qt::Horizontal + Calibrated power (dBx) - + 32 @@ -299,10 +320,10 @@ - -100.0 + dB - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter @@ -389,6 +410,26 @@ + + + + + 24 + 24 + + + + Duplicate current calibration point + + + + + + + :/duplicate.png:/duplicate.png + + + @@ -421,6 +462,124 @@ + + + + + + + + Interp + + + + + + + Calibration interpolation mode + + + + Lin + + + + + LogLin + + + + + + + + Cor + + + + + + + + 0 + 0 + + + + + 32 + 16 + + + + + DejaVu Sans Mono + 12 + + + + PointingHandCursor + + + Qt::StrongFocus + + + Correction (dB) + + + + + + + dB + + + + + + + + 35 + 16777215 + + + + Apply gain correction to all relative values + + + Rel + + + + + + + + 35 + 16777215 + + + + Apply gain correction to all calibrated values + + + Cal + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + @@ -473,6 +632,24 @@ 1 + + calibPointFrequency + calibPoint + calibPointAdd + calibPointDel + calibPointFrequencyUnits + importMarkerZero + centerFrequency + calibPointsExport + calibPointsImport + calibInterpMode + calibPointDuplicate + calibrationGlobalCorr + relativePower + calibratedPower + globalRelativeCorrection + globalCalibratedCorrection + diff --git a/swagger/sdrangel/api/swagger/include/GLSpectrum.yaml b/swagger/sdrangel/api/swagger/include/GLSpectrum.yaml index 2f0395bf5..2a2f6666b 100644 --- a/swagger/sdrangel/api/swagger/include/GLSpectrum.yaml +++ b/swagger/sdrangel/api/swagger/include/GLSpectrum.yaml @@ -160,6 +160,9 @@ GLSpectrum: * 0 - Mome * 1 - Spectrum markers (histogram and waterfall) * 2 - Spectrum annotation markers + useCalibration: + type: integer + description: boolean histogramMarkers: type: array items: diff --git a/swagger/sdrangel/code/html2/index.html b/swagger/sdrangel/code/html2/index.html index d8d874ee9..1f4433d50 100644 --- a/swagger/sdrangel/code/html2/index.html +++ b/swagger/sdrangel/code/html2/index.html @@ -6155,6 +6155,10 @@ margin-bottom: 20px; "type" : "integer", "description" : "Display markers (SpectrumSettings::MarkersDisplay)\n * 0 - Mome\n * 1 - Spectrum markers (histogram and waterfall)\n * 2 - Spectrum annotation markers\n" }, + "useCalibration" : { + "type" : "integer", + "description" : "boolean" + }, "histogramMarkers" : { "type" : "array", "items" : { @@ -51996,7 +52000,7 @@ except ApiException as e:
- Generated 2022-01-29T10:45:16.003+01:00 + Generated 2022-01-30T07:47:20.311+01:00
diff --git a/swagger/sdrangel/code/qt5/client/SWGGLSpectrum.cpp b/swagger/sdrangel/code/qt5/client/SWGGLSpectrum.cpp index aba1fc232..fe11e43be 100644 --- a/swagger/sdrangel/code/qt5/client/SWGGLSpectrum.cpp +++ b/swagger/sdrangel/code/qt5/client/SWGGLSpectrum.cpp @@ -82,6 +82,8 @@ SWGGLSpectrum::SWGGLSpectrum() { m_ws_spectrum_port_isSet = false; markers_display = 0; m_markers_display_isSet = false; + use_calibration = 0; + m_use_calibration_isSet = false; histogram_markers = nullptr; m_histogram_markers_isSet = false; waterfall_markers = nullptr; @@ -152,6 +154,8 @@ SWGGLSpectrum::init() { m_ws_spectrum_port_isSet = false; markers_display = 0; m_markers_display_isSet = false; + use_calibration = 0; + m_use_calibration_isSet = false; histogram_markers = new QList(); m_histogram_markers_isSet = false; waterfall_markers = new QList(); @@ -193,6 +197,7 @@ SWGGLSpectrum::cleanup() { } + if(histogram_markers != nullptr) { auto arr = histogram_markers; for(auto o: *arr) { @@ -288,6 +293,8 @@ SWGGLSpectrum::fromJsonObject(QJsonObject &pJson) { ::SWGSDRangel::setValue(&markers_display, pJson["markersDisplay"], "qint32", ""); + ::SWGSDRangel::setValue(&use_calibration, pJson["useCalibration"], "qint32", ""); + ::SWGSDRangel::setValue(&histogram_markers, pJson["histogramMarkers"], "QList", "SWGSpectrumHistogramMarker"); @@ -393,6 +400,9 @@ SWGGLSpectrum::asJsonObject() { if(m_markers_display_isSet){ obj->insert("markersDisplay", QJsonValue(markers_display)); } + if(m_use_calibration_isSet){ + obj->insert("useCalibration", QJsonValue(use_calibration)); + } if(histogram_markers && histogram_markers->size() > 0){ toJsonArray((QList*)histogram_markers, obj, "histogramMarkers", "SWGSpectrumHistogramMarker"); } @@ -679,6 +689,16 @@ SWGGLSpectrum::setMarkersDisplay(qint32 markers_display) { this->m_markers_display_isSet = true; } +qint32 +SWGGLSpectrum::getUseCalibration() { + return use_calibration; +} +void +SWGGLSpectrum::setUseCalibration(qint32 use_calibration) { + this->use_calibration = use_calibration; + this->m_use_calibration_isSet = true; +} + QList* SWGGLSpectrum::getHistogramMarkers() { return histogram_markers; @@ -805,6 +825,9 @@ SWGGLSpectrum::isSet(){ if(m_markers_display_isSet){ isObjectUpdated = true; break; } + if(m_use_calibration_isSet){ + isObjectUpdated = true; break; + } if(histogram_markers && (histogram_markers->size() > 0)){ isObjectUpdated = true; break; } diff --git a/swagger/sdrangel/code/qt5/client/SWGGLSpectrum.h b/swagger/sdrangel/code/qt5/client/SWGGLSpectrum.h index 6bb51a6da..5d60364e7 100644 --- a/swagger/sdrangel/code/qt5/client/SWGGLSpectrum.h +++ b/swagger/sdrangel/code/qt5/client/SWGGLSpectrum.h @@ -128,6 +128,9 @@ public: qint32 getMarkersDisplay(); void setMarkersDisplay(qint32 markers_display); + qint32 getUseCalibration(); + void setUseCalibration(qint32 use_calibration); + QList* getHistogramMarkers(); void setHistogramMarkers(QList* histogram_markers); @@ -225,6 +228,9 @@ private: qint32 markers_display; bool m_markers_display_isSet; + qint32 use_calibration; + bool m_use_calibration_isSet; + QList* histogram_markers; bool m_histogram_markers_isSet;