NFM Demod: try a deferred init to cure AF squelch init problem

This commit is contained in:
f4exb 2017-06-06 01:53:52 +02:00
parent e4332a16b6
commit 91021678b2
5 changed files with 39 additions and 17 deletions

View File

@ -94,7 +94,8 @@ void NFMDemod::configure(MessageQueue* messageQueue,
bool deltaSquelch,
Real squelch,
bool ctcssOn,
bool audioMute)
bool audioMute,
bool force)
{
Message* cmd = MsgConfigureNFMDemod::create(rfBandwidth,
afBandwidth,
@ -104,7 +105,8 @@ void NFMDemod::configure(MessageQueue* messageQueue,
deltaSquelch,
squelch,
ctcssOn,
audioMute);
audioMute,
force);
messageQueue->push(cmd);
}
@ -338,6 +340,7 @@ void NFMDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
void NFMDemod::start()
{
qDebug() << "NFMDemod::start";
m_audioFifo.clear();
m_phaseDiscri.reset();
apply(true);
@ -379,7 +382,7 @@ bool NFMDemod::handleMessage(const Message& cmd)
m_config.m_ctcssOn = cfg.getCtcssOn();
m_config.m_audioMute = cfg.getAudioMute();
apply();
apply(cfg.getForce());
qDebug() << "NFMDemod::handleMessage: MsgConfigureNFMDemod: m_rfBandwidth: " << m_config.m_rfBandwidth
<< " m_afBandwidth: " << m_config.m_afBandwidth
@ -389,7 +392,8 @@ bool NFMDemod::handleMessage(const Message& cmd)
<< " m_deltaSquelch: " << m_config.m_deltaSquelch
<< " m_squelch: " << m_squelchLevel
<< " m_ctcssOn: " << m_config.m_ctcssOn
<< " m_audioMute: " << m_config.m_audioMute;
<< " m_audioMute: " << m_config.m_audioMute
<< " force: " << cfg.getForce();
return true;
}

View File

@ -49,7 +49,8 @@ public:
bool deltaSquelch,
Real squelch,
bool ctcssOn,
bool audioMute);
bool audioMute,
bool force);
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool po);
virtual void start();
@ -97,6 +98,7 @@ private:
Real getSquelch() const { return m_squelch; }
bool getCtcssOn() const { return m_ctcssOn; }
bool getAudioMute() const { return m_audioMute; }
bool getForce() const { return m_force; }
static MsgConfigureNFMDemod* create(Real rfBandwidth,
Real afBandwidth,
@ -106,7 +108,8 @@ private:
bool deltaSquelch,
Real squelch,
bool ctcssOn,
bool audioMute)
bool audioMute,
bool force)
{
return new MsgConfigureNFMDemod(
rfBandwidth,
@ -117,7 +120,8 @@ private:
deltaSquelch,
squelch,
ctcssOn,
audioMute);
audioMute,
force);
}
private:
@ -130,6 +134,7 @@ private:
Real m_squelch;
bool m_ctcssOn;
bool m_audioMute;
bool m_force;
MsgConfigureNFMDemod(Real rfBandwidth,
Real afBandwidth,
@ -139,7 +144,8 @@ private:
bool deltaSquelch,
Real squelch,
bool ctcssOn,
bool audioMute) :
bool audioMute,
bool force) :
Message(),
m_rfBandwidth(rfBandwidth),
m_afBandwidth(afBandwidth),
@ -149,7 +155,8 @@ private:
m_deltaSquelch(deltaSquelch),
m_squelch(squelch),
m_ctcssOn(ctcssOn),
m_audioMute(audioMute)
m_audioMute(audioMute),
m_force(force)
{ }
};

View File

@ -143,7 +143,7 @@ bool NFMDemodGUI::deserialize(const QByteArray& data)
blockApplySettings(false);
m_channelMarker.blockSignals(false);
applySettings();
applySettings(true);
return true;
}
else
@ -272,7 +272,8 @@ NFMDemodGUI::NFMDemodGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidg
m_channelMarker(this),
m_basicSettingsShown(false),
m_doApplySettings(true),
m_squelchOpen(false)
m_squelchOpen(false),
m_autoInitCount(0)
{
ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose, true);
@ -328,7 +329,7 @@ NFMDemodGUI::NFMDemodGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidg
QChar delta = QChar(0x94, 0x03);
ui->deltaSquelch->setText(delta);
applySettings();
applySettings(true);
}
NFMDemodGUI::~NFMDemodGUI()
@ -342,7 +343,7 @@ NFMDemodGUI::~NFMDemodGUI()
delete ui;
}
void NFMDemodGUI::applySettings()
void NFMDemodGUI::applySettings(bool force)
{
if (m_doApplySettings)
{
@ -365,7 +366,8 @@ void NFMDemodGUI::applySettings()
ui->deltaSquelch->isChecked(),
ui->squelch->value(), // -1000 -> 0
ui->ctcssOn->isChecked(),
ui->audioMute->isChecked());
ui->audioMute->isChecked(),
force);
}
}
@ -427,4 +429,10 @@ void NFMDemodGUI::tick()
m_squelchOpen = squelchOpen;
}
if (m_autoInitCount < 100) // ~5s
{
if (m_autoInitCount == 99) applySettings(true);
m_autoInitCount++;
}
}

View File

@ -69,6 +69,7 @@ private:
bool m_ctcssOn;
bool m_audioMute;
bool m_squelchOpen;
uint32_t m_autoInitCount;
static const int m_rfBW[];
static const int m_fmDev[];
@ -78,7 +79,7 @@ private:
virtual ~NFMDemodGUI();
void blockApplySettings(bool block);
void applySettings();
void applySettings(bool force = false);
void leaveEvent(QEvent*);
void enterEvent(QEvent*);

View File

@ -205,8 +205,10 @@ void AFSquelch::reset()
{
for (unsigned int j = 0; j < m_nTones; ++j)
{
m_power[j] = m_u0[j] = m_u1[j] = 0.0; // reset
m_movingAverages[j].fill(0.0);
m_u0[j] = 0.0;
m_u1[j] = 0.0;
m_power[j] = 0.0;
m_movingAverages[j].fill(0.0);
}
m_samplesProcessed = 0;