diff --git a/plugins/channelrx/radioclock/radioclock.cpp b/plugins/channelrx/radioclock/radioclock.cpp index e3baf16f6..c4b458560 100644 --- a/plugins/channelrx/radioclock/radioclock.cpp +++ b/plugins/channelrx/radioclock/radioclock.cpp @@ -38,6 +38,7 @@ #include "util/db.h" #include "maincore.h" #include "radioclocksink.h" +#include "radioclocksettings.h" MESSAGE_CLASS_DEFINITION(RadioClock::MsgConfigureRadioClock, Message) MESSAGE_CLASS_DEFINITION(RadioClock::MsgDateTime, Message) @@ -366,7 +367,7 @@ void RadioClock::webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& respon getMagSqLevels(magsqAvg, magsqPeak, nbMagsqSamples); response.getRadioClockReport()->setChannelPowerDb(CalcDb::dbPower(magsqAvg)); - response.getRadioClockReport()->setChannelSampleRate(RADIOCLOCK_CHANNEL_SAMPLE_RATE); + response.getRadioClockReport()->setChannelSampleRate(RadioClockSettings::RADIOCLOCK_CHANNEL_SAMPLE_RATE); response.getRadioClockReport()->setDate(new QString(m_dateTime.date().toString())); response.getRadioClockReport()->setTime(new QString(m_dateTime.time().toString())); } diff --git a/plugins/channelrx/radioclock/radioclockbaseband.cpp b/plugins/channelrx/radioclock/radioclockbaseband.cpp index eca4f55fc..35d89155e 100644 --- a/plugins/channelrx/radioclock/radioclockbaseband.cpp +++ b/plugins/channelrx/radioclock/radioclockbaseband.cpp @@ -23,6 +23,7 @@ #include "dsp/downchannelizer.h" #include "radioclockbaseband.h" +#include "radioclocksettings.h" MESSAGE_CLASS_DEFINITION(RadioClockBaseband::MsgConfigureRadioClockBaseband, Message) @@ -159,7 +160,7 @@ void RadioClockBaseband::applySettings(const RadioClockSettings& settings, bool { if ((settings.m_inputFrequencyOffset != m_settings.m_inputFrequencyOffset) || force) { - m_channelizer->setChannelization(RADIOCLOCK_CHANNEL_SAMPLE_RATE, settings.m_inputFrequencyOffset); + m_channelizer->setChannelization(RadioClockSettings::RADIOCLOCK_CHANNEL_SAMPLE_RATE, settings.m_inputFrequencyOffset); m_sink.applyChannelSettings(m_channelizer->getChannelSampleRate(), m_channelizer->getChannelFrequencyOffset()); } diff --git a/plugins/channelrx/radioclock/radioclockgui.cpp b/plugins/channelrx/radioclock/radioclockgui.cpp index 0b500552e..541c24b6c 100644 --- a/plugins/channelrx/radioclock/radioclockgui.cpp +++ b/plugins/channelrx/radioclock/radioclockgui.cpp @@ -248,7 +248,7 @@ RadioClockGUI::RadioClockGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Bas m_scopeVis = m_radioClock->getScopeSink(); m_scopeVis->setGLScope(ui->glScope); m_scopeVis->setNbStreams(7); - m_scopeVis->setLiveRate(1000); + m_scopeVis->setLiveRate(RadioClockSettings::RADIOCLOCK_CHANNEL_SAMPLE_RATE); ui->glScope->connectTimer(MainCore::instance()->getMasterTimer()); ui->scopeGUI->setBuddies(m_scopeVis->getInputMessageQueue(), m_scopeVis, ui->glScope); ui->scopeGUI->setStreams(QStringList({"IQ", "MagSq", "TH", "FM", "Data", "Samp", "GotMM"})); diff --git a/plugins/channelrx/radioclock/radioclocksettings.h b/plugins/channelrx/radioclock/radioclocksettings.h index ac5f69b41..c72437aef 100644 --- a/plugins/channelrx/radioclock/radioclocksettings.h +++ b/plugins/channelrx/radioclock/radioclocksettings.h @@ -52,6 +52,7 @@ struct RadioClockSettings uint16_t m_reverseAPIDeviceIndex; uint16_t m_reverseAPIChannelIndex; Serializable *m_scopeGUI; + static const int RADIOCLOCK_CHANNEL_SAMPLE_RATE = 1000; RadioClockSettings(); void resetToDefaults(); diff --git a/plugins/channelrx/radioclock/radioclocksink.cpp b/plugins/channelrx/radioclock/radioclocksink.cpp index 8a734b1e3..c6dac856d 100644 --- a/plugins/channelrx/radioclock/radioclocksink.cpp +++ b/plugins/channelrx/radioclock/radioclocksink.cpp @@ -31,7 +31,7 @@ RadioClockSink::RadioClockSink(RadioClock *radioClock) : m_scopeSink(nullptr), m_radioClock(radioClock), - m_channelSampleRate(RADIOCLOCK_CHANNEL_SAMPLE_RATE), + m_channelSampleRate(RadioClockSettings::RADIOCLOCK_CHANNEL_SAMPLE_RATE), m_channelFrequencyOffset(0), m_magsq(0.0), m_magsqSum(0.0), @@ -48,7 +48,7 @@ RadioClockSink::RadioClockSink(RadioClock *radioClock) : m_second(0), m_zeroCount(0) { - m_phaseDiscri.setFMScaling(RADIOCLOCK_CHANNEL_SAMPLE_RATE / (2.0f * 20.0/M_PI)); + m_phaseDiscri.setFMScaling(RadioClockSettings::RADIOCLOCK_CHANNEL_SAMPLE_RATE / (2.0f * 20.0/M_PI)); applySettings(m_settings, true); applyChannelSettings(m_channelSampleRate, m_channelFrequencyOffset, true); } @@ -177,10 +177,10 @@ void RadioClockSink::dcf77() // Look for minute marker - 59th second carrier is held high if ((m_data == 0) && (m_prevData == 1)) { - if ( (m_highCount <= RADIOCLOCK_CHANNEL_SAMPLE_RATE * 2) - && (m_highCount >= RADIOCLOCK_CHANNEL_SAMPLE_RATE * 1.6) - && (m_lowCount <= RADIOCLOCK_CHANNEL_SAMPLE_RATE * 0.3) - && (m_lowCount >= RADIOCLOCK_CHANNEL_SAMPLE_RATE * 0.1) + if ( (m_highCount <= RadioClockSettings::RADIOCLOCK_CHANNEL_SAMPLE_RATE * 2) + && (m_highCount >= RadioClockSettings::RADIOCLOCK_CHANNEL_SAMPLE_RATE * 1.6) + && (m_lowCount <= RadioClockSettings::RADIOCLOCK_CHANNEL_SAMPLE_RATE * 0.3) + && (m_lowCount >= RadioClockSettings::RADIOCLOCK_CHANNEL_SAMPLE_RATE * 0.1) ) { qDebug() << "RadioClockSink::dcf77 - Minute marker: (low " << m_lowCount << " high " << m_highCount << ") prev period " << m_periodCount; @@ -318,8 +318,8 @@ void RadioClockSink::tdf(Complex &ci) // Look for minute marker - 59th second is not phase modulated if ((m_data == 1) && (m_prevData == 0)) { - if ( (m_zeroCount <= RADIOCLOCK_CHANNEL_SAMPLE_RATE * 2) - && (m_zeroCount >= RADIOCLOCK_CHANNEL_SAMPLE_RATE * 1) + if ( (m_zeroCount <= RadioClockSettings::RADIOCLOCK_CHANNEL_SAMPLE_RATE * 2) + && (m_zeroCount >= RadioClockSettings::RADIOCLOCK_CHANNEL_SAMPLE_RATE * 1) ) { qDebug() << "RadioClockSink::tdf - Minute marker: (zero " << m_zeroCount << ") prev period " << m_periodCount; @@ -455,10 +455,10 @@ void RadioClockSink::msf60() // Look for minute marker - 500ms low, then 500ms high if ((m_data == 0) && (m_prevData == 1)) { - if ( (m_highCount <= RADIOCLOCK_CHANNEL_SAMPLE_RATE * 0.6) - && (m_highCount >= RADIOCLOCK_CHANNEL_SAMPLE_RATE * 0.4) - && (m_lowCount <= RADIOCLOCK_CHANNEL_SAMPLE_RATE * 0.6) - && (m_lowCount >= RADIOCLOCK_CHANNEL_SAMPLE_RATE * 0.4) + if ( (m_highCount <= RadioClockSettings::RADIOCLOCK_CHANNEL_SAMPLE_RATE * 0.6) + && (m_highCount >= RadioClockSettings::RADIOCLOCK_CHANNEL_SAMPLE_RATE * 0.4) + && (m_lowCount <= RadioClockSettings::RADIOCLOCK_CHANNEL_SAMPLE_RATE * 0.6) + && (m_lowCount >= RadioClockSettings::RADIOCLOCK_CHANNEL_SAMPLE_RATE * 0.4) ) { qDebug() << "RadioClockSink::msf60 - Minute marker: (low " << m_lowCount << " high " << m_highCount << ") prev period " << m_periodCount; @@ -623,7 +623,7 @@ void RadioClockSink::applyChannelSettings(int channelSampleRate, int channelFreq if ((m_channelSampleRate != channelSampleRate) || force) { m_interpolator.create(16, channelSampleRate, m_settings.m_rfBandwidth / 2.2); - m_interpolatorDistance = (Real) channelSampleRate / (Real) RADIOCLOCK_CHANNEL_SAMPLE_RATE; + m_interpolatorDistance = (Real) channelSampleRate / (Real) RadioClockSettings::RADIOCLOCK_CHANNEL_SAMPLE_RATE; m_interpolatorDistanceRemain = m_interpolatorDistance; } @@ -642,7 +642,7 @@ void RadioClockSink::applySettings(const RadioClockSettings& settings, bool forc if ((settings.m_rfBandwidth != m_settings.m_rfBandwidth) || force) { m_interpolator.create(16, m_channelSampleRate, settings.m_rfBandwidth / 2.2); - m_interpolatorDistance = (Real) m_channelSampleRate / (Real) RADIOCLOCK_CHANNEL_SAMPLE_RATE; + m_interpolatorDistance = (Real) m_channelSampleRate / (Real) RadioClockSettings::RADIOCLOCK_CHANNEL_SAMPLE_RATE; m_interpolatorDistanceRemain = m_interpolatorDistance; } diff --git a/plugins/channelrx/radioclock/radioclocksink.h b/plugins/channelrx/radioclock/radioclocksink.h index 9f7eb76e8..d185a7182 100644 --- a/plugins/channelrx/radioclock/radioclocksink.h +++ b/plugins/channelrx/radioclock/radioclocksink.h @@ -40,8 +40,6 @@ #include #include -#define RADIOCLOCK_CHANNEL_SAMPLE_RATE 1000 - class ChannelAPI; class RadioClock; class ScopeVis; @@ -113,7 +111,7 @@ private: MovingAverageUtil m_movingAverage; //!< Moving average has sharpest step response of LPFs - MovingAverageUtil m_thresholdMovingAverage; // Average over 1 second + MovingAverageUtil m_thresholdMovingAverage; // Average over 1 second int m_data; //!< Demod data before clocking int m_prevData; //!< Previous value of m_data