2017-08-13 19:39:26 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2017 Edouard Griffiths, F4EXB //
|
|
|
|
// //
|
|
|
|
// This program is free software; you can redistribute it and/or modify //
|
|
|
|
// it under the terms of the GNU General Public License as published by //
|
|
|
|
// the Free Software Foundation as version 3 of the License, or //
|
|
|
|
// //
|
|
|
|
// This program is distributed in the hope that it will be useful, //
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
|
|
|
// GNU General Public License V3 for more details. //
|
|
|
|
// //
|
|
|
|
// You should have received a copy of the GNU General Public License //
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "device/devicesinkapi.h"
|
|
|
|
#include "dsp/spectrumvis.h"
|
|
|
|
#include "dsp/dspengine.h"
|
2017-08-14 10:09:56 -04:00
|
|
|
#include "util/simpleserializer.h"
|
2017-08-14 16:50:28 -04:00
|
|
|
#include "util/db.h"
|
2017-08-23 20:05:48 -04:00
|
|
|
#include "gui/basicchannelsettingsdialog.h"
|
2017-08-14 10:09:56 -04:00
|
|
|
#include "plugin/pluginapi.h"
|
2017-08-13 19:39:26 -04:00
|
|
|
#include "mainwindow.h"
|
|
|
|
|
|
|
|
#include "udpsinkgui.h"
|
|
|
|
#include "ui_udpsinkgui.h"
|
|
|
|
|
|
|
|
const QString UDPSinkGUI::m_channelID = "sdrangel.channeltx.udpsink";
|
|
|
|
|
|
|
|
UDPSinkGUI* UDPSinkGUI::create(PluginAPI* pluginAPI, DeviceSinkAPI *deviceAPI)
|
|
|
|
{
|
|
|
|
UDPSinkGUI* gui = new UDPSinkGUI(pluginAPI, deviceAPI);
|
|
|
|
return gui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void UDPSinkGUI::destroy()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void UDPSinkGUI::setName(const QString& name)
|
|
|
|
{
|
|
|
|
setObjectName(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString UDPSinkGUI::getName() const
|
|
|
|
{
|
|
|
|
return objectName();
|
|
|
|
}
|
|
|
|
|
|
|
|
qint64 UDPSinkGUI::getCenterFrequency() const {
|
|
|
|
return m_channelMarker.getCenterFrequency();
|
|
|
|
}
|
|
|
|
|
|
|
|
void UDPSinkGUI::setCenterFrequency(qint64 centerFrequency)
|
|
|
|
{
|
|
|
|
m_channelMarker.setCenterFrequency(centerFrequency);
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void UDPSinkGUI::resetToDefaults()
|
|
|
|
{
|
2017-10-15 18:28:01 -04:00
|
|
|
m_settings.resetToDefaults();
|
|
|
|
displaySettings();
|
|
|
|
applySettings(true);
|
2017-08-13 19:39:26 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray UDPSinkGUI::serialize() const
|
|
|
|
{
|
2017-10-15 18:28:01 -04:00
|
|
|
return m_settings.serialize();
|
2017-08-13 19:39:26 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool UDPSinkGUI::deserialize(const QByteArray& data)
|
|
|
|
{
|
2017-10-15 18:28:01 -04:00
|
|
|
if(m_settings.deserialize(data))
|
2017-08-13 19:39:26 -04:00
|
|
|
{
|
2017-08-26 15:20:35 -04:00
|
|
|
displaySettings();
|
2017-08-16 03:53:23 -04:00
|
|
|
applySettings(true);
|
2017-08-13 19:39:26 -04:00
|
|
|
return true;
|
2017-10-15 18:28:01 -04:00
|
|
|
} else {
|
2017-08-13 19:39:26 -04:00
|
|
|
resetToDefaults();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool UDPSinkGUI::handleMessage(const Message& message __attribute__((unused)))
|
|
|
|
{
|
|
|
|
qDebug() << "UDPSinkGUI::handleMessage";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void UDPSinkGUI::handleSourceMessages()
|
|
|
|
{
|
|
|
|
Message* message;
|
|
|
|
|
2017-09-28 02:33:05 -04:00
|
|
|
while ((message = getInputMessageQueue()->pop()) != 0)
|
2017-08-13 19:39:26 -04:00
|
|
|
{
|
|
|
|
if (handleMessage(*message))
|
|
|
|
{
|
|
|
|
delete message;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
UDPSinkGUI::UDPSinkGUI(PluginAPI* pluginAPI, DeviceSinkAPI *deviceAPI, QWidget* parent) :
|
|
|
|
RollupWidget(parent),
|
|
|
|
ui(new Ui::UDPSinkGUI),
|
|
|
|
m_pluginAPI(pluginAPI),
|
|
|
|
m_deviceAPI(deviceAPI),
|
2017-08-17 06:57:45 -04:00
|
|
|
m_channelPowerAvg(4, 1e-10),
|
|
|
|
m_inPowerAvg(4, 1e-10),
|
|
|
|
m_tickCount(0),
|
2017-08-13 19:39:26 -04:00
|
|
|
m_channelMarker(this),
|
2017-10-15 18:08:27 -04:00
|
|
|
m_rfBandwidthChanged(false),
|
2017-08-13 19:39:26 -04:00
|
|
|
m_doApplySettings(true)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
|
2017-08-23 20:05:48 -04:00
|
|
|
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onMenuDialogCalled(const QPoint &)));
|
2017-08-13 19:39:26 -04:00
|
|
|
setAttribute(Qt::WA_DeleteOnClose, true);
|
|
|
|
|
|
|
|
m_spectrumVis = new SpectrumVis(ui->glSpectrum);
|
2017-10-17 15:08:54 -04:00
|
|
|
m_udpSink = new UDPSink(m_deviceAPI, m_spectrumVis);
|
2017-09-28 02:33:05 -04:00
|
|
|
m_udpSink->setMessageQueueToGUI(getInputMessageQueue());
|
2017-08-13 19:39:26 -04:00
|
|
|
|
|
|
|
ui->fmDeviation->setEnabled(false);
|
|
|
|
ui->deltaFrequencyLabel->setText(QString("%1f").arg(QChar(0x94, 0x03)));
|
|
|
|
ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));
|
|
|
|
ui->deltaFrequency->setValueRange(false, 7, -9999999, 9999999);
|
|
|
|
|
|
|
|
ui->glSpectrum->setCenterFrequency(0);
|
|
|
|
ui->glSpectrum->setSampleRate(ui->sampleRate->text().toInt());
|
|
|
|
ui->glSpectrum->setDisplayWaterfall(true);
|
|
|
|
ui->glSpectrum->setDisplayMaxHold(true);
|
|
|
|
m_spectrumVis->configure(m_spectrumVis->getInputMessageQueue(), 64, 10, FFTWindow::BlackmanHarris);
|
|
|
|
|
|
|
|
ui->glSpectrum->connectTimer(m_pluginAPI->getMainWindow()->getMasterTimer());
|
|
|
|
connect(&m_pluginAPI->getMainWindow()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick()));
|
|
|
|
|
|
|
|
//m_channelMarker = new ChannelMarker(this);
|
|
|
|
m_channelMarker.setBandwidth(16000);
|
|
|
|
m_channelMarker.setCenterFrequency(0);
|
|
|
|
m_channelMarker.setColor(Qt::green);
|
2017-08-14 18:20:04 -04:00
|
|
|
m_channelMarker.setTitle("UDP Sample Sink");
|
2017-08-13 19:39:26 -04:00
|
|
|
m_channelMarker.setVisible(true);
|
|
|
|
|
|
|
|
connect(&m_channelMarker, SIGNAL(changed()), this, SLOT(channelMarkerChanged()));
|
|
|
|
|
|
|
|
m_deviceAPI->registerChannelInstance(m_channelID, this);
|
|
|
|
m_deviceAPI->addChannelMarker(&m_channelMarker);
|
|
|
|
m_deviceAPI->addRollupWidget(this);
|
|
|
|
|
2017-08-14 18:20:04 -04:00
|
|
|
ui->spectrumGUI->setBuddies(m_spectrumVis->getInputMessageQueue(), m_spectrumVis, ui->glSpectrum);
|
|
|
|
|
2017-08-17 06:57:45 -04:00
|
|
|
displaySettings();
|
2017-08-16 03:53:23 -04:00
|
|
|
applySettings(true);
|
2017-08-13 19:39:26 -04:00
|
|
|
|
2017-09-28 02:33:05 -04:00
|
|
|
connect(getInputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleSourceMessages()));
|
2017-08-16 17:37:01 -04:00
|
|
|
connect(m_udpSink, SIGNAL(levelChanged(qreal, qreal, int)), ui->volumeMeter, SLOT(levelChanged(qreal, qreal, int)));
|
2017-08-13 19:39:26 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
UDPSinkGUI::~UDPSinkGUI()
|
|
|
|
{
|
|
|
|
m_deviceAPI->removeChannelInstance(this);
|
|
|
|
delete m_udpSink;
|
|
|
|
delete m_spectrumVis;
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void UDPSinkGUI::blockApplySettings(bool block)
|
|
|
|
{
|
|
|
|
m_doApplySettings = !block;
|
|
|
|
}
|
|
|
|
|
2017-08-16 03:53:23 -04:00
|
|
|
void UDPSinkGUI::applySettings(bool force)
|
2017-08-13 19:39:26 -04:00
|
|
|
{
|
|
|
|
if (m_doApplySettings)
|
|
|
|
{
|
2017-10-17 17:45:57 -04:00
|
|
|
UDPSink::MsgConfigureChannelizer *msgChan = UDPSink::MsgConfigureChannelizer::create(
|
2017-10-15 16:14:30 -04:00
|
|
|
m_settings.m_inputSampleRate,
|
2017-10-15 18:08:27 -04:00
|
|
|
m_settings.m_inputFrequencyOffset);
|
2017-10-17 17:45:57 -04:00
|
|
|
m_udpSink->getInputMessageQueue()->push(msgChan);
|
2017-08-13 19:39:26 -04:00
|
|
|
|
2017-10-16 18:14:06 -04:00
|
|
|
UDPSink::MsgConfigureUDPSink* message = UDPSink::MsgConfigureUDPSink::create( m_settings, force);
|
|
|
|
m_udpSink->getInputMessageQueue()->push(message);
|
|
|
|
|
2017-08-13 19:39:26 -04:00
|
|
|
ui->applyBtn->setEnabled(false);
|
2017-08-18 21:42:56 -04:00
|
|
|
ui->applyBtn->setStyleSheet("QPushButton { background:rgb(79,79,79); }");
|
2017-08-13 19:39:26 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-16 22:23:36 -04:00
|
|
|
void UDPSinkGUI::displaySettings()
|
|
|
|
{
|
2017-10-15 18:08:27 -04:00
|
|
|
m_channelMarker.blockSignals(true);
|
|
|
|
m_channelMarker.setCenterFrequency(m_settings.m_inputFrequencyOffset);
|
|
|
|
m_channelMarker.setBandwidth((int)m_settings.m_rfBandwidth);
|
|
|
|
m_channelMarker.setColor(m_settings.m_rgbColor);
|
|
|
|
m_channelMarker.setUDPAddress(m_settings.m_udpAddress);
|
|
|
|
m_channelMarker.setUDPReceivePort(m_settings.m_udpPort);
|
|
|
|
m_channelMarker.blockSignals(false);
|
|
|
|
|
|
|
|
setTitleColor(m_settings.m_rgbColor);
|
|
|
|
this->setWindowTitle(m_channelMarker.getTitle());
|
|
|
|
|
|
|
|
ui->deltaFrequency->setValue(m_settings.m_inputFrequencyOffset);
|
2017-10-15 16:55:00 -04:00
|
|
|
ui->sampleRate->setText(QString("%1").arg(roundf(m_settings.m_inputSampleRate), 0));
|
2017-10-15 18:08:27 -04:00
|
|
|
ui->glSpectrum->setSampleRate(m_settings.m_inputSampleRate);
|
2017-10-15 16:55:00 -04:00
|
|
|
ui->rfBandwidth->setText(QString("%1").arg(roundf(m_settings.m_rfBandwidth), 0));
|
|
|
|
ui->fmDeviation->setText(QString("%1").arg(m_settings.m_fmDeviation, 0));
|
2017-10-15 17:32:11 -04:00
|
|
|
ui->amModPercent->setText(QString("%1").arg(roundf(m_settings.m_amModFactor * 100.0), 0));
|
2017-10-15 16:55:00 -04:00
|
|
|
|
|
|
|
setSampleFormatIndex(m_settings.m_sampleFormat);
|
|
|
|
|
2017-10-15 17:32:11 -04:00
|
|
|
ui->channelMute->setChecked(m_settings.m_channelMute);
|
|
|
|
ui->autoRWBalance->setChecked(m_settings.m_autoRWBalance);
|
|
|
|
ui->stereoInput->setChecked(m_settings.m_stereoInput);
|
|
|
|
|
|
|
|
ui->gainInText->setText(tr("%1").arg(m_settings.m_gainIn, 0, 'f', 1));
|
|
|
|
ui->gainIn->setValue(roundf(m_settings.m_gainIn * 10.0));
|
|
|
|
|
|
|
|
ui->gainOutText->setText(tr("%1").arg(m_settings.m_gainOut, 0, 'f', 1));
|
|
|
|
ui->gainOut->setValue(roundf(m_settings.m_gainOut * 10.0));
|
|
|
|
|
|
|
|
if (m_settings.m_squelchEnabled) {
|
|
|
|
ui->squelchText->setText(tr("%1").arg(m_settings.m_squelch, 0, 'f', 0));
|
|
|
|
} else {
|
|
|
|
ui->squelchText->setText("---");
|
|
|
|
}
|
|
|
|
|
|
|
|
ui->squelch->setValue(roundf(m_settings.m_squelch));
|
|
|
|
|
|
|
|
ui->squelchGateText->setText(tr("%1").arg(roundf(m_settings.m_squelchGate * 1000.0), 0, 'f', 0));
|
|
|
|
ui->squelchGate->setValue(roundf(m_settings.m_squelchGate * 100.0));
|
|
|
|
|
2017-10-15 18:08:27 -04:00
|
|
|
ui->addressText->setText(tr("%1:%2").arg(m_settings.m_udpAddress).arg(m_settings.m_udpPort));
|
|
|
|
}
|
|
|
|
|
|
|
|
void UDPSinkGUI::displayUDPSettings()
|
|
|
|
{
|
2017-08-16 22:23:36 -04:00
|
|
|
}
|
|
|
|
|
2017-08-14 15:27:39 -04:00
|
|
|
void UDPSinkGUI::channelMarkerChanged()
|
|
|
|
{
|
2017-10-15 18:08:27 -04:00
|
|
|
m_settings.m_rgbColor = m_channelMarker.getColor().rgb();
|
|
|
|
m_settings.m_udpAddress = m_channelMarker.getUDPAddress();
|
|
|
|
m_settings.m_udpPort = m_channelMarker.getUDPReceivePort();
|
2017-08-25 05:26:59 -04:00
|
|
|
displaySettings();
|
2017-08-14 15:27:39 -04:00
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2017-08-14 10:09:56 -04:00
|
|
|
void UDPSinkGUI::on_deltaFrequency_changed(qint64 value)
|
|
|
|
{
|
2017-10-15 18:08:27 -04:00
|
|
|
m_settings.m_inputFrequencyOffset = value;
|
|
|
|
m_channelMarker.setCenterFrequency(value); // will trigger apply settings
|
2017-08-14 10:09:56 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void UDPSinkGUI::on_sampleFormat_currentIndexChanged(int index)
|
|
|
|
{
|
2017-10-15 14:31:33 -04:00
|
|
|
if ((index == (int) UDPSinkSettings::FormatNFM)) {
|
2017-08-14 10:09:56 -04:00
|
|
|
ui->fmDeviation->setEnabled(true);
|
|
|
|
} else {
|
|
|
|
ui->fmDeviation->setEnabled(false);
|
|
|
|
}
|
|
|
|
|
2017-10-15 14:31:33 -04:00
|
|
|
if (index == (int) UDPSinkSettings::FormatAM) {
|
2017-08-18 19:46:52 -04:00
|
|
|
ui->amModPercent->setEnabled(true);
|
|
|
|
} else {
|
|
|
|
ui->amModPercent->setEnabled(false);
|
|
|
|
}
|
|
|
|
|
2017-10-15 16:55:00 -04:00
|
|
|
setSampleFormat(index);
|
|
|
|
|
2017-08-14 10:09:56 -04:00
|
|
|
ui->applyBtn->setEnabled(true);
|
2017-08-18 21:42:56 -04:00
|
|
|
ui->applyBtn->setStyleSheet("QPushButton { background-color : green; }");
|
2017-08-14 10:09:56 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void UDPSinkGUI::on_sampleRate_textEdited(const QString& arg1 __attribute__((unused)))
|
|
|
|
{
|
2017-10-15 16:14:30 -04:00
|
|
|
bool ok;
|
|
|
|
Real inputSampleRate = ui->sampleRate->text().toDouble(&ok);
|
|
|
|
|
|
|
|
if ((!ok) || (inputSampleRate < 1000)) {
|
|
|
|
m_settings.m_inputSampleRate = 48000;
|
|
|
|
ui->sampleRate->setText(QString("%1").arg(m_settings.m_inputSampleRate, 0));
|
|
|
|
} else {
|
|
|
|
m_settings.m_inputSampleRate = inputSampleRate;
|
|
|
|
}
|
|
|
|
|
2017-08-14 10:09:56 -04:00
|
|
|
ui->applyBtn->setEnabled(true);
|
2017-08-18 21:42:56 -04:00
|
|
|
ui->applyBtn->setStyleSheet("QPushButton { background-color : green; }");
|
2017-08-14 10:09:56 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void UDPSinkGUI::on_rfBandwidth_textEdited(const QString& arg1 __attribute__((unused)))
|
|
|
|
{
|
2017-10-15 16:14:30 -04:00
|
|
|
bool ok;
|
|
|
|
Real rfBandwidth = ui->rfBandwidth->text().toDouble(&ok);
|
|
|
|
|
|
|
|
if ((!ok) || (rfBandwidth > m_settings.m_inputSampleRate)) {
|
|
|
|
m_settings.m_rfBandwidth = m_settings.m_inputSampleRate;
|
|
|
|
ui->rfBandwidth->setText(QString("%1").arg(m_settings.m_rfBandwidth, 0));
|
|
|
|
} else {
|
|
|
|
m_settings.m_rfBandwidth = rfBandwidth;
|
|
|
|
}
|
|
|
|
|
2017-08-14 10:09:56 -04:00
|
|
|
ui->applyBtn->setEnabled(true);
|
2017-08-18 21:42:56 -04:00
|
|
|
ui->applyBtn->setStyleSheet("QPushButton { background-color : green; }");
|
2017-08-14 10:09:56 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void UDPSinkGUI::on_fmDeviation_textEdited(const QString& arg1 __attribute__((unused)))
|
|
|
|
{
|
2017-10-15 16:55:00 -04:00
|
|
|
bool ok;
|
|
|
|
int fmDeviation = ui->fmDeviation->text().toInt(&ok);
|
|
|
|
|
|
|
|
if ((!ok) || (fmDeviation < 1)) {
|
|
|
|
m_settings.m_fmDeviation = 2500;
|
|
|
|
ui->fmDeviation->setText(QString("%1").arg(m_settings.m_fmDeviation));
|
|
|
|
} else {
|
|
|
|
m_settings.m_fmDeviation = fmDeviation;
|
|
|
|
}
|
|
|
|
|
2017-08-14 10:09:56 -04:00
|
|
|
ui->applyBtn->setEnabled(true);
|
2017-08-18 21:42:56 -04:00
|
|
|
ui->applyBtn->setStyleSheet("QPushButton { background-color : green; }");
|
2017-08-14 10:09:56 -04:00
|
|
|
}
|
|
|
|
|
2017-08-18 19:46:52 -04:00
|
|
|
void UDPSinkGUI::on_amModPercent_textEdited(const QString& arg1 __attribute__((unused)))
|
|
|
|
{
|
2017-10-15 16:55:00 -04:00
|
|
|
bool ok;
|
|
|
|
int amModPercent = ui->amModPercent->text().toInt(&ok);
|
|
|
|
|
|
|
|
if ((!ok) || (amModPercent < 1) || (amModPercent > 100))
|
|
|
|
{
|
|
|
|
m_settings.m_amModFactor = 0.95;
|
|
|
|
ui->amModPercent->setText(QString("%1").arg(95));
|
|
|
|
} else {
|
|
|
|
m_settings.m_amModFactor = amModPercent / 100.0;
|
|
|
|
}
|
|
|
|
|
2017-08-18 19:46:52 -04:00
|
|
|
ui->applyBtn->setEnabled(true);
|
2017-08-18 21:42:56 -04:00
|
|
|
ui->applyBtn->setStyleSheet("QPushButton { background-color : green; }");
|
2017-08-18 19:46:52 -04:00
|
|
|
}
|
|
|
|
|
2017-08-25 09:29:45 -04:00
|
|
|
void UDPSinkGUI::on_gainIn_valueChanged(int value)
|
2017-08-14 10:09:56 -04:00
|
|
|
{
|
2017-10-15 17:32:11 -04:00
|
|
|
m_settings.m_gainIn = value / 10.0;
|
|
|
|
ui->gainInText->setText(tr("%1").arg(m_settings.m_gainIn, 0, 'f', 1));
|
2017-08-25 09:29:45 -04:00
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void UDPSinkGUI::on_gainOut_valueChanged(int value)
|
|
|
|
{
|
2017-10-15 17:32:11 -04:00
|
|
|
m_settings.m_gainOut = value / 10.0;
|
|
|
|
ui->gainOutText->setText(tr("%1").arg(m_settings.m_gainOut, 0, 'f', 1));
|
2017-08-14 10:09:56 -04:00
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2017-08-16 22:23:36 -04:00
|
|
|
void UDPSinkGUI::on_squelch_valueChanged(int value)
|
|
|
|
{
|
2017-10-15 17:32:11 -04:00
|
|
|
m_settings.m_squelchEnabled = (value != -100);
|
|
|
|
m_settings.m_squelch = value * 1.0;
|
|
|
|
|
|
|
|
if (m_settings.m_squelchEnabled) {
|
|
|
|
ui->squelchText->setText(tr("%1").arg(m_settings.m_squelch, 0, 'f', 0));
|
|
|
|
} else {
|
2017-08-17 14:23:17 -04:00
|
|
|
ui->squelchText->setText("---");
|
|
|
|
}
|
|
|
|
|
2017-08-16 22:23:36 -04:00
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2017-08-18 18:52:10 -04:00
|
|
|
void UDPSinkGUI::on_squelchGate_valueChanged(int value)
|
|
|
|
{
|
2017-10-15 17:32:11 -04:00
|
|
|
m_settings.m_squelchGate = value / 100.0;
|
|
|
|
ui->squelchGateText->setText(tr("%1").arg(roundf(value * 10.0), 0, 'f', 0));
|
2017-08-18 18:52:10 -04:00
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2017-10-15 17:32:11 -04:00
|
|
|
void UDPSinkGUI::on_channelMute_toggled(bool checked)
|
2017-08-14 10:09:56 -04:00
|
|
|
{
|
2017-10-15 17:32:11 -04:00
|
|
|
m_settings.m_channelMute = checked;
|
2017-08-14 10:09:56 -04:00
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void UDPSinkGUI::on_applyBtn_clicked()
|
|
|
|
{
|
2017-10-15 18:08:27 -04:00
|
|
|
if (m_rfBandwidthChanged)
|
|
|
|
{
|
|
|
|
m_channelMarker.setBandwidth(m_settings.m_rfBandwidth); // will call apply settings
|
|
|
|
m_rfBandwidthChanged = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
applySettings();
|
|
|
|
}
|
2017-08-14 10:09:56 -04:00
|
|
|
}
|
|
|
|
|
2017-08-18 11:51:11 -04:00
|
|
|
void UDPSinkGUI::on_resetUDPReadIndex_clicked()
|
|
|
|
{
|
2017-10-17 03:02:33 -04:00
|
|
|
m_udpSink->resetReadIndex();
|
2017-08-18 11:51:11 -04:00
|
|
|
}
|
|
|
|
|
2017-10-15 17:32:11 -04:00
|
|
|
void UDPSinkGUI::on_autoRWBalance_toggled(bool checked)
|
2017-08-24 20:21:34 -04:00
|
|
|
{
|
2017-10-15 17:32:11 -04:00
|
|
|
m_settings.m_autoRWBalance = checked;
|
2017-08-24 20:21:34 -04:00
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2017-10-15 17:32:11 -04:00
|
|
|
void UDPSinkGUI::on_stereoInput_toggled(bool checked)
|
2017-08-25 03:48:07 -04:00
|
|
|
{
|
2017-10-15 17:32:11 -04:00
|
|
|
m_settings.m_stereoInput = checked;
|
2017-08-25 03:48:07 -04:00
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2017-08-14 10:09:56 -04:00
|
|
|
void UDPSinkGUI::onWidgetRolled(QWidget* widget, bool rollDown)
|
|
|
|
{
|
|
|
|
if ((widget == ui->spectrumBox) && (m_udpSink != 0))
|
|
|
|
{
|
2017-10-17 03:02:33 -04:00
|
|
|
m_udpSink->setSpectrum(rollDown);
|
2017-08-14 10:09:56 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-23 20:05:48 -04:00
|
|
|
void UDPSinkGUI::onMenuDialogCalled(const QPoint &p)
|
2017-08-14 10:09:56 -04:00
|
|
|
{
|
2017-08-23 20:05:48 -04:00
|
|
|
BasicChannelSettingsDialog dialog(&m_channelMarker, this);
|
|
|
|
dialog.move(p);
|
|
|
|
dialog.exec();
|
2017-08-14 10:09:56 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void UDPSinkGUI::leaveEvent(QEvent*)
|
|
|
|
{
|
|
|
|
blockApplySettings(true);
|
|
|
|
m_channelMarker.setHighlighted(false);
|
|
|
|
blockApplySettings(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void UDPSinkGUI::enterEvent(QEvent*)
|
|
|
|
{
|
|
|
|
blockApplySettings(true);
|
|
|
|
m_channelMarker.setHighlighted(true);
|
|
|
|
blockApplySettings(false);
|
|
|
|
}
|
|
|
|
|
2017-08-14 16:50:28 -04:00
|
|
|
void UDPSinkGUI::tick()
|
|
|
|
{
|
2017-08-16 22:23:36 -04:00
|
|
|
m_channelPowerAvg.feed(m_udpSink->getMagSq());
|
|
|
|
m_inPowerAvg.feed(m_udpSink->getInMagSq());
|
|
|
|
|
2017-08-17 06:57:45 -04:00
|
|
|
if (m_tickCount % 4 == 0)
|
2017-08-16 22:23:36 -04:00
|
|
|
{
|
|
|
|
double powDb = CalcDb::dbPower(m_channelPowerAvg.average());
|
|
|
|
ui->channelPower->setText(tr("%1 dB").arg(powDb, 0, 'f', 1));
|
|
|
|
double inPowDb = CalcDb::dbPower(m_inPowerAvg.average());
|
|
|
|
ui->inputPower->setText(tr("%1").arg(inPowDb, 0, 'f', 1));
|
|
|
|
}
|
2017-08-15 21:33:05 -04:00
|
|
|
|
|
|
|
int32_t bufferGauge = m_udpSink->getBufferGauge();
|
|
|
|
ui->bufferGaugeNegative->setValue((bufferGauge < 0 ? -bufferGauge : 0));
|
|
|
|
ui->bufferGaugePositive->setValue((bufferGauge < 0 ? 0 : bufferGauge));
|
|
|
|
QString s = QString::number(bufferGauge, 'f', 0);
|
|
|
|
ui->bufferRWBalanceText->setText(tr("%1").arg(s));
|
|
|
|
|
2017-08-16 22:23:36 -04:00
|
|
|
if (m_udpSink->getSquelchOpen()) {
|
|
|
|
ui->channelMute->setStyleSheet("QToolButton { background-color : green; }");
|
|
|
|
} else {
|
|
|
|
ui->channelMute->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
|
|
|
|
}
|
2017-08-17 06:57:45 -04:00
|
|
|
|
|
|
|
m_tickCount++;
|
2017-08-14 16:50:28 -04:00
|
|
|
}
|
|
|
|
|
2017-10-15 16:55:00 -04:00
|
|
|
void UDPSinkGUI::setSampleFormatIndex(const UDPSinkSettings::SampleFormat& sampleFormat)
|
|
|
|
{
|
|
|
|
switch(sampleFormat)
|
|
|
|
{
|
|
|
|
case UDPSinkSettings::FormatS16LE:
|
|
|
|
ui->sampleFormat->setCurrentIndex(0);
|
2017-10-15 18:28:01 -04:00
|
|
|
ui->fmDeviation->setEnabled(false);
|
|
|
|
ui->stereoInput->setChecked(true);
|
|
|
|
ui->stereoInput->setEnabled(false);
|
2017-10-15 16:55:00 -04:00
|
|
|
break;
|
|
|
|
case UDPSinkSettings::FormatNFM:
|
|
|
|
ui->sampleFormat->setCurrentIndex(1);
|
2017-10-15 18:28:01 -04:00
|
|
|
ui->fmDeviation->setEnabled(true);
|
|
|
|
ui->stereoInput->setEnabled(true);
|
2017-10-15 16:55:00 -04:00
|
|
|
break;
|
|
|
|
case UDPSinkSettings::FormatLSB:
|
|
|
|
ui->sampleFormat->setCurrentIndex(2);
|
2017-10-15 18:28:01 -04:00
|
|
|
ui->fmDeviation->setEnabled(false);
|
|
|
|
ui->stereoInput->setEnabled(true);
|
2017-10-15 16:55:00 -04:00
|
|
|
break;
|
|
|
|
case UDPSinkSettings::FormatUSB:
|
|
|
|
ui->sampleFormat->setCurrentIndex(3);
|
2017-10-15 18:28:01 -04:00
|
|
|
ui->fmDeviation->setEnabled(false);
|
|
|
|
ui->stereoInput->setEnabled(true);
|
2017-10-15 16:55:00 -04:00
|
|
|
break;
|
|
|
|
case UDPSinkSettings::FormatAM:
|
|
|
|
ui->sampleFormat->setCurrentIndex(4);
|
2017-10-15 18:28:01 -04:00
|
|
|
ui->fmDeviation->setEnabled(false);
|
|
|
|
ui->stereoInput->setEnabled(true);
|
2017-10-15 16:55:00 -04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ui->sampleFormat->setCurrentIndex(0);
|
2017-10-15 18:28:01 -04:00
|
|
|
ui->fmDeviation->setEnabled(false);
|
|
|
|
ui->stereoInput->setChecked(true);
|
|
|
|
ui->stereoInput->setEnabled(false);
|
2017-10-15 16:55:00 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void UDPSinkGUI::setSampleFormat(int index)
|
|
|
|
{
|
|
|
|
switch(index)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
m_settings.m_sampleFormat = UDPSinkSettings::FormatS16LE;
|
|
|
|
ui->fmDeviation->setEnabled(false);
|
|
|
|
ui->stereoInput->setChecked(true);
|
|
|
|
ui->stereoInput->setEnabled(false);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
m_settings.m_sampleFormat = UDPSinkSettings::FormatNFM;
|
|
|
|
ui->fmDeviation->setEnabled(true);
|
|
|
|
ui->stereoInput->setEnabled(true);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
m_settings.m_sampleFormat = UDPSinkSettings::FormatLSB;
|
|
|
|
ui->fmDeviation->setEnabled(false);
|
|
|
|
ui->stereoInput->setEnabled(true);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
m_settings.m_sampleFormat = UDPSinkSettings::FormatUSB;
|
|
|
|
ui->fmDeviation->setEnabled(false);
|
|
|
|
ui->stereoInput->setEnabled(true);
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
m_settings.m_sampleFormat = UDPSinkSettings::FormatAM;
|
|
|
|
ui->fmDeviation->setEnabled(false);
|
|
|
|
ui->stereoInput->setEnabled(true);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
m_settings.m_sampleFormat = UDPSinkSettings::FormatS16LE;
|
|
|
|
ui->fmDeviation->setEnabled(false);
|
|
|
|
ui->stereoInput->setChecked(true);
|
|
|
|
ui->stereoInput->setEnabled(false);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|