1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2025-04-04 10:38:45 -04:00

NFM demod: pass CTCSS index via message

This commit is contained in:
f4exb 2017-10-08 10:52:37 +02:00
parent f8fe5e2e13
commit 531ab992f3
3 changed files with 36 additions and 18 deletions

View File

@ -63,6 +63,7 @@ NFMDemod::NFMDemod() :
m_config.m_squelch = -30.0;
m_config.m_volume = 1.0;
m_config.m_ctcssOn = false;
m_config.m_ctcssIndex = 0;
m_config.m_audioMute = false;
m_config.m_audioSampleRate = DSPEngine::instance()->getAudioSampleRate();
@ -95,6 +96,7 @@ void NFMDemod::configure(MessageQueue* messageQueue,
int squelchGate,
bool deltaSquelch,
Real squelch,
int ctcssIndex,
bool ctcssOn,
bool audioMute,
bool copyAudioToUDP,
@ -109,6 +111,7 @@ void NFMDemod::configure(MessageQueue* messageQueue,
squelchGate,
deltaSquelch,
squelch,
ctcssIndex,
ctcssOn,
audioMute,
copyAudioToUDP,
@ -390,6 +393,7 @@ bool NFMDemod::handleMessage(const Message& cmd)
m_config.m_squelchGate = cfg.getSquelchGate();
m_config.m_deltaSquelch = cfg.getDeltaSquelch();
m_config.m_squelch = cfg.getSquelch();
m_config.m_ctcssIndex = cfg.getCtcssIndex();
m_config.m_ctcssOn = cfg.getCtcssOn();
m_config.m_audioMute = cfg.getAudioMute();
m_config.m_copyAudioToUDP = cfg.getCopyAudioToUDP();
@ -405,6 +409,7 @@ bool NFMDemod::handleMessage(const Message& cmd)
<< " m_squelchGate: " << m_config.m_squelchGate
<< " m_deltaSquelch: " << m_config.m_deltaSquelch
<< " m_squelch: " << m_squelchLevel
<< " m_ctcssIndex: " << m_config.m_ctcssIndex
<< " m_ctcssOn: " << m_config.m_ctcssOn
<< " m_audioMute: " << m_config.m_audioMute
<< " m_copyAudioToUDP: " << m_config.m_copyAudioToUDP
@ -483,5 +488,10 @@ void NFMDemod::apply(bool force)
m_udpBufferAudio->setPort(m_config.m_udpPort);
}
if ((m_config.m_ctcssIndex != m_running.m_ctcssIndex) || force)
{
setSelectedCtcssIndex(m_config.m_ctcssIndex);
}
m_running = m_config;
}

View File

@ -48,6 +48,7 @@ public:
int squelchGate,
bool deltaSquelch,
Real squelch,
int ctcssIndex,
bool ctcssOn,
bool audioMute,
bool copyAudioToUDP,
@ -99,6 +100,7 @@ private:
int getSquelchGate() const { return m_squelchGate; }
bool getDeltaSquelch() const { return m_deltaSquelch; }
Real getSquelch() const { return m_squelch; }
int getCtcssIndex() const { return m_ctcssIndex; }
bool getCtcssOn() const { return m_ctcssOn; }
bool getAudioMute() const { return m_audioMute; }
bool getCopyAudioToUDP() const { return m_copyAudioToUDP; }
@ -113,6 +115,7 @@ private:
int squelchGate,
bool deltaSquelch,
Real squelch,
int ctcssIndex,
bool ctcssOn,
bool audioMute,
bool copyAudioToUDP,
@ -128,6 +131,7 @@ private:
squelchGate,
deltaSquelch,
squelch,
ctcssIndex,
ctcssOn,
audioMute,
copyAudioToUDP,
@ -144,6 +148,7 @@ private:
int m_squelchGate;
bool m_deltaSquelch;
Real m_squelch;
int m_ctcssIndex;
bool m_ctcssOn;
bool m_audioMute;
bool m_copyAudioToUDP;
@ -158,6 +163,7 @@ private:
int squelchGate,
bool deltaSquelch,
Real squelch,
int ctcssIndex,
bool ctcssOn,
bool audioMute,
bool copyAudioToUDP,
@ -172,6 +178,7 @@ private:
m_squelchGate(squelchGate),
m_deltaSquelch(deltaSquelch),
m_squelch(squelch),
m_ctcssIndex(ctcssIndex),
m_ctcssOn(ctcssOn),
m_audioMute(audioMute),
m_copyAudioToUDP(copyAudioToUDP),

View File

@ -268,11 +268,8 @@ void NFMDemodGUI::on_copyAudioToUDP_toggled(bool checked)
void NFMDemodGUI::on_ctcss_currentIndexChanged(int index)
{
if (m_nfmDemod != 0)
{
m_nfmDemod->setSelectedCtcssIndex(index);
}
m_settings.m_ctcssIndex = index;
applySettings();
}
void NFMDemodGUI::onWidgetRolled(QWidget* widget __attribute__((unused)), bool rollDown __attribute__((unused)))
@ -304,13 +301,6 @@ NFMDemodGUI::NFMDemodGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidg
ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose, true);
blockApplySettings(true);
ui->rfBW->clear();
for (int i = 0; i < m_nbRfBW; i++) {
ui->rfBW->addItem(QString("%1").arg(m_rfBW[i] / 1000.0, 0, 'f', 2));
}
blockApplySettings(false);
connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onMenuDialogCalled(const QPoint &)));
@ -319,15 +309,25 @@ NFMDemodGUI::NFMDemodGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidg
connect(&m_pluginAPI->getMainWindow()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick()));
int ctcss_nbTones;
const Real *ctcss_tones = m_nfmDemod->getCtcssToneSet(ctcss_nbTones);
blockApplySettings(true);
ui->ctcss->addItem("--");
ui->rfBW->clear();
for (int i=0; i<ctcss_nbTones; i++)
{
ui->ctcss->addItem(QString("%1").arg(ctcss_tones[i]));
}
for (int i = 0; i < m_nbRfBW; i++) {
ui->rfBW->addItem(QString("%1").arg(m_rfBW[i] / 1000.0, 0, 'f', 2));
}
int ctcss_nbTones;
const Real *ctcss_tones = m_nfmDemod->getCtcssToneSet(ctcss_nbTones);
ui->ctcss->addItem("--");
for (int i=0; i<ctcss_nbTones; i++)
{
ui->ctcss->addItem(QString("%1").arg(ctcss_tones[i]));
}
blockApplySettings(false);
ui->audioMute->setStyleSheet("QToolButton { background:rgb(79,79,79); }"); // squelch closed
@ -396,6 +396,7 @@ void NFMDemodGUI::applySettings(bool force)
m_settings.m_squelchGate, // in 10ths of ms 1 -> 50
m_settings.m_deltaSquelch,
m_settings.m_squelch, // -1000 -> 0
m_settings.m_ctcssIndex,
m_settings.m_ctcssOn,
m_settings.m_audioMute,
m_settings.m_copyAudioToUDP,