2016-04-08 12:14:50 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
2016-04-21 21:53:16 -04:00
|
|
|
// Copyright (C) 2016 F4EXB //
|
2016-04-08 12:14:50 -04:00
|
|
|
// written by Edouard Griffiths //
|
|
|
|
// //
|
|
|
|
// 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/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2017-05-07 04:23:37 -04:00
|
|
|
#include "dsddemodgui.h"
|
2016-10-02 07:18:07 -04:00
|
|
|
|
2016-10-10 19:17:55 -04:00
|
|
|
#include <device/devicesourceapi.h>
|
2016-10-02 15:52:39 -04:00
|
|
|
#include <dsp/downchannelizer.h>
|
2016-04-07 07:05:53 -04:00
|
|
|
#include <QDockWidget>
|
|
|
|
#include <QMainWindow>
|
|
|
|
#include <QDebug>
|
2016-10-03 09:55:16 -04:00
|
|
|
|
2017-05-07 04:23:37 -04:00
|
|
|
#include "dsp/threadedbasebandsamplesink.h"
|
2016-04-07 07:05:53 -04:00
|
|
|
#include "ui_dsddemodgui.h"
|
|
|
|
#include "dsp/scopevis.h"
|
2016-04-07 13:54:26 -04:00
|
|
|
#include "gui/glscope.h"
|
2016-04-07 07:05:53 -04:00
|
|
|
#include "plugin/pluginapi.h"
|
|
|
|
#include "util/simpleserializer.h"
|
|
|
|
#include "util/db.h"
|
|
|
|
#include "gui/basicchannelsettingswidget.h"
|
|
|
|
#include "dsp/dspengine.h"
|
|
|
|
#include "mainwindow.h"
|
|
|
|
|
2017-05-07 04:23:37 -04:00
|
|
|
#include "dsddemod.h"
|
2016-04-07 13:54:26 -04:00
|
|
|
|
2016-05-16 13:37:53 -04:00
|
|
|
const QString DSDDemodGUI::m_channelID = "sdrangel.channel.dsddemod";
|
|
|
|
|
2016-08-06 05:03:05 -04:00
|
|
|
unsigned int DSDDemodBaudRates::m_rates[] = {2400, 4800};
|
|
|
|
unsigned int DSDDemodBaudRates::m_nb_rates = 2;
|
|
|
|
unsigned int DSDDemodBaudRates::m_defaultRateIndex = 1; // 4800 bauds
|
|
|
|
|
2016-10-10 19:17:55 -04:00
|
|
|
DSDDemodGUI* DSDDemodGUI::create(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI)
|
2016-04-07 07:05:53 -04:00
|
|
|
{
|
2016-05-16 04:05:09 -04:00
|
|
|
DSDDemodGUI* gui = new DSDDemodGUI(pluginAPI, deviceAPI);
|
2016-04-07 07:05:53 -04:00
|
|
|
return gui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DSDDemodGUI::destroy()
|
|
|
|
{
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DSDDemodGUI::setName(const QString& name)
|
|
|
|
{
|
|
|
|
setObjectName(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString DSDDemodGUI::getName() const
|
|
|
|
{
|
|
|
|
return objectName();
|
|
|
|
}
|
|
|
|
|
|
|
|
qint64 DSDDemodGUI::getCenterFrequency() const
|
|
|
|
{
|
|
|
|
return m_channelMarker.getCenterFrequency();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DSDDemodGUI::setCenterFrequency(qint64 centerFrequency)
|
|
|
|
{
|
|
|
|
m_channelMarker.setCenterFrequency(centerFrequency);
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DSDDemodGUI::resetToDefaults()
|
|
|
|
{
|
|
|
|
blockApplySettings(true);
|
|
|
|
|
|
|
|
ui->rfBW->setValue(100); // x100 Hz
|
|
|
|
ui->demodGain->setValue(100); // 100ths
|
|
|
|
ui->fmDeviation->setValue(50); // x100 Hz
|
|
|
|
ui->volume->setValue(20); // /10.0
|
2016-08-06 05:03:05 -04:00
|
|
|
ui->baudRate->setCurrentIndex(DSDDemodBaudRates::getDefaultRateIndex());
|
2016-04-07 07:05:53 -04:00
|
|
|
ui->squelchGate->setValue(5);
|
|
|
|
ui->squelch->setValue(-40);
|
|
|
|
ui->deltaFrequency->setValue(0);
|
2017-05-07 04:23:37 -04:00
|
|
|
ui->symbolPLLLock->setChecked(true);
|
2016-04-07 07:05:53 -04:00
|
|
|
|
|
|
|
blockApplySettings(false);
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray DSDDemodGUI::serialize() const
|
|
|
|
{
|
|
|
|
SimpleSerializer s(1);
|
|
|
|
s.writeS32(1, m_channelMarker.getCenterFrequency());
|
|
|
|
s.writeS32(2, ui->rfBW->value());
|
|
|
|
s.writeS32(3, ui->demodGain->value());
|
|
|
|
s.writeS32(4, ui->fmDeviation->value());
|
|
|
|
s.writeS32(5, ui->squelch->value());
|
|
|
|
s.writeU32(7, m_channelMarker.getColor().rgb());
|
|
|
|
s.writeS32(8, ui->squelchGate->value());
|
|
|
|
s.writeS32(9, ui->volume->value());
|
2016-04-07 13:54:26 -04:00
|
|
|
s.writeBlob(10, ui->scopeGUI->serialize());
|
2016-08-06 05:03:05 -04:00
|
|
|
s.writeS32(11, ui->baudRate->currentIndex());
|
2016-08-18 13:38:39 -04:00
|
|
|
s.writeBool(12, m_enableCosineFiltering);
|
2016-08-24 19:06:42 -04:00
|
|
|
s.writeBool(13, m_syncOrConstellation);
|
2016-08-30 19:18:32 -04:00
|
|
|
s.writeBool(14, m_slot1On);
|
|
|
|
s.writeBool(15, m_slot2On);
|
2016-09-06 18:53:49 -04:00
|
|
|
s.writeBool(16, m_tdmaStereo);
|
2016-04-07 07:05:53 -04:00
|
|
|
return s.final();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DSDDemodGUI::deserialize(const QByteArray& data)
|
|
|
|
{
|
|
|
|
SimpleDeserializer d(data);
|
|
|
|
|
|
|
|
if (!d.isValid())
|
|
|
|
{
|
|
|
|
resetToDefaults();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (d.getVersion() == 1)
|
|
|
|
{
|
|
|
|
QByteArray bytetmp;
|
|
|
|
quint32 u32tmp;
|
|
|
|
qint32 tmp;
|
|
|
|
|
|
|
|
blockApplySettings(true);
|
|
|
|
m_channelMarker.blockSignals(true);
|
|
|
|
|
|
|
|
d.readS32(1, &tmp, 0);
|
|
|
|
m_channelMarker.setCenterFrequency(tmp);
|
|
|
|
d.readS32(2, &tmp, 4);
|
|
|
|
ui->rfBW->setValue(tmp);
|
|
|
|
d.readS32(3, &tmp, 3);
|
|
|
|
ui->demodGain->setValue(tmp);
|
|
|
|
d.readS32(4, &tmp, 20);
|
|
|
|
ui->fmDeviation->setValue(tmp);
|
|
|
|
d.readS32(5, &tmp, -40);
|
|
|
|
ui->squelch->setValue(tmp);
|
|
|
|
|
|
|
|
if(d.readU32(7, &u32tmp))
|
|
|
|
{
|
|
|
|
m_channelMarker.setColor(u32tmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
d.readS32(8, &tmp, 5);
|
|
|
|
ui->squelchGate->setValue(tmp);
|
|
|
|
d.readS32(9, &tmp, 20);
|
|
|
|
ui->volume->setValue(tmp);
|
2016-04-07 13:54:26 -04:00
|
|
|
d.readBlob(10, &bytetmp);
|
|
|
|
ui->scopeGUI->deserialize(bytetmp);
|
2016-08-06 05:03:05 -04:00
|
|
|
d.readS32(11, &tmp, 20);
|
|
|
|
ui->baudRate->setCurrentIndex(tmp);
|
2016-08-18 13:38:39 -04:00
|
|
|
d.readBool(12, &m_enableCosineFiltering, false);
|
2016-08-24 19:06:42 -04:00
|
|
|
d.readBool(13, &m_syncOrConstellation, false);
|
2016-08-30 19:18:32 -04:00
|
|
|
d.readBool(14, &m_slot1On, false);
|
|
|
|
d.readBool(15, &m_slot2On, false);
|
2016-09-06 18:53:49 -04:00
|
|
|
d.readBool(16, &m_tdmaStereo, false);
|
2016-04-07 07:05:53 -04:00
|
|
|
|
|
|
|
blockApplySettings(false);
|
|
|
|
m_channelMarker.blockSignals(false);
|
|
|
|
|
2016-09-28 11:58:29 -04:00
|
|
|
updateMyPosition(); // we do it also here to be able to refresh with latest settings
|
2016-04-07 07:05:53 -04:00
|
|
|
applySettings();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
resetToDefaults();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-25 14:13:34 -04:00
|
|
|
bool DSDDemodGUI::handleMessage(const Message& message __attribute__((unused)))
|
2016-04-07 07:05:53 -04:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DSDDemodGUI::viewChanged()
|
|
|
|
{
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2017-05-17 17:22:17 -04:00
|
|
|
void DSDDemodGUI::on_deltaFrequency_changed(qint64 value)
|
2016-04-07 07:05:53 -04:00
|
|
|
{
|
2017-05-17 17:34:14 -04:00
|
|
|
m_channelMarker.setCenterFrequency(value);
|
2016-04-07 07:05:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void DSDDemodGUI::on_rfBW_valueChanged(int value)
|
|
|
|
{
|
|
|
|
qDebug() << "DSDDemodGUI::on_rfBW_valueChanged" << value * 100;
|
|
|
|
m_channelMarker.setBandwidth(value * 100);
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2017-05-25 14:13:34 -04:00
|
|
|
void DSDDemodGUI::on_demodGain_valueChanged(int value __attribute__((unused)))
|
2016-04-07 07:05:53 -04:00
|
|
|
{
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2017-05-25 14:13:34 -04:00
|
|
|
void DSDDemodGUI::on_fmDeviation_valueChanged(int value __attribute__((unused)))
|
2016-04-07 07:05:53 -04:00
|
|
|
{
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2017-05-25 14:13:34 -04:00
|
|
|
void DSDDemodGUI::on_volume_valueChanged(int value __attribute__((unused)))
|
2016-04-07 07:05:53 -04:00
|
|
|
{
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2017-05-25 14:13:34 -04:00
|
|
|
void DSDDemodGUI::on_baudRate_currentIndexChanged(int index __attribute__((unused)))
|
2016-08-06 05:03:05 -04:00
|
|
|
{
|
|
|
|
applySettings();
|
|
|
|
}
|
2016-04-07 07:05:53 -04:00
|
|
|
|
2016-08-18 13:38:39 -04:00
|
|
|
void DSDDemodGUI::on_enableCosineFiltering_toggled(bool enable)
|
|
|
|
{
|
|
|
|
m_enableCosineFiltering = enable;
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2016-08-24 19:06:42 -04:00
|
|
|
void DSDDemodGUI::on_syncOrConstellation_toggled(bool checked)
|
|
|
|
{
|
|
|
|
m_syncOrConstellation = checked;
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2016-08-30 19:18:32 -04:00
|
|
|
void DSDDemodGUI::on_slot1On_toggled(bool checked)
|
|
|
|
{
|
|
|
|
m_slot1On = checked;
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DSDDemodGUI::on_slot2On_toggled(bool checked)
|
|
|
|
{
|
|
|
|
m_slot2On = checked;
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2016-09-06 18:16:08 -04:00
|
|
|
void DSDDemodGUI::on_tdmaStereoSplit_toggled(bool checked)
|
|
|
|
{
|
|
|
|
m_tdmaStereo = checked;
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2017-05-25 14:13:34 -04:00
|
|
|
void DSDDemodGUI::on_squelchGate_valueChanged(int value __attribute__((unused)))
|
2016-04-07 07:05:53 -04:00
|
|
|
{
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DSDDemodGUI::on_squelch_valueChanged(int value)
|
|
|
|
{
|
|
|
|
ui->squelchText->setText(QString("%1").arg(value / 10.0, 0, 'f', 1));
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DSDDemodGUI::on_audioMute_toggled(bool checked)
|
|
|
|
{
|
|
|
|
m_audioMute = checked;
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2017-05-07 04:23:37 -04:00
|
|
|
void DSDDemodGUI::on_symbolPLLLock_toggled(bool checked)
|
|
|
|
{
|
|
|
|
if (checked) {
|
|
|
|
ui->symbolPLLLock->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
|
|
|
|
} else {
|
|
|
|
ui->symbolPLLLock->setStyleSheet("QToolButton { background:rgb(53,53,53); }");
|
|
|
|
}
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2017-05-25 14:13:34 -04:00
|
|
|
void DSDDemodGUI::onWidgetRolled(QWidget* widget __attribute__((unused)), bool rollDown __attribute__((unused)))
|
2016-04-07 07:05:53 -04:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
if((widget == ui->spectrumContainer) && (DSDDemodGUI != NULL))
|
|
|
|
m_dsdDemod->setSpectrum(m_threadedSampleSink->getMessageQueue(), rollDown);
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
void DSDDemodGUI::onMenuDoubleClicked()
|
|
|
|
{
|
|
|
|
if (!m_basicSettingsShown)
|
|
|
|
{
|
|
|
|
m_basicSettingsShown = true;
|
|
|
|
BasicChannelSettingsWidget* bcsw = new BasicChannelSettingsWidget(&m_channelMarker, this);
|
|
|
|
bcsw->show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-10 19:17:55 -04:00
|
|
|
DSDDemodGUI::DSDDemodGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidget* parent) :
|
2016-04-07 07:05:53 -04:00
|
|
|
RollupWidget(parent),
|
|
|
|
ui(new Ui::DSDDemodGUI),
|
|
|
|
m_pluginAPI(pluginAPI),
|
2016-05-16 04:05:09 -04:00
|
|
|
m_deviceAPI(deviceAPI),
|
2016-04-07 07:05:53 -04:00
|
|
|
m_channelMarker(this),
|
|
|
|
m_basicSettingsShown(false),
|
|
|
|
m_doApplySettings(true),
|
2016-04-23 00:27:28 -04:00
|
|
|
m_signalFormat(signalFormatNone),
|
2016-08-18 13:38:39 -04:00
|
|
|
m_enableCosineFiltering(false),
|
2016-08-24 19:06:42 -04:00
|
|
|
m_syncOrConstellation(false),
|
2016-08-30 19:18:32 -04:00
|
|
|
m_slot1On(false),
|
|
|
|
m_slot2On(false),
|
2016-09-06 18:16:08 -04:00
|
|
|
m_tdmaStereo(false),
|
2016-04-07 07:05:53 -04:00
|
|
|
m_squelchOpen(false),
|
2016-04-21 21:53:16 -04:00
|
|
|
m_tickCount(0)
|
2016-04-07 07:05:53 -04:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
setAttribute(Qt::WA_DeleteOnClose, true);
|
|
|
|
|
|
|
|
connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
|
|
|
|
connect(this, SIGNAL(menuDoubleClickEvent()), this, SLOT(onMenuDoubleClicked()));
|
|
|
|
|
|
|
|
m_scopeVis = new ScopeVis(ui->glScope);
|
|
|
|
m_dsdDemod = new DSDDemod(m_scopeVis);
|
|
|
|
m_dsdDemod->registerGUI(this);
|
|
|
|
|
2016-04-07 13:54:26 -04:00
|
|
|
ui->glScope->setSampleRate(48000);
|
|
|
|
m_scopeVis->setSampleRate(48000);
|
|
|
|
|
2016-04-07 07:05:53 -04:00
|
|
|
ui->glScope->connectTimer(m_pluginAPI->getMainWindow()->getMasterTimer());
|
|
|
|
|
|
|
|
connect(&m_pluginAPI->getMainWindow()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick()));
|
|
|
|
|
2017-01-16 18:49:52 -05:00
|
|
|
ui->audioMute->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
|
|
|
|
|
2017-05-17 17:22:17 -04:00
|
|
|
ui->deltaFrequencyLabel->setText(QString("%1f").arg(QChar(0x94, 0x03)));
|
2017-05-16 11:48:12 -04:00
|
|
|
ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));
|
2017-05-17 17:22:17 -04:00
|
|
|
ui->deltaFrequency->setValueRange(false, 7, -9999999, 9999999);
|
2016-12-06 13:06:38 -05:00
|
|
|
ui->channelPowerMeter->setColorTheme(LevelMeterSignalDB::ColorGreenAndBlue);
|
2016-04-07 07:05:53 -04:00
|
|
|
|
2016-10-02 15:52:39 -04:00
|
|
|
m_channelizer = new DownChannelizer(m_dsdDemod);
|
2016-10-03 09:55:16 -04:00
|
|
|
m_threadedChannelizer = new ThreadedBasebandSampleSink(m_channelizer, this);
|
2016-05-16 04:05:09 -04:00
|
|
|
m_deviceAPI->addThreadedSink(m_threadedChannelizer);
|
2016-04-07 07:05:53 -04:00
|
|
|
|
|
|
|
//m_channelMarker = new ChannelMarker(this);
|
|
|
|
m_channelMarker.setColor(Qt::cyan);
|
|
|
|
m_channelMarker.setBandwidth(10000);
|
|
|
|
m_channelMarker.setCenterFrequency(0);
|
|
|
|
m_channelMarker.setVisible(true);
|
|
|
|
|
|
|
|
connect(&m_channelMarker, SIGNAL(changed()), this, SLOT(viewChanged()));
|
|
|
|
|
2016-05-16 13:37:53 -04:00
|
|
|
m_deviceAPI->registerChannelInstance(m_channelID, this);
|
2016-05-16 04:05:09 -04:00
|
|
|
m_deviceAPI->addChannelMarker(&m_channelMarker);
|
|
|
|
m_deviceAPI->addRollupWidget(this);
|
2016-04-07 07:05:53 -04:00
|
|
|
|
|
|
|
ui->scopeGUI->setBuddies(m_scopeVis->getInputMessageQueue(), m_scopeVis, ui->glScope);
|
|
|
|
|
2016-09-28 11:58:29 -04:00
|
|
|
updateMyPosition();
|
2016-04-07 07:05:53 -04:00
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
DSDDemodGUI::~DSDDemodGUI()
|
|
|
|
{
|
2016-05-16 13:37:53 -04:00
|
|
|
m_deviceAPI->removeChannelInstance(this);
|
2016-05-16 04:05:09 -04:00
|
|
|
m_deviceAPI->removeThreadedSink(m_threadedChannelizer);
|
2016-04-07 07:05:53 -04:00
|
|
|
delete m_threadedChannelizer;
|
|
|
|
delete m_channelizer;
|
|
|
|
delete m_dsdDemod;
|
|
|
|
//delete m_channelMarker;
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2016-09-28 11:58:29 -04:00
|
|
|
void DSDDemodGUI::updateMyPosition()
|
|
|
|
{
|
|
|
|
float latitude = m_pluginAPI->getMainWindow()->getMainSettings().getLatitude();
|
|
|
|
float longitude = m_pluginAPI->getMainWindow()->getMainSettings().getLongitude();
|
|
|
|
|
|
|
|
if ((m_myLatitude != latitude) || (m_myLongitude != longitude))
|
|
|
|
{
|
|
|
|
m_dsdDemod->configureMyPosition(m_dsdDemod->getInputMessageQueue(), latitude, longitude);
|
|
|
|
m_myLatitude = latitude;
|
|
|
|
m_myLongitude = longitude;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-07 07:05:53 -04:00
|
|
|
void DSDDemodGUI::applySettings()
|
|
|
|
{
|
|
|
|
if (m_doApplySettings)
|
|
|
|
{
|
|
|
|
qDebug() << "DSDDemodGUI::applySettings";
|
|
|
|
|
|
|
|
setTitleColor(m_channelMarker.getColor());
|
|
|
|
|
|
|
|
m_channelizer->configure(m_channelizer->getInputMessageQueue(),
|
|
|
|
48000,
|
|
|
|
m_channelMarker.getCenterFrequency());
|
|
|
|
|
2017-05-17 17:22:17 -04:00
|
|
|
ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency());
|
2016-04-07 07:05:53 -04:00
|
|
|
ui->rfBWText->setText(QString("%1k").arg(ui->rfBW->value() / 10.0, 0, 'f', 1));
|
|
|
|
ui->demodGainText->setText(QString("%1").arg(ui->demodGain->value() / 100.0, 0, 'f', 2));
|
|
|
|
ui->fmDeviationText->setText(QString("%1k").arg(ui->fmDeviation->value() / 10.0, 0, 'f', 1));
|
|
|
|
ui->squelchGateText->setText(QString("%1").arg(ui->squelchGate->value() * 10.0, 0, 'f', 0));
|
|
|
|
ui->volumeText->setText(QString("%1").arg(ui->volume->value() / 10.0, 0, 'f', 1));
|
2016-08-18 13:38:39 -04:00
|
|
|
ui->enableCosineFiltering->setChecked(m_enableCosineFiltering);
|
2016-08-24 19:06:42 -04:00
|
|
|
ui->syncOrConstellation->setChecked(m_syncOrConstellation);
|
2016-08-30 19:18:32 -04:00
|
|
|
ui->slot1On->setChecked(m_slot1On);
|
|
|
|
ui->slot2On->setChecked(m_slot2On);
|
2016-09-06 18:53:49 -04:00
|
|
|
ui->tdmaStereoSplit->setChecked(m_tdmaStereo);
|
2016-04-07 07:05:53 -04:00
|
|
|
|
|
|
|
m_dsdDemod->configure(m_dsdDemod->getInputMessageQueue(),
|
|
|
|
ui->rfBW->value(),
|
|
|
|
ui->demodGain->value(),
|
|
|
|
ui->fmDeviation->value(),
|
|
|
|
ui->volume->value(),
|
2016-08-06 05:03:05 -04:00
|
|
|
DSDDemodBaudRates::getRate(ui->baudRate->currentIndex()),
|
2016-04-07 07:05:53 -04:00
|
|
|
ui->squelchGate->value(), // in 10ths of ms
|
|
|
|
ui->squelch->value(),
|
2016-08-18 13:38:39 -04:00
|
|
|
ui->audioMute->isChecked(),
|
2016-08-24 19:06:42 -04:00
|
|
|
m_enableCosineFiltering,
|
2016-08-30 19:18:32 -04:00
|
|
|
m_syncOrConstellation,
|
|
|
|
m_slot1On,
|
2016-09-06 18:16:08 -04:00
|
|
|
m_slot2On,
|
2017-05-07 04:23:37 -04:00
|
|
|
m_tdmaStereo,
|
|
|
|
ui->symbolPLLLock->isChecked());
|
2016-04-07 07:05:53 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DSDDemodGUI::leaveEvent(QEvent*)
|
|
|
|
{
|
|
|
|
blockApplySettings(true);
|
|
|
|
m_channelMarker.setHighlighted(false);
|
|
|
|
blockApplySettings(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DSDDemodGUI::enterEvent(QEvent*)
|
|
|
|
{
|
|
|
|
blockApplySettings(true);
|
|
|
|
m_channelMarker.setHighlighted(true);
|
|
|
|
blockApplySettings(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DSDDemodGUI::blockApplySettings(bool block)
|
|
|
|
{
|
|
|
|
m_doApplySettings = !block;
|
|
|
|
}
|
|
|
|
|
2016-04-23 00:27:28 -04:00
|
|
|
void DSDDemodGUI::formatStatusText()
|
|
|
|
{
|
|
|
|
switch (m_dsdDemod->getDecoder().getSyncType())
|
|
|
|
{
|
2016-09-08 20:19:50 -04:00
|
|
|
case DSDcc::DSDDecoder::DSDSyncDMRDataMS:
|
2016-04-23 00:27:28 -04:00
|
|
|
case DSDcc::DSDDecoder::DSDSyncDMRDataP:
|
2016-09-08 20:19:50 -04:00
|
|
|
case DSDcc::DSDDecoder::DSDSyncDMRVoiceMS:
|
2016-04-23 00:27:28 -04:00
|
|
|
case DSDcc::DSDDecoder::DSDSyncDMRVoiceP:
|
|
|
|
if (m_signalFormat != signalFormatDMR)
|
|
|
|
{
|
2016-09-06 17:35:41 -04:00
|
|
|
strcpy(m_formatStatusText, "Sta: __ S1: __________________________ S2: __________________________");
|
2016-04-23 00:27:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (m_dsdDemod->getDecoder().getStationType())
|
|
|
|
{
|
|
|
|
case DSDcc::DSDDecoder::DSDBaseStation:
|
2016-08-28 17:53:39 -04:00
|
|
|
memcpy(&m_formatStatusText[5], "BS ", 3);
|
2016-04-23 00:27:28 -04:00
|
|
|
break;
|
|
|
|
case DSDcc::DSDDecoder::DSDMobileStation:
|
2016-08-28 17:53:39 -04:00
|
|
|
memcpy(&m_formatStatusText[5], "MS ", 3);
|
2016-04-23 00:27:28 -04:00
|
|
|
break;
|
|
|
|
default:
|
2016-08-28 17:53:39 -04:00
|
|
|
memcpy(&m_formatStatusText[5], "NA ", 3);
|
2016-04-23 00:27:28 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2017-01-12 20:16:28 -05:00
|
|
|
memcpy(&m_formatStatusText[12], m_dsdDemod->getDecoder().getDMRDecoder().getSlot0Text(), 26);
|
|
|
|
memcpy(&m_formatStatusText[43], m_dsdDemod->getDecoder().getDMRDecoder().getSlot1Text(), 26);
|
2016-04-23 00:27:28 -04:00
|
|
|
m_signalFormat = signalFormatDMR;
|
|
|
|
break;
|
|
|
|
case DSDcc::DSDDecoder::DSDSyncDStarHeaderN:
|
|
|
|
case DSDcc::DSDDecoder::DSDSyncDStarHeaderP:
|
|
|
|
case DSDcc::DSDDecoder::DSDSyncDStarN:
|
|
|
|
case DSDcc::DSDDecoder::DSDSyncDStarP:
|
|
|
|
if (m_signalFormat != signalFormatDStar)
|
|
|
|
{
|
2016-09-27 11:57:06 -04:00
|
|
|
// 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8
|
2016-09-27 13:56:42 -04:00
|
|
|
// 0....5....0....5....0....5....0....5....0....5....0....5....0....5....0....5....0..
|
2016-09-27 20:05:39 -04:00
|
|
|
strcpy(m_formatStatusText, "________/____>________|________>________|____________________|______:___/_____._");
|
2016-09-27 13:56:42 -04:00
|
|
|
// MY UR RPT1 RPT2 Info Loc Target
|
2016-04-23 00:27:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
const std::string& rpt1 = m_dsdDemod->getDecoder().getDStarDecoder().getRpt1();
|
|
|
|
const std::string& rpt2 = m_dsdDemod->getDecoder().getDStarDecoder().getRpt2();
|
|
|
|
const std::string& mySign = m_dsdDemod->getDecoder().getDStarDecoder().getMySign();
|
|
|
|
const std::string& yrSign = m_dsdDemod->getDecoder().getDStarDecoder().getYourSign();
|
|
|
|
|
|
|
|
if (rpt1.length() > 0) { // 0 or 8
|
2016-09-27 11:57:06 -04:00
|
|
|
memcpy(&m_formatStatusText[23], rpt1.c_str(), 8);
|
2016-04-23 00:27:28 -04:00
|
|
|
}
|
|
|
|
if (rpt2.length() > 0) { // 0 or 8
|
2016-09-27 11:57:06 -04:00
|
|
|
memcpy(&m_formatStatusText[32], rpt2.c_str(), 8);
|
2016-04-23 00:27:28 -04:00
|
|
|
}
|
|
|
|
if (yrSign.length() > 0) { // 0 or 8
|
2016-09-27 11:57:06 -04:00
|
|
|
memcpy(&m_formatStatusText[14], yrSign.c_str(), 8);
|
2016-04-23 00:27:28 -04:00
|
|
|
}
|
|
|
|
if (mySign.length() > 0) { // 0 or 13
|
2016-09-27 11:57:06 -04:00
|
|
|
memcpy(&m_formatStatusText[0], mySign.c_str(), 13);
|
2016-04-23 00:27:28 -04:00
|
|
|
}
|
2016-09-27 11:57:06 -04:00
|
|
|
memcpy(&m_formatStatusText[41], m_dsdDemod->getDecoder().getDStarDecoder().getInfoText(), 20);
|
2016-09-27 20:05:39 -04:00
|
|
|
memcpy(&m_formatStatusText[62], m_dsdDemod->getDecoder().getDStarDecoder().getLocator(), 6);
|
2017-05-06 06:24:57 -04:00
|
|
|
snprintf(&m_formatStatusText[69], 82-69, "%03d/%07.1f",
|
2016-09-28 07:39:17 -04:00
|
|
|
m_dsdDemod->getDecoder().getDStarDecoder().getBearing(),
|
|
|
|
m_dsdDemod->getDecoder().getDStarDecoder().getDistance());
|
2016-04-23 00:27:28 -04:00
|
|
|
}
|
|
|
|
|
2016-09-27 13:56:42 -04:00
|
|
|
m_formatStatusText[82] = '\0';
|
2016-04-23 00:27:28 -04:00
|
|
|
m_signalFormat = signalFormatDStar;
|
|
|
|
break;
|
2016-08-07 19:04:56 -04:00
|
|
|
case DSDcc::DSDDecoder::DSDSyncDPMR:
|
2017-05-06 06:24:57 -04:00
|
|
|
snprintf(m_formatStatusText, 82, "%s CC: %04d OI: %08d CI: %08d",
|
2017-01-12 20:16:28 -05:00
|
|
|
DSDcc::DSDdPMR::dpmrFrameTypes[(int) m_dsdDemod->getDecoder().getDPMRDecoder().getFrameType()],
|
2016-08-15 04:36:32 -04:00
|
|
|
m_dsdDemod->getDecoder().getDPMRDecoder().getColorCode(),
|
|
|
|
m_dsdDemod->getDecoder().getDPMRDecoder().getOwnId(),
|
|
|
|
m_dsdDemod->getDecoder().getDPMRDecoder().getCalledId());
|
2016-08-07 19:04:56 -04:00
|
|
|
m_signalFormat = signalFormatDPMR;
|
|
|
|
break;
|
2016-09-20 13:35:51 -04:00
|
|
|
case DSDcc::DSDDecoder::DSDSyncYSF:
|
2016-09-27 11:57:06 -04:00
|
|
|
// 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8
|
2016-09-27 13:56:42 -04:00
|
|
|
// 0....5....0....5....0....5....0....5....0....5....0....5....0....5....0....5....0..
|
2016-09-27 11:57:06 -04:00
|
|
|
// C V2 RI 0:7 WL000|ssssssssss>dddddddddd |UUUUUUUUUU>DDDDDDDDDD|44444
|
2016-09-20 13:35:51 -04:00
|
|
|
if (m_dsdDemod->getDecoder().getYSFDecoder().getFICHError() == DSDcc::DSDYSF::FICHNoError)
|
|
|
|
{
|
2017-01-29 08:55:54 -05:00
|
|
|
snprintf(m_formatStatusText, 82, "%s ", DSDcc::DSDYSF::ysfChannelTypeText[(int) m_dsdDemod->getDecoder().getYSFDecoder().getFICH().getFrameInformation()]);
|
2016-09-20 13:35:51 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-01-29 08:55:54 -05:00
|
|
|
snprintf(m_formatStatusText, 82, "%d ", (int) m_dsdDemod->getDecoder().getYSFDecoder().getFICHError());
|
2016-09-20 13:35:51 -04:00
|
|
|
}
|
2016-09-21 16:12:02 -04:00
|
|
|
|
2017-02-04 14:02:07 -05:00
|
|
|
snprintf(&m_formatStatusText[2], 80, "%s %s %d:%d %c%c",
|
2017-01-12 20:16:28 -05:00
|
|
|
DSDcc::DSDYSF::ysfDataTypeText[(int) m_dsdDemod->getDecoder().getYSFDecoder().getFICH().getDataType()],
|
|
|
|
DSDcc::DSDYSF::ysfCallModeText[(int) m_dsdDemod->getDecoder().getYSFDecoder().getFICH().getCallMode()],
|
2016-09-20 13:35:51 -04:00
|
|
|
m_dsdDemod->getDecoder().getYSFDecoder().getFICH().getBlockTotal(),
|
|
|
|
m_dsdDemod->getDecoder().getYSFDecoder().getFICH().getFrameTotal(),
|
|
|
|
(m_dsdDemod->getDecoder().getYSFDecoder().getFICH().isNarrowMode() ? 'N' : 'W'),
|
|
|
|
(m_dsdDemod->getDecoder().getYSFDecoder().getFICH().isInternetPath() ? 'I' : 'L'));
|
2016-09-21 16:12:02 -04:00
|
|
|
|
|
|
|
if (m_dsdDemod->getDecoder().getYSFDecoder().getFICH().isSquelchCodeEnabled())
|
2016-09-20 13:35:51 -04:00
|
|
|
{
|
2017-01-29 08:55:54 -05:00
|
|
|
snprintf(&m_formatStatusText[14], 82-14, "%03d", m_dsdDemod->getDecoder().getYSFDecoder().getFICH().getSquelchCode());
|
2016-09-20 13:35:51 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-01-29 08:55:54 -05:00
|
|
|
strncpy(&m_formatStatusText[14], "---", 82-14);
|
2016-09-20 13:35:51 -04:00
|
|
|
}
|
2016-09-21 16:12:02 -04:00
|
|
|
|
|
|
|
char dest[11];
|
|
|
|
|
|
|
|
if ( m_dsdDemod->getDecoder().getYSFDecoder().radioIdMode())
|
|
|
|
{
|
2017-02-04 14:02:07 -05:00
|
|
|
snprintf(dest, 10, "%-5s:%-5s",
|
2016-09-21 16:12:02 -04:00
|
|
|
m_dsdDemod->getDecoder().getYSFDecoder().getDestId(),
|
|
|
|
m_dsdDemod->getDecoder().getYSFDecoder().getSrcId());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-02-04 14:02:07 -05:00
|
|
|
snprintf(dest, 10, "%-10s", m_dsdDemod->getDecoder().getYSFDecoder().getDest());
|
2016-09-21 16:12:02 -04:00
|
|
|
}
|
|
|
|
|
2017-01-29 08:55:54 -05:00
|
|
|
snprintf(&m_formatStatusText[17], 82-17, "|%-10s>%s|%-10s>%-10s|%-5s",
|
2016-09-21 13:45:22 -04:00
|
|
|
m_dsdDemod->getDecoder().getYSFDecoder().getSrc(),
|
2016-09-21 16:12:02 -04:00
|
|
|
dest,
|
2016-09-21 13:45:22 -04:00
|
|
|
m_dsdDemod->getDecoder().getYSFDecoder().getUplink(),
|
|
|
|
m_dsdDemod->getDecoder().getYSFDecoder().getDownlink(),
|
|
|
|
m_dsdDemod->getDecoder().getYSFDecoder().getRem4());
|
2016-09-21 16:12:02 -04:00
|
|
|
|
|
|
|
m_signalFormat = signalFormatYSF;
|
2016-09-20 13:35:51 -04:00
|
|
|
break;
|
2016-04-23 00:27:28 -04:00
|
|
|
default:
|
|
|
|
m_signalFormat = signalFormatNone;
|
|
|
|
m_formatStatusText[0] = '\0';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-09-27 13:56:42 -04:00
|
|
|
m_formatStatusText[82] = '\0'; // guard
|
2016-04-23 00:27:28 -04:00
|
|
|
}
|
|
|
|
|
2016-04-07 07:05:53 -04:00
|
|
|
void DSDDemodGUI::tick()
|
|
|
|
{
|
2017-05-16 17:39:49 -04:00
|
|
|
double magsqAvg, magsqPeak;
|
2016-12-06 13:06:38 -05:00
|
|
|
int nbMagsqSamples;
|
|
|
|
m_dsdDemod->getMagSqLevels(magsqAvg, magsqPeak, nbMagsqSamples);
|
2017-05-16 17:39:49 -04:00
|
|
|
double powDbAvg = CalcDb::dbPower(magsqAvg);
|
|
|
|
double powDbPeak = CalcDb::dbPower(magsqPeak);
|
2016-12-06 13:06:38 -05:00
|
|
|
|
|
|
|
ui->channelPowerMeter->levelChanged(
|
|
|
|
(100.0f + powDbAvg) / 100.0f,
|
|
|
|
(100.0f + powDbPeak) / 100.0f,
|
|
|
|
nbMagsqSamples);
|
|
|
|
|
2017-08-17 11:48:47 -04:00
|
|
|
if (m_tickCount % 4 == 0) {
|
|
|
|
ui->channelPower->setText(tr("%1 dB").arg(powDbAvg, 0, 'f', 1));
|
|
|
|
}
|
2016-08-25 20:02:10 -04:00
|
|
|
|
2016-04-07 07:05:53 -04:00
|
|
|
bool squelchOpen = m_dsdDemod->getSquelchOpen();
|
|
|
|
|
|
|
|
if (squelchOpen != m_squelchOpen)
|
|
|
|
{
|
2017-01-16 18:49:52 -05:00
|
|
|
if (squelchOpen) {
|
2016-04-07 07:05:53 -04:00
|
|
|
ui->audioMute->setStyleSheet("QToolButton { background-color : green; }");
|
|
|
|
} else {
|
|
|
|
ui->audioMute->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
|
|
|
|
}
|
2017-01-16 18:49:52 -05:00
|
|
|
|
|
|
|
m_squelchOpen = squelchOpen;
|
2016-04-07 07:05:53 -04:00
|
|
|
}
|
2016-04-21 21:53:16 -04:00
|
|
|
|
|
|
|
// "slow" updates
|
|
|
|
|
2017-08-17 11:48:47 -04:00
|
|
|
if (m_tickCount % 10 == 0)
|
2016-04-21 21:53:16 -04:00
|
|
|
{
|
|
|
|
ui->inLevelText->setText(QString::number(m_dsdDemod->getDecoder().getInLevel()));
|
2016-08-17 20:47:49 -04:00
|
|
|
ui->inCarrierPosText->setText(QString::number(m_dsdDemod->getDecoder().getCarrierPos()));
|
|
|
|
ui->zcPosText->setText(QString::number(m_dsdDemod->getDecoder().getZeroCrossingPos()));
|
2016-08-18 07:35:11 -04:00
|
|
|
ui->symbolSyncQualityText->setText(QString::number(m_dsdDemod->getDecoder().getSymbolSyncQuality()));
|
2016-08-25 07:58:52 -04:00
|
|
|
|
2016-09-03 20:10:52 -04:00
|
|
|
if (m_dsdDemod->getDecoder().getVoice1On()) {
|
|
|
|
ui->slot1On->setStyleSheet("QToolButton { background-color : green; }");
|
|
|
|
} else {
|
|
|
|
ui->slot1On->setStyleSheet("QToolButton { background-color : rgb(79,79,79); }");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_dsdDemod->getDecoder().getVoice2On()) {
|
|
|
|
ui->slot2On->setStyleSheet("QToolButton { background-color : green; }");
|
|
|
|
} else {
|
|
|
|
ui->slot2On->setStyleSheet("QToolButton { background-color : rgb(79,79,79); }");
|
|
|
|
}
|
|
|
|
|
2016-08-25 07:58:52 -04:00
|
|
|
const char *frameTypeText = m_dsdDemod->getDecoder().getFrameTypeText();
|
|
|
|
|
|
|
|
if (frameTypeText[0] == '\0') {
|
|
|
|
ui->syncText->setStyleSheet("QLabel { background:rgb(53,53,53); }"); // turn off background
|
|
|
|
} else {
|
|
|
|
ui->syncText->setStyleSheet("QLabel { background:rgb(37,53,39); }"); // turn on background
|
|
|
|
}
|
|
|
|
|
|
|
|
ui->syncText->setText(QString(frameTypeText));
|
2016-04-23 00:27:28 -04:00
|
|
|
|
|
|
|
formatStatusText();
|
|
|
|
ui->formatStatusText->setText(QString(m_formatStatusText));
|
|
|
|
|
2016-04-23 05:31:40 -04:00
|
|
|
if (m_formatStatusText[0] == '\0') {
|
|
|
|
ui->formatStatusText->setStyleSheet("QLabel { background:rgb(53,53,53); }"); // turn off background
|
|
|
|
} else {
|
|
|
|
ui->formatStatusText->setStyleSheet("QLabel { background:rgb(37,53,39); }"); // turn on background
|
|
|
|
}
|
|
|
|
|
2017-05-07 04:23:37 -04:00
|
|
|
if (m_squelchOpen && ui->symbolPLLLock->isChecked() && m_dsdDemod->getDecoder().getSymbolPLLLocked()) {
|
2017-05-05 18:29:58 -04:00
|
|
|
ui->symbolPLLLock->setStyleSheet("QToolButton { background-color : green; }");
|
|
|
|
} else {
|
2017-05-07 04:23:37 -04:00
|
|
|
ui->symbolPLLLock->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
|
2017-05-05 18:29:58 -04:00
|
|
|
}
|
2016-04-21 21:53:16 -04:00
|
|
|
}
|
2017-08-17 11:48:47 -04:00
|
|
|
|
|
|
|
m_tickCount++;
|
2016-04-07 07:05:53 -04:00
|
|
|
}
|
2016-08-06 05:03:05 -04:00
|
|
|
|
|
|
|
unsigned int DSDDemodBaudRates::getRate(unsigned int rate_index)
|
|
|
|
{
|
|
|
|
if (rate_index < m_nb_rates)
|
|
|
|
{
|
|
|
|
return m_rates[rate_index];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return m_rates[m_defaultRateIndex];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int DSDDemodBaudRates::getRateIndex(unsigned int rate)
|
|
|
|
{
|
|
|
|
for (unsigned int i=0; i < m_nb_rates; i++)
|
|
|
|
{
|
|
|
|
if (rate == m_rates[i])
|
|
|
|
{
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return m_defaultRateIndex;
|
|
|
|
}
|