1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-09-28 15:56:33 -04:00

UDP sink plugin: implement auto RW balance toggle button

This commit is contained in:
f4exb 2017-08-25 02:21:34 +02:00
parent 115379bcf2
commit 21cfac0cac
7 changed files with 59 additions and 2 deletions

View File

@ -374,6 +374,7 @@ bool UDPSink::handleMessage(const Message& cmd)
m_config.m_squelch = CalcDb::powerFromdB(cfg.getSquelchDB());
m_config.m_squelchGate = cfg.getSquelchGate();
m_config.m_squelchEnabled = cfg.getSquelchEnabled();
m_config.m_autoRWBalance = cfg.getAutoRWBalance();
apply(cfg.getForce());
@ -389,7 +390,8 @@ bool UDPSink::handleMessage(const Message& cmd)
<< " squelchDB: " << cfg.getSquelchDB()
<< " m_squelchGate: " << m_config.m_squelchGate
<< " m_squelch: " << m_config.m_squelch
<< " m_squelchEnabled: " << m_config.m_squelchEnabled;
<< " m_squelchEnabled: " << m_config.m_squelchEnabled
<< " m_autoRWBalance: " << m_config.m_autoRWBalance;
return true;
}
@ -489,6 +491,7 @@ void UDPSink::configure(MessageQueue* messageQueue,
Real squelchDB,
Real squelchGate,
bool squelchEnabled,
bool autoRWBalance,
bool force)
{
Message* cmd = MsgUDPSinkConfigure::create(sampleFormat,
@ -503,6 +506,7 @@ void UDPSink::configure(MessageQueue* messageQueue,
squelchDB,
squelchGate,
squelchEnabled,
autoRWBalance,
force);
messageQueue->push(cmd);
}

View File

@ -73,6 +73,7 @@ public:
Real squelchDB,
Real squelchGate,
bool squelchEnabled,
bool autoRWBalance,
bool force = false);
void setSpectrum(MessageQueue* messageQueue, bool enabled);
void resetReadIndex(MessageQueue* messageQueue);
@ -104,6 +105,7 @@ private:
Real getSquelchGate() const { return m_squelchGate; }
bool getSquelchEnabled() const { return m_squelchEnabled; }
bool getForce() const { return m_force; }
bool getAutoRWBalance() const { return m_autoRWBalance; }
static MsgUDPSinkConfigure* create(SampleFormat
sampleFormat,
@ -118,6 +120,7 @@ private:
Real squelchDB,
Real squelchGate,
bool squelchEnabled,
bool autoRWBalance,
bool force)
{
return new MsgUDPSinkConfigure(sampleFormat,
@ -132,6 +135,7 @@ private:
squelchDB,
squelchGate,
squelchEnabled,
autoRWBalance,
force);
}
@ -148,6 +152,7 @@ private:
Real m_squelchDB;
Real m_squelchGate;
bool m_squelchEnabled;
bool m_autoRWBalance;
bool m_force;
MsgUDPSinkConfigure(SampleFormat sampleFormat,
@ -162,6 +167,7 @@ private:
Real squelchDB,
Real squelchGate,
bool squelchEnabled,
bool autoRWBalance,
bool force) :
Message(),
m_sampleFormat(sampleFormat),
@ -176,6 +182,7 @@ private:
m_squelchDB(squelchDB),
m_squelchGate(squelchGate),
m_squelchEnabled(squelchEnabled),
m_autoRWBalance(autoRWBalance),
m_force(force)
{ }
};
@ -232,6 +239,7 @@ private:
Real m_squelch; //!< squared magnitude
Real m_squelchGate; //!< seconds
bool m_squelchEnabled;
bool m_autoRWBalance;
QString m_udpAddressStr;
quint16 m_udpPort;
@ -251,6 +259,7 @@ private:
m_squelch(-50.0),
m_squelchGate(0.05),
m_squelchEnabled(true),
m_autoRWBalance(true),
m_udpAddressStr("127.0.0.1"),
m_udpPort(9999)
{}

View File

@ -95,6 +95,7 @@ QByteArray UDPSinkGUI::serialize() const
s.writeString(13, m_channelMarker.getTitle());
s.writeS32(14, ui->squelch->value());
s.writeS32(15, ui->squelchGate->value());
s.writeBool(16, ui->autoRWBalance->isChecked());
return s.final();
}
@ -115,6 +116,7 @@ bool UDPSinkGUI::deserialize(const QByteArray& data)
qint32 s32tmp;
quint32 u32tmp;
Real realtmp;
bool booltmp;
blockApplySettings(true);
m_channelMarker.blockSignals(true);
@ -184,6 +186,8 @@ bool UDPSinkGUI::deserialize(const QByteArray& data)
d.readS32(15, &s32tmp, 5);
ui->squelchGate->setValue(s32tmp);
ui->squelchGateText->setText(tr("%1").arg(s32tmp*10.0, 0, 'f', 0));
d.readBool(16, &booltmp, true);
ui->autoRWBalance->setChecked(booltmp);
blockApplySettings(false);
m_channelMarker.blockSignals(false);
@ -412,6 +416,7 @@ void UDPSinkGUI::applySettings(bool force)
ui->squelch->value() * 1.0f,
ui->squelchGate->value() * 0.01f,
ui->squelch->value() != -100,
ui->autoRWBalance->isChecked(),
force);
ui->applyBtn->setEnabled(false);
@ -532,6 +537,11 @@ void UDPSinkGUI::on_resetUDPReadIndex_clicked()
m_udpSink->resetReadIndex(m_udpSink->getInputMessageQueue());
}
void UDPSinkGUI::on_autoRWBalance_toggled(bool checked __attribute__((unused)))
{
applySettings();
}
void UDPSinkGUI::onWidgetRolled(QWidget* widget, bool rollDown)
{
if ((widget == ui->spectrumBox) && (m_udpSink != 0))

View File

@ -73,6 +73,7 @@ private slots:
void on_squelchGate_valueChanged(int value);
void on_channelMute_toggled(bool checked);
void on_resetUDPReadIndex_clicked();
void on_autoRWBalance_toggled(bool checked);
void tick();
private:

View File

@ -654,6 +654,31 @@
</property>
</widget>
</item>
<item>
<widget class="ButtonSwitch" name="autoRWBalance">
<property name="minimumSize">
<size>
<width>0</width>
<height>22</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>22</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Automatic R/W balance compensation</string>
</property>
<property name="text">
<string>G</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
@ -897,6 +922,11 @@
<header>gui/levelmeter.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ButtonSwitch</class>
<extends>QToolButton</extends>
<header location="global">gui/buttonswitch.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../../../sdrbase/resources/res.qrc"/>

View File

@ -36,6 +36,7 @@ UDPSinkUDPHandler::UDPSinkUDPHandler() :
m_readIndex(0),
m_rwDelta(m_minNbUDPFrames/2),
m_d(0),
m_autoRWBalance(true),
m_feedbackMessageQueue(0)
{
m_udpBuf = new udpBlk_t[m_minNbUDPFrames];
@ -192,7 +193,7 @@ void UDPSinkUDPHandler::advanceReadPointer(int nbBytes)
c = c < -0.05 ? -0.05 : c > 0.05 ? 0.05 : c; // limit
UDPSinkMessages::MsgSampleRateCorrection *msg = UDPSinkMessages::MsgSampleRateCorrection::create(c, d);
if (m_feedbackMessageQueue) {
if (m_autoRWBalance && m_feedbackMessageQueue) {
m_feedbackMessageQueue->push(msg);
}

View File

@ -42,6 +42,7 @@ public:
void readSample(FixReal &t);
void readSample(Sample &s);
void setAutoRWBalance(bool autoRWBalance) { m_autoRWBalance = autoRWBalance; }
void setFeedbackMessageQueue(MessageQueue *messageQueue) { m_feedbackMessageQueue = messageQueue; }
/** Get buffer gauge value in % of buffer size ([-50:50])
@ -107,6 +108,7 @@ private:
int m_readIndex;
int m_rwDelta;
float m_d;
bool m_autoRWBalance;
MessageQueue *m_feedbackMessageQueue;
MessageQueue m_inputMessageQueue;