2019-02-24 18:13:57 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2019 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 //
|
2019-04-11 00:39:30 -04:00
|
|
|
// (at your option) any later version. //
|
2019-02-24 18:13:57 -05:00
|
|
|
// //
|
|
|
|
// 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 <QPixmap>
|
|
|
|
|
|
|
|
#include "freedvdemodgui.h"
|
|
|
|
|
|
|
|
#include "device/deviceuiset.h"
|
|
|
|
|
|
|
|
#include "dsp/spectrumvis.h"
|
|
|
|
#include "dsp/dspengine.h"
|
|
|
|
#include "dsp/dspcommands.h"
|
|
|
|
#include "gui/glspectrum.h"
|
|
|
|
#include "gui/basicchannelsettingsdialog.h"
|
2019-09-22 19:25:17 -04:00
|
|
|
#include "gui/devicestreamselectiondialog.h"
|
2022-12-20 05:31:15 -05:00
|
|
|
#include "gui/dialpopup.h"
|
|
|
|
#include "gui/dialogpositioner.h"
|
2019-02-24 18:13:57 -05:00
|
|
|
#include "plugin/pluginapi.h"
|
|
|
|
#include "util/simpleserializer.h"
|
|
|
|
#include "util/db.h"
|
|
|
|
#include "gui/crightclickenabler.h"
|
|
|
|
#include "gui/audioselectdialog.h"
|
2020-10-12 15:59:04 -04:00
|
|
|
#include "maincore.h"
|
2019-02-28 18:25:57 -05:00
|
|
|
|
|
|
|
#include "ui_freedvdemodgui.h"
|
2019-02-24 18:13:57 -05:00
|
|
|
#include "freedvdemod.h"
|
|
|
|
|
|
|
|
FreeDVDemodGUI* FreeDVDemodGUI::create(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSink *rxChannel)
|
|
|
|
{
|
|
|
|
FreeDVDemodGUI* gui = new FreeDVDemodGUI(pluginAPI, deviceUISet, rxChannel);
|
|
|
|
return gui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FreeDVDemodGUI::destroy()
|
|
|
|
{
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FreeDVDemodGUI::resetToDefaults()
|
|
|
|
{
|
|
|
|
m_settings.resetToDefaults();
|
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray FreeDVDemodGUI::serialize() const
|
|
|
|
{
|
|
|
|
return m_settings.serialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FreeDVDemodGUI::deserialize(const QByteArray& data)
|
|
|
|
{
|
|
|
|
if(m_settings.deserialize(data))
|
|
|
|
{
|
|
|
|
displaySettings();
|
2019-02-27 20:42:19 -05:00
|
|
|
applyBandwidths(5 - ui->spanLog2->value(), true); // does applySettings(true)
|
2019-02-24 18:13:57 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_settings.resetToDefaults();
|
|
|
|
displaySettings();
|
2019-02-27 20:42:19 -05:00
|
|
|
applyBandwidths(5 - ui->spanLog2->value(), true); // does applySettings(true)
|
2019-02-24 18:13:57 -05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FreeDVDemodGUI::handleMessage(const Message& message)
|
|
|
|
{
|
|
|
|
if (FreeDVDemod::MsgConfigureFreeDVDemod::match(message))
|
|
|
|
{
|
|
|
|
qDebug("FreeDVDemodGUI::handleMessage: FreeDVDemodGUI::MsgConfigureFreeDVDemod");
|
|
|
|
const FreeDVDemod::MsgConfigureFreeDVDemod& cfg = (FreeDVDemod::MsgConfigureFreeDVDemod&) message;
|
|
|
|
m_settings = cfg.getSettings();
|
|
|
|
blockApplySettings(true);
|
2021-11-30 18:20:14 -05:00
|
|
|
ui->spectrumGUI->updateSettings();
|
2021-12-02 17:54:39 -05:00
|
|
|
m_channelMarker.updateSettings(static_cast<const ChannelMarker*>(m_settings.m_channelMarker));
|
2019-02-24 18:13:57 -05:00
|
|
|
displaySettings();
|
|
|
|
blockApplySettings(false);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (DSPConfigureAudio::match(message))
|
|
|
|
{
|
|
|
|
qDebug("FreeDVDemodGUI::handleMessage: DSPConfigureAudio: %d", m_freeDVDemod->getAudioSampleRate());
|
|
|
|
applyBandwidths(5 - ui->spanLog2->value()); // will update spectrum details with new sample rate
|
|
|
|
return true;
|
|
|
|
}
|
2022-04-13 05:08:21 -04:00
|
|
|
else if (DSPSignalNotification::match(message))
|
|
|
|
{
|
|
|
|
DSPSignalNotification& notif = (DSPSignalNotification&) message;
|
|
|
|
m_deviceCenterFrequency = notif.getCenterFrequency();
|
|
|
|
m_basebandSampleRate = notif.getSampleRate();
|
|
|
|
ui->deltaFrequency->setValueRange(false, 7, -m_basebandSampleRate/2, m_basebandSampleRate/2);
|
|
|
|
ui->deltaFrequencyLabel->setToolTip(tr("Range %1 %L2 Hz").arg(QChar(0xB1)).arg(m_basebandSampleRate/2));
|
|
|
|
updateAbsoluteCenterFrequency();
|
|
|
|
return true;
|
|
|
|
}
|
2019-02-24 18:13:57 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FreeDVDemodGUI::handleInputMessages()
|
|
|
|
{
|
|
|
|
Message* message;
|
|
|
|
|
|
|
|
while ((message = getInputMessageQueue()->pop()) != 0)
|
|
|
|
{
|
|
|
|
if (handleMessage(*message))
|
|
|
|
{
|
|
|
|
delete message;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FreeDVDemodGUI::channelMarkerChangedByCursor()
|
|
|
|
{
|
|
|
|
ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency());
|
|
|
|
m_settings.m_inputFrequencyOffset = m_channelMarker.getCenterFrequency();
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FreeDVDemodGUI::channelMarkerHighlightedByCursor()
|
|
|
|
{
|
2022-04-25 18:42:26 -04:00
|
|
|
setHighlighted(m_channelMarker.getHighlighted());
|
2019-02-24 18:13:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void FreeDVDemodGUI::on_deltaFrequency_changed(qint64 value)
|
|
|
|
{
|
|
|
|
m_channelMarker.setCenterFrequency(value);
|
|
|
|
m_settings.m_inputFrequencyOffset = m_channelMarker.getCenterFrequency();
|
2022-04-13 05:08:21 -04:00
|
|
|
updateAbsoluteCenterFrequency();
|
2019-02-24 18:13:57 -05:00
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2019-02-27 08:53:50 -05:00
|
|
|
void FreeDVDemodGUI::on_reSync_clicked(bool checked)
|
|
|
|
{
|
2019-02-27 11:41:11 -05:00
|
|
|
(void) checked;
|
2019-02-27 08:53:50 -05:00
|
|
|
FreeDVDemod::MsgResyncFreeDVDemod* message = FreeDVDemod::MsgResyncFreeDVDemod::create();
|
|
|
|
m_freeDVDemod->getInputMessageQueue()->push(message);
|
|
|
|
}
|
|
|
|
|
2019-02-24 19:15:10 -05:00
|
|
|
void FreeDVDemodGUI::on_freeDVMode_currentIndexChanged(int index)
|
2019-02-24 18:13:57 -05:00
|
|
|
{
|
2019-02-24 19:15:10 -05:00
|
|
|
m_settings.m_freeDVMode = (FreeDVDemodSettings::FreeDVMode) index;
|
|
|
|
m_channelMarker.setBandwidth(FreeDVDemodSettings::getHiCutoff(m_settings.m_freeDVMode) * 2);
|
|
|
|
m_channelMarker.setLowCutoff(FreeDVDemodSettings::getLowCutoff(m_settings.m_freeDVMode));
|
|
|
|
m_channelMarker.setSidebands(ChannelMarker::usb);
|
|
|
|
applySettings();
|
2019-02-24 18:13:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void FreeDVDemodGUI::on_volume_valueChanged(int value)
|
|
|
|
{
|
|
|
|
ui->volumeText->setText(QString("%1").arg(value / 10.0, 0, 'f', 1));
|
|
|
|
m_settings.m_volume = value / 10.0;
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2019-02-28 09:15:04 -05:00
|
|
|
void FreeDVDemodGUI::on_volumeIn_valueChanged(int value)
|
|
|
|
{
|
|
|
|
ui->volumeInText->setText(QString("%1").arg(value / 10.0, 0, 'f', 1));
|
|
|
|
m_settings.m_volumeIn = value / 10.0;
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2019-02-24 18:13:57 -05:00
|
|
|
void FreeDVDemodGUI::on_agc_toggled(bool checked)
|
|
|
|
{
|
|
|
|
m_settings.m_agc = checked;
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FreeDVDemodGUI::on_audioMute_toggled(bool checked)
|
|
|
|
{
|
|
|
|
m_audioMute = checked;
|
|
|
|
m_settings.m_audioMute = checked;
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void FreeDVDemodGUI::on_spanLog2_valueChanged(int value)
|
|
|
|
{
|
|
|
|
if ((value < 0) || (value > 4)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
applyBandwidths(5 - ui->spanLog2->value());
|
|
|
|
}
|
|
|
|
|
|
|
|
void FreeDVDemodGUI::onMenuDialogCalled(const QPoint &p)
|
|
|
|
{
|
2019-05-09 15:07:05 -04:00
|
|
|
if (m_contextMenuType == ContextMenuChannelSettings)
|
|
|
|
{
|
|
|
|
BasicChannelSettingsDialog dialog(&m_channelMarker, this);
|
|
|
|
dialog.setUseReverseAPI(m_settings.m_useReverseAPI);
|
|
|
|
dialog.setReverseAPIAddress(m_settings.m_reverseAPIAddress);
|
|
|
|
dialog.setReverseAPIPort(m_settings.m_reverseAPIPort);
|
|
|
|
dialog.setReverseAPIDeviceIndex(m_settings.m_reverseAPIDeviceIndex);
|
|
|
|
dialog.setReverseAPIChannelIndex(m_settings.m_reverseAPIChannelIndex);
|
2022-04-17 19:42:03 -04:00
|
|
|
dialog.setDefaultTitle(m_displayedName);
|
|
|
|
|
|
|
|
if (m_deviceUISet->m_deviceMIMOEngine)
|
|
|
|
{
|
|
|
|
dialog.setNumberOfStreams(m_freeDVDemod->getNumberOfDeviceStreams());
|
|
|
|
dialog.setStreamIndex(m_settings.m_streamIndex);
|
|
|
|
}
|
2019-05-09 15:07:05 -04:00
|
|
|
|
|
|
|
dialog.move(p);
|
2022-12-20 05:31:15 -05:00
|
|
|
new DialogPositioner(&dialog, false);
|
2019-05-09 15:07:05 -04:00
|
|
|
dialog.exec();
|
|
|
|
|
|
|
|
m_settings.m_rgbColor = m_channelMarker.getColor().rgb();
|
|
|
|
m_settings.m_title = m_channelMarker.getTitle();
|
|
|
|
m_settings.m_useReverseAPI = dialog.useReverseAPI();
|
|
|
|
m_settings.m_reverseAPIAddress = dialog.getReverseAPIAddress();
|
|
|
|
m_settings.m_reverseAPIPort = dialog.getReverseAPIPort();
|
|
|
|
m_settings.m_reverseAPIDeviceIndex = dialog.getReverseAPIDeviceIndex();
|
|
|
|
m_settings.m_reverseAPIChannelIndex = dialog.getReverseAPIChannelIndex();
|
|
|
|
|
|
|
|
setWindowTitle(m_settings.m_title);
|
2022-04-12 10:20:45 -04:00
|
|
|
setTitle(m_channelMarker.getTitle());
|
2019-05-09 15:07:05 -04:00
|
|
|
setTitleColor(m_settings.m_rgbColor);
|
|
|
|
|
2022-04-17 19:42:03 -04:00
|
|
|
if (m_deviceUISet->m_deviceMIMOEngine)
|
|
|
|
{
|
|
|
|
m_settings.m_streamIndex = dialog.getSelectedStreamIndex();
|
|
|
|
m_channelMarker.clearStreamIndexes();
|
|
|
|
m_channelMarker.addStreamIndex(m_settings.m_streamIndex);
|
|
|
|
updateIndexLabel();
|
|
|
|
}
|
2019-09-22 19:25:17 -04:00
|
|
|
|
|
|
|
applySettings();
|
|
|
|
}
|
2019-02-24 18:13:57 -05:00
|
|
|
|
2019-05-09 15:07:05 -04:00
|
|
|
resetContextMenuType();
|
2019-02-24 18:13:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void FreeDVDemodGUI::onWidgetRolled(QWidget* widget, bool rollDown)
|
|
|
|
{
|
|
|
|
(void) widget;
|
|
|
|
(void) rollDown;
|
2021-11-24 04:50:42 -05:00
|
|
|
|
dd maximize button to MainSpectrum and expandible Channels and Features.
Add sizeToContents in ChannelGUI and FeatureGUI, called when widget is
rolled, so we can remove resizing code from all of the individual
channels and features.
In RollupContents, use minimumSizeHint for calculated size, so that
minimumWidth can come from .ui file.
In DeviceGUI::sizeToContents(), call adjustSize(), so Device GUIs start
out at minimum needed size (which should restore appearance prior to
last patch).
In stackSubWindows, use available space for channels if no
spectrum/features present.
In stackSubWindows, fix spectrum from being sized too big, resulting in
scroll bars appearing.
Reset user-defined channel width in stackSubWindows, when channels are
removed.
Don't stack maximized windows.
There's one hack in Channel/FeatureGUI::maximizeWindow(). It seems that
when maximimzing a window, QOpenGLWidgets aren't always paint properly
immediately afterwards, so the code forces an additional update. I can't
see why the first call to paintGL doesn't work.
2022-11-11 07:24:27 -05:00
|
|
|
getRollupContents()->saveState(m_rollupState);
|
2021-11-24 04:50:42 -05:00
|
|
|
applySettings();
|
2019-02-24 18:13:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
FreeDVDemodGUI::FreeDVDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSink *rxChannel, QWidget* parent) :
|
2020-10-04 00:16:15 -04:00
|
|
|
ChannelGUI(parent),
|
2019-02-24 18:13:57 -05:00
|
|
|
ui(new Ui::FreeDVDemodGUI),
|
|
|
|
m_pluginAPI(pluginAPI),
|
|
|
|
m_deviceUISet(deviceUISet),
|
|
|
|
m_channelMarker(this),
|
2022-04-13 05:08:21 -04:00
|
|
|
m_deviceCenterFrequency(0),
|
|
|
|
m_basebandSampleRate(1),
|
2019-02-24 18:13:57 -05:00
|
|
|
m_doApplySettings(true),
|
|
|
|
m_spectrumRate(6000),
|
|
|
|
m_audioBinaural(false),
|
|
|
|
m_audioFlipChannels(false),
|
|
|
|
m_audioMute(false),
|
2020-08-01 04:09:39 -04:00
|
|
|
m_squelchOpen(false),
|
|
|
|
m_audioSampleRate(-1)
|
2019-02-24 18:13:57 -05:00
|
|
|
{
|
|
|
|
setAttribute(Qt::WA_DeleteOnClose, true);
|
2022-04-24 06:28:56 -04:00
|
|
|
m_helpURL = "plugins/channelrx/demodfreedv/readme.md";
|
|
|
|
RollupContents *rollupContents = getRollupContents();
|
|
|
|
ui->setupUi(rollupContents);
|
|
|
|
setSizePolicy(rollupContents->sizePolicy());
|
|
|
|
rollupContents->arrangeRollups();
|
|
|
|
connect(rollupContents, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
|
2019-02-24 18:13:57 -05:00
|
|
|
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onMenuDialogCalled(const QPoint &)));
|
|
|
|
|
|
|
|
m_freeDVDemod = (FreeDVDemod*) rxChannel;
|
2020-04-30 03:57:05 -04:00
|
|
|
m_spectrumVis = m_freeDVDemod->getSpectrumVis();
|
|
|
|
m_spectrumVis->setGLSpectrum(ui->glSpectrum);
|
2019-02-24 18:13:57 -05:00
|
|
|
m_freeDVDemod->setMessageQueueToGUI(getInputMessageQueue());
|
|
|
|
|
|
|
|
resetToDefaults();
|
|
|
|
|
2023-04-09 05:47:50 -04:00
|
|
|
ui->spectrumGUI->setBuddies(m_spectrumVis, ui->glSpectrum);
|
|
|
|
|
2019-02-24 18:13:57 -05:00
|
|
|
ui->glSpectrum->setCenterFrequency(m_spectrumRate/2);
|
|
|
|
ui->glSpectrum->setSampleRate(m_spectrumRate);
|
2023-04-09 05:47:50 -04:00
|
|
|
|
|
|
|
SpectrumSettings spectrumSettings = m_spectrumVis->getSettings();
|
|
|
|
spectrumSettings.m_displayWaterfall = true;
|
|
|
|
spectrumSettings.m_displayMaxHold = false;
|
|
|
|
spectrumSettings.m_ssb = true;
|
|
|
|
SpectrumVis::MsgConfigureSpectrumVis *msg = SpectrumVis::MsgConfigureSpectrumVis::create(spectrumSettings, false);
|
|
|
|
m_spectrumVis->getInputMessageQueue()->push(msg);
|
2019-02-24 18:13:57 -05:00
|
|
|
|
2020-10-12 15:59:04 -04:00
|
|
|
connect(&MainCore::instance()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick()));
|
2019-02-24 18:13:57 -05:00
|
|
|
|
|
|
|
CRightClickEnabler *audioMuteRightClickEnabler = new CRightClickEnabler(ui->audioMute);
|
2022-12-28 14:33:28 -05:00
|
|
|
connect(audioMuteRightClickEnabler, SIGNAL(rightClick(const QPoint &)), this, SLOT(audioSelect(const QPoint &)));
|
2019-02-24 18:13:57 -05:00
|
|
|
|
|
|
|
ui->deltaFrequencyLabel->setText(QString("%1f").arg(QChar(0x94, 0x03)));
|
|
|
|
ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));
|
|
|
|
ui->deltaFrequency->setValueRange(false, 7, -9999999, 9999999);
|
|
|
|
ui->channelPowerMeter->setColorTheme(LevelMeterSignalDB::ColorGreenAndBlue);
|
2019-02-27 12:37:07 -05:00
|
|
|
ui->snrMeter->setColorTheme(LevelMeterSignalDB::ColorCyanAndBlue);
|
2019-02-27 20:42:19 -05:00
|
|
|
ui->snrMeter->setRange(-10, 30);
|
2019-02-27 12:37:07 -05:00
|
|
|
ui->snrMeter->setAverageSmoothing(2);
|
2019-02-24 18:13:57 -05:00
|
|
|
|
|
|
|
m_channelMarker.setVisible(true); // activate signal on the last setting only
|
|
|
|
|
|
|
|
m_settings.setChannelMarker(&m_channelMarker);
|
|
|
|
m_settings.setSpectrumGUI(ui->spectrumGUI);
|
2022-01-08 23:27:12 -05:00
|
|
|
m_settings.setRollupState(&m_rollupState);
|
2019-02-24 18:13:57 -05:00
|
|
|
|
|
|
|
m_deviceUISet->addChannelMarker(&m_channelMarker);
|
|
|
|
|
|
|
|
connect(&m_channelMarker, SIGNAL(changedByCursor()), this, SLOT(channelMarkerChangedByCursor()));
|
|
|
|
connect(&m_channelMarker, SIGNAL(highlightedByCursor()), this, SLOT(channelMarkerHighlightedByCursor()));
|
|
|
|
connect(getInputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
|
2019-12-08 04:09:24 -05:00
|
|
|
m_freeDVDemod->setLevelMeter(ui->volumeInMeter);
|
2019-02-24 18:13:57 -05:00
|
|
|
|
|
|
|
m_iconDSBUSB.addPixmap(QPixmap("://dsb.png"), QIcon::Normal, QIcon::On);
|
|
|
|
m_iconDSBUSB.addPixmap(QPixmap("://usb.png"), QIcon::Normal, QIcon::Off);
|
|
|
|
m_iconDSBLSB.addPixmap(QPixmap("://dsb.png"), QIcon::Normal, QIcon::On);
|
|
|
|
m_iconDSBLSB.addPixmap(QPixmap("://lsb.png"), QIcon::Normal, QIcon::Off);
|
|
|
|
|
|
|
|
displaySettings();
|
2022-04-12 10:20:45 -04:00
|
|
|
makeUIConnections();
|
2019-02-24 18:13:57 -05:00
|
|
|
applyBandwidths(5 - ui->spanLog2->value(), true); // does applySettings(true)
|
2022-12-20 05:31:15 -05:00
|
|
|
DialPopup::addPopupsToChildDials(this);
|
2019-02-24 18:13:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
FreeDVDemodGUI::~FreeDVDemodGUI()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FreeDVDemodGUI::blockApplySettings(bool block)
|
|
|
|
{
|
|
|
|
bool ret = !m_doApplySettings;
|
|
|
|
m_doApplySettings = !block;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FreeDVDemodGUI::applySettings(bool force)
|
|
|
|
{
|
|
|
|
if (m_doApplySettings)
|
|
|
|
{
|
|
|
|
FreeDVDemod::MsgConfigureFreeDVDemod* message = FreeDVDemod::MsgConfigureFreeDVDemod::create( m_settings, force);
|
|
|
|
m_freeDVDemod->getInputMessageQueue()->push(message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FreeDVDemodGUI::applyBandwidths(int spanLog2, bool force)
|
2019-04-17 11:34:02 -04:00
|
|
|
{
|
2019-08-26 17:55:23 -04:00
|
|
|
displayBandwidths(spanLog2);
|
2019-04-17 11:34:02 -04:00
|
|
|
m_settings.m_spanLog2 = spanLog2;
|
|
|
|
applySettings(force);
|
|
|
|
}
|
|
|
|
|
|
|
|
void FreeDVDemodGUI::displayBandwidths(int spanLog2)
|
2019-02-24 18:13:57 -05:00
|
|
|
{
|
2019-02-24 19:15:10 -05:00
|
|
|
m_spectrumRate = m_freeDVDemod->getModemSampleRate() / (1<<spanLog2);
|
|
|
|
int bwMax = m_freeDVDemod->getModemSampleRate() / (100*(1<<spanLog2));
|
2019-02-24 18:13:57 -05:00
|
|
|
|
2019-04-17 11:34:02 -04:00
|
|
|
qDebug() << "FreeDVDemodGUI::displayBandwidths:"
|
2019-02-24 18:13:57 -05:00
|
|
|
<< " spanLog2: " << spanLog2
|
|
|
|
<< " m_spectrumRate: " << m_spectrumRate
|
2019-02-24 19:15:10 -05:00
|
|
|
<< " bwMax: " << bwMax;
|
2019-02-24 18:13:57 -05:00
|
|
|
|
|
|
|
QString spanStr = QString::number(bwMax/10.0, 'f', 1);
|
|
|
|
|
2019-02-24 19:15:10 -05:00
|
|
|
ui->spanText->setText(tr("%1k").arg(spanStr));
|
2023-07-08 19:19:39 -04:00
|
|
|
ui->glSpectrum->setCenterFrequency(0);
|
|
|
|
ui->glSpectrum->setSampleRate(2*m_spectrumRate);
|
2019-02-24 19:15:10 -05:00
|
|
|
ui->glSpectrum->setLsbDisplay(false);
|
2023-07-08 19:19:39 -04:00
|
|
|
ui->glSpectrum->setSsbSpectrum(true);
|
2019-02-24 18:13:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void FreeDVDemodGUI::displaySettings()
|
|
|
|
{
|
|
|
|
m_channelMarker.blockSignals(true);
|
|
|
|
m_channelMarker.setCenterFrequency(m_settings.m_inputFrequencyOffset);
|
|
|
|
m_channelMarker.setTitle(m_settings.m_title);
|
2019-02-24 19:15:10 -05:00
|
|
|
m_channelMarker.setBandwidth(FreeDVDemodSettings::getHiCutoff(m_settings.m_freeDVMode) * 2);
|
|
|
|
m_channelMarker.setLowCutoff(FreeDVDemodSettings::getLowCutoff(m_settings.m_freeDVMode));
|
|
|
|
m_channelMarker.setSidebands(ChannelMarker::usb);
|
2019-02-24 18:13:57 -05:00
|
|
|
m_channelMarker.blockSignals(false);
|
|
|
|
m_channelMarker.setColor(m_settings.m_rgbColor); // activate signal on the last setting only
|
|
|
|
|
|
|
|
setTitleColor(m_settings.m_rgbColor);
|
|
|
|
setWindowTitle(m_channelMarker.getTitle());
|
2022-04-12 10:20:45 -04:00
|
|
|
setTitle(m_channelMarker.getTitle());
|
2019-02-24 18:13:57 -05:00
|
|
|
|
|
|
|
blockApplySettings(true);
|
|
|
|
|
2019-04-17 11:34:02 -04:00
|
|
|
ui->freeDVMode->setCurrentIndex((int) m_settings.m_freeDVMode);
|
2019-02-24 18:13:57 -05:00
|
|
|
ui->agc->setChecked(m_settings.m_agc);
|
|
|
|
ui->audioMute->setChecked(m_settings.m_audioMute);
|
|
|
|
ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency());
|
|
|
|
|
|
|
|
// Prevent uncontrolled triggering of applyBandwidths
|
|
|
|
ui->spanLog2->blockSignals(true);
|
|
|
|
ui->spanLog2->setValue(5 - m_settings.m_spanLog2);
|
2019-04-17 11:34:02 -04:00
|
|
|
displayBandwidths(m_settings.m_spanLog2);
|
2019-02-24 18:13:57 -05:00
|
|
|
ui->spanLog2->blockSignals(false);
|
|
|
|
|
|
|
|
ui->volume->setValue(m_settings.m_volume * 10.0);
|
|
|
|
ui->volumeText->setText(QString("%1").arg(m_settings.m_volume, 0, 'f', 1));
|
|
|
|
|
2019-02-28 18:25:57 -05:00
|
|
|
ui->volumeIn->setValue(m_settings.m_volumeIn * 10.0);
|
|
|
|
ui->volumeInText->setText(QString("%1").arg(m_settings.m_volumeIn, 0, 'f', 1));
|
|
|
|
|
2022-04-17 19:42:03 -04:00
|
|
|
updateIndexLabel();
|
2019-09-22 19:25:17 -04:00
|
|
|
|
2022-04-12 10:20:45 -04:00
|
|
|
getRollupContents()->restoreState(m_rollupState);
|
2022-04-13 05:08:21 -04:00
|
|
|
updateAbsoluteCenterFrequency();
|
2019-02-24 18:13:57 -05:00
|
|
|
blockApplySettings(false);
|
|
|
|
}
|
|
|
|
|
2022-04-22 13:21:24 -04:00
|
|
|
void FreeDVDemodGUI::leaveEvent(QEvent* event)
|
2019-02-24 18:13:57 -05:00
|
|
|
{
|
|
|
|
m_channelMarker.setHighlighted(false);
|
2022-04-22 13:21:24 -04:00
|
|
|
ChannelGUI::leaveEvent(event);
|
2019-02-24 18:13:57 -05:00
|
|
|
}
|
|
|
|
|
2022-11-17 09:36:12 -05:00
|
|
|
void FreeDVDemodGUI::enterEvent(EnterEventType* event)
|
2019-02-24 18:13:57 -05:00
|
|
|
{
|
|
|
|
m_channelMarker.setHighlighted(true);
|
2022-04-22 13:21:24 -04:00
|
|
|
ChannelGUI::enterEvent(event);
|
2019-02-24 18:13:57 -05:00
|
|
|
}
|
|
|
|
|
2022-12-28 14:33:28 -05:00
|
|
|
void FreeDVDemodGUI::audioSelect(const QPoint& p)
|
2019-02-24 18:13:57 -05:00
|
|
|
{
|
|
|
|
qDebug("FreeDVDemodGUI::audioSelect");
|
|
|
|
AudioSelectDialog audioSelect(DSPEngine::instance()->getAudioDeviceManager(), m_settings.m_audioDeviceName);
|
2022-12-28 14:33:28 -05:00
|
|
|
audioSelect.move(p);
|
2019-02-24 18:13:57 -05:00
|
|
|
audioSelect.exec();
|
|
|
|
|
|
|
|
if (audioSelect.m_selected)
|
|
|
|
{
|
|
|
|
m_settings.m_audioDeviceName = audioSelect.m_audioDeviceName;
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FreeDVDemodGUI::tick()
|
|
|
|
{
|
|
|
|
double magsqAvg, magsqPeak;
|
|
|
|
int nbMagsqSamples;
|
|
|
|
m_freeDVDemod->getMagSqLevels(magsqAvg, magsqPeak, nbMagsqSamples);
|
|
|
|
double powDbAvg = CalcDb::dbPower(magsqAvg);
|
|
|
|
double powDbPeak = CalcDb::dbPower(magsqPeak);
|
|
|
|
|
|
|
|
ui->channelPowerMeter->levelChanged(
|
|
|
|
(FreeDVDemodSettings::m_mminPowerThresholdDBf + powDbAvg) / FreeDVDemodSettings::m_mminPowerThresholdDBf,
|
|
|
|
(FreeDVDemodSettings::m_mminPowerThresholdDBf + powDbPeak) / FreeDVDemodSettings::m_mminPowerThresholdDBf,
|
|
|
|
nbMagsqSamples);
|
|
|
|
|
2019-02-27 12:37:07 -05:00
|
|
|
double snrAvg, snrPeak;
|
|
|
|
int nbSNRSamples;
|
|
|
|
m_freeDVDemod->getSNRLevels(snrAvg, snrPeak, nbSNRSamples);
|
|
|
|
|
|
|
|
ui->snrMeter->levelChanged(
|
2019-02-27 20:42:19 -05:00
|
|
|
(10.0f + snrAvg) / 40.0f,
|
|
|
|
(10.0f + snrPeak) / 40.0f,
|
2019-02-27 12:37:07 -05:00
|
|
|
nbSNRSamples
|
|
|
|
);
|
|
|
|
|
2019-02-27 20:42:19 -05:00
|
|
|
ui->berText->setText(tr("%1").arg(m_freeDVDemod->getBER()));
|
|
|
|
float freqOffset = m_freeDVDemod->getFrequencyOffset();
|
|
|
|
int freqOffsetInt = freqOffset < -999 ? -999 : freqOffset > 999 ? 999 : freqOffset;
|
|
|
|
ui->freqOffset->setText(tr("%1Hz").arg(freqOffsetInt));
|
|
|
|
|
|
|
|
if (m_freeDVDemod->isSync()) {
|
|
|
|
ui->syncLabel->setStyleSheet("QLabel { background-color : green; }");
|
|
|
|
} else {
|
|
|
|
ui->syncLabel->setStyleSheet("QLabel { background:rgb(79,79,79); }");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_tickCount % 4 == 0) {
|
|
|
|
ui->channelPower->setText(tr("%1 dB").arg(powDbAvg, 0, 'f', 1));
|
|
|
|
ui->snrText->setText(tr("%1 dB").arg(snrAvg < -90 ? -90 : snrAvg > 90 ? 90 : snrAvg, 0, 'f', 1));
|
|
|
|
}
|
|
|
|
|
2020-08-01 04:09:39 -04:00
|
|
|
int audioSampleRate = m_freeDVDemod->getAudioSampleRate();
|
2019-02-24 18:13:57 -05:00
|
|
|
bool squelchOpen = m_freeDVDemod->getAudioActive();
|
|
|
|
|
2020-08-01 04:09:39 -04:00
|
|
|
if ((audioSampleRate != m_audioSampleRate) || (squelchOpen != m_squelchOpen))
|
2019-02-24 18:13:57 -05:00
|
|
|
{
|
2020-08-01 04:09:39 -04:00
|
|
|
if (audioSampleRate < 0) {
|
|
|
|
ui->audioMute->setStyleSheet("QToolButton { background-color : red; }");
|
|
|
|
} else if (squelchOpen) {
|
2019-02-24 18:13:57 -05:00
|
|
|
ui->audioMute->setStyleSheet("QToolButton { background-color : green; }");
|
|
|
|
} else {
|
|
|
|
ui->audioMute->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
|
|
|
|
}
|
|
|
|
|
2020-08-01 04:09:39 -04:00
|
|
|
m_audioSampleRate = audioSampleRate;
|
2019-02-24 18:13:57 -05:00
|
|
|
m_squelchOpen = squelchOpen;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_tickCount++;
|
|
|
|
}
|
2022-04-12 10:20:45 -04:00
|
|
|
|
|
|
|
void FreeDVDemodGUI::makeUIConnections()
|
|
|
|
{
|
|
|
|
QObject::connect(ui->deltaFrequency, &ValueDialZ::changed, this, &FreeDVDemodGUI::on_deltaFrequency_changed);
|
|
|
|
QObject::connect(ui->reSync, &QPushButton::clicked, this, &FreeDVDemodGUI::on_reSync_clicked);
|
|
|
|
QObject::connect(ui->freeDVMode, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &FreeDVDemodGUI::on_freeDVMode_currentIndexChanged);
|
|
|
|
QObject::connect(ui->volume, &QDial::valueChanged, this, &FreeDVDemodGUI::on_volume_valueChanged);
|
|
|
|
QObject::connect(ui->volumeIn, &QDial::valueChanged, this, &FreeDVDemodGUI::on_volumeIn_valueChanged);
|
|
|
|
QObject::connect(ui->agc, &ButtonSwitch::toggled, this, &FreeDVDemodGUI::on_agc_toggled);
|
|
|
|
QObject::connect(ui->audioMute, &QToolButton::toggled, this, &FreeDVDemodGUI::on_audioMute_toggled);
|
2022-05-26 12:06:10 -04:00
|
|
|
QObject::connect(ui->spanLog2, &QSlider::valueChanged, this, &FreeDVDemodGUI::on_spanLog2_valueChanged);
|
2022-04-12 10:20:45 -04:00
|
|
|
}
|
2022-04-13 05:08:21 -04:00
|
|
|
|
|
|
|
void FreeDVDemodGUI::updateAbsoluteCenterFrequency()
|
|
|
|
{
|
|
|
|
setStatusFrequency(m_deviceCenterFrequency + m_settings.m_inputFrequencyOffset);
|
|
|
|
}
|