2017-10-24 07:45:10 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2017 F4HKW //
|
|
|
|
// for F4EXB / SDRAngel //
|
|
|
|
// //
|
|
|
|
// 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. //
|
2017-10-24 07:45:10 -04: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 <QDockWidget>
|
|
|
|
#include <QMainWindow>
|
|
|
|
|
|
|
|
#include "atvdemodgui.h"
|
|
|
|
|
2017-10-31 03:24:05 -04:00
|
|
|
#include "device/deviceuiset.h"
|
2017-10-24 07:45:10 -04:00
|
|
|
#include "dsp/downchannelizer.h"
|
|
|
|
|
|
|
|
#include "dsp/threadedbasebandsamplesink.h"
|
2018-08-12 11:22:39 -04:00
|
|
|
#include "dsp/scopevis.h"
|
2017-10-24 07:45:10 -04:00
|
|
|
#include "ui_atvdemodgui.h"
|
|
|
|
#include "plugin/pluginapi.h"
|
|
|
|
#include "util/simpleserializer.h"
|
|
|
|
#include "util/db.h"
|
|
|
|
#include "dsp/dspengine.h"
|
|
|
|
#include "mainwindow.h"
|
|
|
|
|
|
|
|
#include "atvdemod.h"
|
|
|
|
|
|
|
|
ATVDemodGUI* ATVDemodGUI::create(PluginAPI* objPluginAPI,
|
2017-11-08 19:03:05 -05:00
|
|
|
DeviceUISet *deviceUISet,
|
|
|
|
BasebandSampleSink *rxChannel)
|
2017-10-24 07:45:10 -04:00
|
|
|
{
|
2017-11-08 19:03:05 -05:00
|
|
|
ATVDemodGUI* gui = new ATVDemodGUI(objPluginAPI, deviceUISet, rxChannel);
|
2017-10-24 07:45:10 -04:00
|
|
|
return gui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ATVDemodGUI::destroy()
|
|
|
|
{
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ATVDemodGUI::setName(const QString& strName)
|
|
|
|
{
|
|
|
|
setObjectName(strName);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString ATVDemodGUI::getName() const
|
|
|
|
{
|
|
|
|
return objectName();
|
|
|
|
}
|
|
|
|
|
|
|
|
qint64 ATVDemodGUI::getCenterFrequency() const
|
|
|
|
{
|
|
|
|
return m_channelMarker.getCenterFrequency();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ATVDemodGUI::setCenterFrequency(qint64 intCenterFrequency)
|
|
|
|
{
|
|
|
|
m_channelMarker.setCenterFrequency(intCenterFrequency);
|
2019-12-01 09:13:35 -05:00
|
|
|
m_settings.m_inputFrequencyOffset = intCenterFrequency;
|
2017-10-24 07:45:10 -04:00
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ATVDemodGUI::resetToDefaults()
|
|
|
|
{
|
2019-12-01 09:13:35 -05:00
|
|
|
m_settings.resetToDefaults();
|
|
|
|
displaySettings();
|
|
|
|
applySettings(true);
|
2017-10-24 07:45:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray ATVDemodGUI::serialize() const
|
|
|
|
{
|
2019-12-01 09:13:35 -05:00
|
|
|
return m_settings.serialize();
|
2017-10-24 07:45:10 -04:00
|
|
|
}
|
|
|
|
|
2019-12-01 09:13:35 -05:00
|
|
|
bool ATVDemodGUI::deserialize(const QByteArray& data)
|
2017-10-24 07:45:10 -04:00
|
|
|
{
|
2019-12-01 09:13:35 -05:00
|
|
|
if(m_settings.deserialize(data))
|
2017-10-24 07:45:10 -04:00
|
|
|
{
|
2019-12-01 09:13:35 -05:00
|
|
|
displaySettings();
|
|
|
|
applySettings(true); // will have true
|
2017-10-24 07:45:10 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-12-01 09:13:35 -05:00
|
|
|
m_settings.resetToDefaults();
|
|
|
|
displaySettings();
|
|
|
|
applySettings(true); // will have true
|
2017-10-24 07:45:10 -04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-01 09:13:35 -05:00
|
|
|
void ATVDemodGUI::displaySettings()
|
2017-10-24 07:45:10 -04:00
|
|
|
{
|
2019-12-01 09:13:35 -05:00
|
|
|
m_channelMarker.blockSignals(true);
|
|
|
|
m_channelMarker.setCenterFrequency(m_settings.m_inputFrequencyOffset);
|
|
|
|
m_channelMarker.setTitle(m_settings.m_title);
|
|
|
|
setChannelMarkerBandwidth();
|
|
|
|
m_channelMarker.blockSignals(false);
|
|
|
|
m_channelMarker.setColor(m_settings.m_rgbColor); // activate signal on the last setting only
|
2017-10-24 07:45:10 -04:00
|
|
|
|
2019-12-01 09:13:35 -05:00
|
|
|
setTitleColor(m_settings.m_rgbColor);
|
|
|
|
setWindowTitle(m_channelMarker.getTitle());
|
|
|
|
displayStreamIndex();
|
|
|
|
|
|
|
|
blockApplySettings(true);
|
|
|
|
|
|
|
|
//********** ATV values **********
|
|
|
|
ui->synchLevel->setValue((int) (m_settings.m_levelSynchroTop * 1000.0f));
|
|
|
|
ui->synchLevelText->setText(QString("%1 mV").arg((int) (m_settings.m_levelSynchroTop * 1000.0f)));
|
|
|
|
ui->blackLevel->setValue((int) (m_settings.m_levelBlack * 1000.0f));
|
|
|
|
ui->blackLevelText->setText(QString("%1 mV").arg((int) (m_settings.m_levelBlack * 1000.0f)));
|
|
|
|
ui->lineTime->setValue(m_settings.m_lineTimeFactor);
|
|
|
|
ui->topTime->setValue(m_settings.m_topTimeFactor);
|
|
|
|
ui->modulation->setCurrentIndex((int) m_settings.m_atvModulation);
|
|
|
|
ui->fps->setCurrentIndex(ATVDemodSettings::getFpsIndex(m_settings.m_fps));
|
|
|
|
ui->nbLines->setCurrentIndex(ATVDemodSettings::getNumberOfLinesIndex(m_settings.m_nbLines));
|
|
|
|
ui->hSync->setChecked(m_settings.m_hSync);
|
|
|
|
ui->vSync->setChecked(m_settings.m_vSync);
|
|
|
|
ui->halfImage->setChecked(m_settings.m_halfFrames);
|
|
|
|
ui->invertVideo->setChecked(m_settings.m_invertVideo);
|
|
|
|
ui->standard->setCurrentIndex((int) m_settings.m_atvStd);
|
|
|
|
lineTimeUpdate();
|
|
|
|
topTimeUpdate();
|
|
|
|
|
|
|
|
//********** RF values **********
|
|
|
|
ui->decimatorEnable->setChecked(m_settings.m_forceDecimator);
|
|
|
|
ui->rfFiltering->setChecked(m_settings.m_fftFiltering);
|
|
|
|
ui->bfo->setValue(m_settings.m_bfoFrequency);
|
|
|
|
ui->bfoText->setText(QString("%1").arg(m_settings.m_bfoFrequency * 1.0, 0, 'f', 0));
|
|
|
|
ui->fmDeviation->setValue((int) (m_settings.m_fmDeviation * 1000.0f));
|
|
|
|
ui->fmDeviationText->setText(QString("%1").arg(m_settings.m_fmDeviation * 100.0, 0, 'f', 1));
|
|
|
|
blockApplySettings(false);
|
|
|
|
|
|
|
|
applyTVSampleRate();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ATVDemodGUI::displayStreamIndex()
|
|
|
|
{
|
|
|
|
if (m_deviceUISet->m_deviceMIMOEngine) {
|
|
|
|
setStreamIndicator(tr("%1").arg(m_settings.m_streamIndex));
|
|
|
|
} else {
|
|
|
|
setStreamIndicator("S"); // single channel indicator
|
2017-10-24 07:45:10 -04:00
|
|
|
}
|
2019-12-01 09:13:35 -05:00
|
|
|
}
|
2017-11-06 17:57:59 -05:00
|
|
|
|
2019-12-01 09:13:35 -05:00
|
|
|
void ATVDemodGUI::displayRFBandwidths()
|
|
|
|
{
|
|
|
|
int sliderPosition = m_settings.m_fftBandwidth / m_rfSliderDivisor;
|
|
|
|
sliderPosition < 1 ? 1 : sliderPosition > 100 ? 100 : sliderPosition;
|
|
|
|
ui->rfBW->setValue(sliderPosition);
|
|
|
|
ui->rfBWText->setText(QString("%1k").arg((sliderPosition * m_rfSliderDivisor) / 1000.0, 0, 'f', 0));
|
|
|
|
sliderPosition = m_settings.m_fftOppBandwidth / m_rfSliderDivisor;
|
|
|
|
sliderPosition < 0 ? 0 : sliderPosition > 100 ? 100 : sliderPosition;
|
|
|
|
ui->rfOppBW->setValue(sliderPosition);
|
|
|
|
ui->rfOppBWText->setText(QString("%1k").arg((sliderPosition * m_rfSliderDivisor) / 1000.0, 0, 'f', 0));
|
|
|
|
}
|
2017-11-06 17:57:59 -05:00
|
|
|
|
2019-12-01 09:13:35 -05:00
|
|
|
void ATVDemodGUI::applyTVSampleRate()
|
|
|
|
{
|
|
|
|
blockApplySettings(true);
|
|
|
|
unsigned int nbPointsPerLine;
|
|
|
|
ATVDemodSettings::getBaseValues(m_basebandSampleRate, m_settings.m_fps*m_settings.m_nbLines, m_tvSampleRate, nbPointsPerLine);
|
|
|
|
ui->tvSampleRateText->setText(tr("%1k").arg(m_tvSampleRate/1000.0f, 0, 'f', 2));
|
|
|
|
ui->nbPointsPerLineText->setText(tr("%1p").arg(nbPointsPerLine));
|
|
|
|
m_scopeVis->setLiveRate(m_tvSampleRate);
|
|
|
|
setRFFiltersSlidersRange(m_tvSampleRate);
|
|
|
|
displayRFBandwidths();
|
|
|
|
lineTimeUpdate();
|
|
|
|
topTimeUpdate();
|
|
|
|
blockApplySettings(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ATVDemodGUI::handleMessage(const Message& message)
|
|
|
|
{
|
|
|
|
if (DSPSignalNotification::match(message))
|
|
|
|
{
|
|
|
|
DSPSignalNotification& notif = (DSPSignalNotification&) message;
|
|
|
|
m_basebandSampleRate = notif.getSampleRate();
|
|
|
|
applyTVSampleRate();
|
2017-11-06 17:57:59 -05:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2017-10-24 07:45:10 -04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-13 19:06:19 -05:00
|
|
|
void ATVDemodGUI::channelMarkerChangedByCursor()
|
2017-10-24 07:45:10 -04:00
|
|
|
{
|
2017-11-13 19:06:19 -05:00
|
|
|
qDebug("ATVDemodGUI::channelMarkerChangedByCursor");
|
|
|
|
ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency());
|
2019-12-01 09:13:35 -05:00
|
|
|
m_settings.m_inputFrequencyOffset = m_channelMarker.getCenterFrequency();
|
2017-10-24 07:45:10 -04:00
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2017-11-14 16:58:35 -05:00
|
|
|
void ATVDemodGUI::channelMarkerHighlightedByCursor()
|
|
|
|
{
|
|
|
|
setHighlighted(m_channelMarker.getHighlighted());
|
|
|
|
}
|
|
|
|
|
2017-10-24 07:45:10 -04:00
|
|
|
void ATVDemodGUI::handleSourceMessages()
|
|
|
|
{
|
|
|
|
Message* message;
|
|
|
|
|
|
|
|
while ((message = getInputMessageQueue()->pop()) != 0)
|
|
|
|
{
|
|
|
|
if (handleMessage(*message))
|
|
|
|
{
|
|
|
|
delete message;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-12 18:45:03 -05:00
|
|
|
void ATVDemodGUI::onWidgetRolled(QWidget* widget, bool rollDown)
|
2017-10-24 07:45:10 -04:00
|
|
|
{
|
2018-11-12 18:45:03 -05:00
|
|
|
(void) widget;
|
|
|
|
(void) rollDown;
|
2017-10-24 07:45:10 -04:00
|
|
|
}
|
|
|
|
|
2017-11-08 19:03:05 -05:00
|
|
|
ATVDemodGUI::ATVDemodGUI(PluginAPI* objPluginAPI, DeviceUISet *deviceUISet, BasebandSampleSink *rxChannel, QWidget* objParent) :
|
2017-10-24 07:45:10 -04:00
|
|
|
RollupWidget(objParent),
|
|
|
|
ui(new Ui::ATVDemodGUI),
|
|
|
|
m_pluginAPI(objPluginAPI),
|
2017-10-31 03:24:05 -04:00
|
|
|
m_deviceUISet(deviceUISet),
|
2017-10-24 07:45:10 -04:00
|
|
|
m_channelMarker(this),
|
|
|
|
m_blnDoApplySettings(true),
|
2017-11-06 17:04:23 -05:00
|
|
|
m_intTickCount(0),
|
2019-12-01 09:13:35 -05:00
|
|
|
m_basebandSampleRate(48000),
|
|
|
|
m_tvSampleRate(48000)
|
2017-10-24 07:45:10 -04:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
2018-03-11 14:43:40 -04:00
|
|
|
ui->screenTV->setColor(false);
|
2017-10-24 07:45:10 -04:00
|
|
|
setAttribute(Qt::WA_DeleteOnClose, true);
|
|
|
|
connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
|
|
|
|
|
2018-08-12 11:18:58 -04:00
|
|
|
m_scopeVis = new ScopeVis(ui->glScope);
|
2017-11-08 19:03:05 -05:00
|
|
|
m_atvDemod = (ATVDemod*) rxChannel; //new ATVDemod(m_deviceUISet->m_deviceSourceAPI);
|
2017-10-24 07:45:10 -04:00
|
|
|
m_atvDemod->setMessageQueueToGUI(getInputMessageQueue());
|
2017-11-06 17:57:59 -05:00
|
|
|
m_atvDemod->setScopeSink(m_scopeVis);
|
2018-03-11 12:11:02 -04:00
|
|
|
m_atvDemod->setTVScreen(ui->screenTV);
|
2017-10-24 07:45:10 -04:00
|
|
|
|
|
|
|
ui->glScope->connectTimer(MainWindow::getInstance()->getMasterTimer());
|
|
|
|
connect(&MainWindow::getInstance()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick())); // 50 ms
|
|
|
|
|
|
|
|
ui->deltaFrequencyLabel->setText(QString("%1f").arg(QChar(0x94, 0x03)));
|
|
|
|
ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));
|
|
|
|
ui->deltaFrequency->setValueRange(false, 7, -9999999, 9999999);
|
|
|
|
|
2017-11-13 19:06:19 -05:00
|
|
|
m_channelMarker.blockSignals(true);
|
2017-10-24 07:45:10 -04:00
|
|
|
m_channelMarker.setColor(Qt::white);
|
|
|
|
m_channelMarker.setBandwidth(6000000);
|
|
|
|
m_channelMarker.setCenterFrequency(0);
|
2017-11-13 19:06:19 -05:00
|
|
|
m_channelMarker.blockSignals(false);
|
|
|
|
m_channelMarker.setVisible(true); // activate signal on the last setting only
|
2017-10-24 07:45:10 -04:00
|
|
|
|
2017-11-13 19:06:19 -05:00
|
|
|
setTitleColor(m_channelMarker.getColor());
|
2017-10-24 07:45:10 -04:00
|
|
|
|
2017-11-22 19:19:32 -05:00
|
|
|
m_deviceUISet->registerRxChannelInstance(ATVDemod::m_channelIdURI, this);
|
2017-10-31 03:24:05 -04:00
|
|
|
m_deviceUISet->addChannelMarker(&m_channelMarker);
|
|
|
|
m_deviceUISet->addRollupWidget(this);
|
2017-10-24 07:45:10 -04:00
|
|
|
|
|
|
|
ui->scopeGUI->setBuddies(m_scopeVis->getInputMessageQueue(), m_scopeVis, ui->glScope);
|
|
|
|
|
|
|
|
resetToDefaults(); // does applySettings()
|
|
|
|
|
|
|
|
ui->scopeGUI->setPreTrigger(1);
|
2018-08-12 11:18:58 -04:00
|
|
|
ScopeVis::TraceData traceData;
|
2017-10-24 07:45:10 -04:00
|
|
|
traceData.m_amp = 2.0; // amplification factor
|
|
|
|
traceData.m_ampIndex = 1; // this is second step
|
|
|
|
traceData.m_ofs = 0.5; // direct offset
|
|
|
|
traceData.m_ofsCoarse = 50; // this is 50 coarse steps
|
|
|
|
ui->scopeGUI->changeTrace(0, traceData);
|
|
|
|
ui->scopeGUI->focusOnTrace(0); // re-focus to take changes into account in the GUI
|
2018-08-12 11:18:58 -04:00
|
|
|
ScopeVis::TriggerData triggerData;
|
2017-10-24 07:45:10 -04:00
|
|
|
triggerData.m_triggerLevel = 0.1;
|
|
|
|
triggerData.m_triggerLevelCoarse = 10;
|
|
|
|
triggerData.m_triggerPositiveEdge = false;
|
|
|
|
ui->scopeGUI->changeTrigger(0, triggerData);
|
|
|
|
ui->scopeGUI->focusOnTrigger(0); // re-focus to take changes into account in the GUI
|
|
|
|
|
2017-11-13 19:06:19 -05:00
|
|
|
connect(&m_channelMarker, SIGNAL(changedByCursor()), this, SLOT(channelMarkerChangedByCursor()));
|
2017-11-14 16:58:35 -05:00
|
|
|
connect(&m_channelMarker, SIGNAL(highlightedByCursor()), this, SLOT(channelMarkerHighlightedByCursor()));
|
2017-10-24 07:45:10 -04:00
|
|
|
connect(getInputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleSourceMessages()));
|
|
|
|
|
|
|
|
QChar delta = QChar(0x94, 0x03);
|
|
|
|
ui->fmDeviationLabel->setText(delta);
|
|
|
|
}
|
|
|
|
|
|
|
|
ATVDemodGUI::~ATVDemodGUI()
|
|
|
|
{
|
2017-10-31 17:37:57 -04:00
|
|
|
m_deviceUISet->removeRxChannelInstance(this);
|
2017-11-08 19:03:05 -05:00
|
|
|
delete m_atvDemod; // TODO: check this: when the GUI closes it has to delete the demodulator
|
2017-10-24 07:45:10 -04:00
|
|
|
delete m_scopeVis;
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ATVDemodGUI::blockApplySettings(bool blnBlock)
|
|
|
|
{
|
|
|
|
m_blnDoApplySettings = !blnBlock;
|
|
|
|
}
|
|
|
|
|
2019-12-01 09:13:35 -05:00
|
|
|
void ATVDemodGUI::applySettings(bool force)
|
2017-10-24 07:45:10 -04:00
|
|
|
{
|
|
|
|
if (m_blnDoApplySettings)
|
|
|
|
{
|
2019-12-01 09:13:35 -05:00
|
|
|
ATVDemod::MsgConfigureATVDemod *msg = ATVDemod::MsgConfigureATVDemod::create(m_settings, force);
|
|
|
|
m_atvDemod->getInputMessageQueue()->push(msg);
|
2017-10-24 07:45:10 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ATVDemodGUI::setChannelMarkerBandwidth()
|
|
|
|
{
|
|
|
|
m_blnDoApplySettings = false; // avoid infinite recursion
|
2017-11-13 19:06:19 -05:00
|
|
|
m_channelMarker.blockSignals(true);
|
2017-10-24 07:45:10 -04:00
|
|
|
|
|
|
|
if (ui->rfFiltering->isChecked()) // FFT filter
|
|
|
|
{
|
|
|
|
m_channelMarker.setBandwidth(ui->rfBW->value()*m_rfSliderDivisor);
|
|
|
|
m_channelMarker.setOppositeBandwidth(ui->rfOppBW->value()*m_rfSliderDivisor);
|
|
|
|
|
2019-12-01 09:13:35 -05:00
|
|
|
if (ui->modulation->currentIndex() == (int) ATVDemodSettings::ATV_LSB) {
|
2017-10-24 07:45:10 -04:00
|
|
|
m_channelMarker.setSidebands(ChannelMarker::vlsb);
|
2019-12-01 09:13:35 -05:00
|
|
|
} else if (ui->modulation->currentIndex() == (int) ATVDemodSettings::ATV_USB) {
|
2017-10-24 07:45:10 -04:00
|
|
|
m_channelMarker.setSidebands(ChannelMarker::vusb);
|
|
|
|
} else {
|
|
|
|
m_channelMarker.setSidebands(ChannelMarker::vusb);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-12-01 09:13:35 -05:00
|
|
|
if ((m_basebandSampleRate == m_tvSampleRate) && (!m_settings.m_forceDecimator)) {
|
|
|
|
m_channelMarker.setBandwidth(m_basebandSampleRate);
|
2017-10-24 07:45:10 -04:00
|
|
|
} else {
|
2019-12-01 09:13:35 -05:00
|
|
|
m_channelMarker.setBandwidth(ui->rfBW->value()*m_rfSliderDivisor);
|
2017-10-24 07:45:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
m_channelMarker.setSidebands(ChannelMarker::dsb);
|
|
|
|
}
|
|
|
|
|
2017-11-13 19:06:19 -05:00
|
|
|
m_channelMarker.blockSignals(false);
|
|
|
|
m_channelMarker.emitChangedByAPI();
|
2017-10-24 07:45:10 -04:00
|
|
|
m_blnDoApplySettings = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ATVDemodGUI::setRFFiltersSlidersRange(int sampleRate)
|
|
|
|
{
|
|
|
|
// RF filters sliders range
|
|
|
|
int scaleFactor = (int) std::log10(sampleRate/2);
|
|
|
|
m_rfSliderDivisor = std::pow(10.0, scaleFactor-1);
|
|
|
|
|
|
|
|
if (sampleRate/m_rfSliderDivisor < 50) {
|
|
|
|
m_rfSliderDivisor /= 10;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ui->rfFiltering->isChecked())
|
|
|
|
{
|
|
|
|
ui->rfBW->setMaximum((sampleRate) / (2*m_rfSliderDivisor));
|
|
|
|
ui->rfOppBW->setMaximum((sampleRate) / (2*m_rfSliderDivisor));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui->rfBW->setMaximum((sampleRate) / m_rfSliderDivisor);
|
|
|
|
ui->rfOppBW->setMaximum((sampleRate) / m_rfSliderDivisor);
|
|
|
|
}
|
|
|
|
|
|
|
|
ui->rfBWText->setText(QString("%1k").arg((ui->rfBW->value() * m_rfSliderDivisor) / 1000.0, 0, 'f', 0));
|
|
|
|
ui->rfOppBWText->setText(QString("%1k").arg((ui->rfOppBW->value() * m_rfSliderDivisor) / 1000.0, 0, 'f', 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
void ATVDemodGUI::leaveEvent(QEvent*)
|
|
|
|
{
|
|
|
|
m_channelMarker.setHighlighted(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ATVDemodGUI::enterEvent(QEvent*)
|
|
|
|
{
|
|
|
|
m_channelMarker.setHighlighted(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ATVDemodGUI::tick()
|
|
|
|
{
|
|
|
|
if (m_intTickCount < 4) // ~200 ms
|
|
|
|
{
|
|
|
|
m_intTickCount++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (m_atvDemod)
|
|
|
|
{
|
2018-02-03 04:33:02 -05:00
|
|
|
m_objMagSqAverage(m_atvDemod->getMagSq());
|
|
|
|
double magSqDB = CalcDb::dbPower(m_objMagSqAverage / (SDR_RX_SCALED*SDR_RX_SCALED));
|
2017-10-24 07:45:10 -04:00
|
|
|
ui->channePowerText->setText(tr("%1 dB").arg(magSqDB, 0, 'f', 1));
|
|
|
|
|
|
|
|
if (m_atvDemod->getBFOLocked()) {
|
|
|
|
ui->bfoLockedLabel->setStyleSheet("QLabel { background-color : green; }");
|
|
|
|
} else {
|
|
|
|
ui->bfoLockedLabel->setStyleSheet("QLabel { background:rgb(79,79,79); }");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_intTickCount = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ATVDemodGUI::on_synchLevel_valueChanged(int value)
|
|
|
|
{
|
|
|
|
ui->synchLevelText->setText(QString("%1 mV").arg(value));
|
2019-12-01 09:13:35 -05:00
|
|
|
m_settings.m_levelSynchroTop = value / 1000.0f;
|
|
|
|
applySettings();
|
2017-10-24 07:45:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void ATVDemodGUI::on_blackLevel_valueChanged(int value)
|
|
|
|
{
|
|
|
|
ui->blackLevelText->setText(QString("%1 mV").arg(value));
|
2019-12-01 09:13:35 -05:00
|
|
|
m_settings.m_levelBlack = value / 1000.0f;
|
|
|
|
applySettings();
|
2017-10-24 07:45:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void ATVDemodGUI::on_lineTime_valueChanged(int value)
|
|
|
|
{
|
|
|
|
ui->lineTime->setToolTip(QString("Line length adjustment (%1)").arg(value));
|
2019-12-01 09:13:35 -05:00
|
|
|
m_settings.m_lineTimeFactor = value;
|
2017-10-24 07:45:10 -04:00
|
|
|
lineTimeUpdate();
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ATVDemodGUI::on_topTime_valueChanged(int value)
|
|
|
|
{
|
|
|
|
ui->topTime->setToolTip(QString("Horizontal sync pulse length adjustment (%1)").arg(value));
|
2019-12-01 09:13:35 -05:00
|
|
|
m_settings.m_topTimeFactor = value;
|
2017-10-24 07:45:10 -04:00
|
|
|
topTimeUpdate();
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ATVDemodGUI::on_hSync_clicked()
|
|
|
|
{
|
2019-12-01 09:13:35 -05:00
|
|
|
m_settings.m_hSync = ui->hSync->isChecked();
|
2017-10-24 07:45:10 -04:00
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ATVDemodGUI::on_vSync_clicked()
|
|
|
|
{
|
2019-12-01 09:13:35 -05:00
|
|
|
m_settings.m_vSync = ui->vSync->isChecked();
|
2017-10-24 07:45:10 -04:00
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ATVDemodGUI::on_invertVideo_clicked()
|
|
|
|
{
|
2019-12-01 09:13:35 -05:00
|
|
|
m_settings.m_invertVideo = ui->invertVideo->isChecked();
|
2017-10-24 07:45:10 -04:00
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ATVDemodGUI::on_halfImage_clicked()
|
|
|
|
{
|
2019-12-01 09:13:35 -05:00
|
|
|
m_settings.m_halfFrames = ui->halfImage->isChecked();
|
2017-10-24 07:45:10 -04:00
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2018-11-12 18:45:03 -05:00
|
|
|
void ATVDemodGUI::on_nbLines_currentIndexChanged(int index)
|
2017-10-24 07:45:10 -04:00
|
|
|
{
|
2019-12-01 09:13:35 -05:00
|
|
|
m_settings.m_nbLines = ATVDemodSettings::getNumberOfLines(index);
|
|
|
|
applyTVSampleRate();
|
2017-10-24 07:45:10 -04:00
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2018-11-12 18:45:03 -05:00
|
|
|
void ATVDemodGUI::on_fps_currentIndexChanged(int index)
|
2017-10-24 07:45:10 -04:00
|
|
|
{
|
2019-12-01 09:13:35 -05:00
|
|
|
m_settings.m_fps = ATVDemodSettings::getFps(index);
|
|
|
|
applyTVSampleRate();
|
2017-10-24 07:45:10 -04:00
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2018-11-12 18:45:03 -05:00
|
|
|
void ATVDemodGUI::on_standard_currentIndexChanged(int index)
|
2017-10-24 07:45:10 -04:00
|
|
|
{
|
2019-12-01 09:13:35 -05:00
|
|
|
m_settings.m_atvStd = (ATVDemodSettings::ATVStd) index;
|
2017-10-24 07:45:10 -04:00
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2018-11-12 18:45:03 -05:00
|
|
|
void ATVDemodGUI::on_reset_clicked(bool checked)
|
2017-10-24 07:45:10 -04:00
|
|
|
{
|
2018-11-12 18:45:03 -05:00
|
|
|
(void) checked;
|
2017-10-24 07:45:10 -04:00
|
|
|
resetToDefaults();
|
|
|
|
}
|
|
|
|
|
2018-11-12 18:45:03 -05:00
|
|
|
void ATVDemodGUI::on_modulation_currentIndexChanged(int index)
|
2017-10-24 07:45:10 -04:00
|
|
|
{
|
2019-12-01 09:13:35 -05:00
|
|
|
m_settings.m_atvModulation = (ATVDemodSettings::ATVModulation) index;
|
|
|
|
setRFFiltersSlidersRange(m_tvSampleRate);
|
2017-10-24 07:45:10 -04:00
|
|
|
setChannelMarkerBandwidth();
|
2019-12-01 09:13:35 -05:00
|
|
|
applySettings();
|
2017-10-24 07:45:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void ATVDemodGUI::on_rfBW_valueChanged(int value)
|
|
|
|
{
|
2019-12-01 09:13:35 -05:00
|
|
|
m_settings.m_fftBandwidth = value * m_rfSliderDivisor;
|
2017-10-24 07:45:10 -04:00
|
|
|
ui->rfBWText->setText(QString("%1k").arg((value * m_rfSliderDivisor) / 1000.0, 0, 'f', 0));
|
|
|
|
setChannelMarkerBandwidth();
|
2019-12-01 09:13:35 -05:00
|
|
|
applySettings();
|
2017-10-24 07:45:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void ATVDemodGUI::on_rfOppBW_valueChanged(int value)
|
|
|
|
{
|
2019-12-01 09:13:35 -05:00
|
|
|
m_settings.m_fftOppBandwidth = value * m_rfSliderDivisor;
|
2017-10-24 07:45:10 -04:00
|
|
|
ui->rfOppBWText->setText(QString("%1k").arg((value * m_rfSliderDivisor) / 1000.0, 0, 'f', 0));
|
|
|
|
setChannelMarkerBandwidth();
|
2019-12-01 09:13:35 -05:00
|
|
|
applySettings();
|
2017-10-24 07:45:10 -04:00
|
|
|
}
|
|
|
|
|
2018-11-12 18:45:03 -05:00
|
|
|
void ATVDemodGUI::on_rfFiltering_toggled(bool checked)
|
2017-10-24 07:45:10 -04:00
|
|
|
{
|
2019-12-01 09:13:35 -05:00
|
|
|
m_settings.m_fftFiltering = checked;
|
|
|
|
setRFFiltersSlidersRange(m_tvSampleRate);
|
2017-10-24 07:45:10 -04:00
|
|
|
setChannelMarkerBandwidth();
|
2019-12-01 09:13:35 -05:00
|
|
|
applySettings();
|
2017-10-24 07:45:10 -04:00
|
|
|
}
|
|
|
|
|
2018-11-12 18:45:03 -05:00
|
|
|
void ATVDemodGUI::on_decimatorEnable_toggled(bool checked)
|
2017-10-24 07:45:10 -04:00
|
|
|
{
|
2019-12-01 09:13:35 -05:00
|
|
|
m_settings.m_forceDecimator = checked;
|
2017-10-24 07:45:10 -04:00
|
|
|
setChannelMarkerBandwidth();
|
2019-12-01 09:13:35 -05:00
|
|
|
applySettings();
|
2017-10-24 07:45:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void ATVDemodGUI::on_deltaFrequency_changed(qint64 value)
|
|
|
|
{
|
2019-12-01 09:13:35 -05:00
|
|
|
m_settings.m_inputFrequencyOffset = value;
|
2017-10-24 07:45:10 -04:00
|
|
|
m_channelMarker.setCenterFrequency(value);
|
2019-12-01 09:13:35 -05:00
|
|
|
applySettings();
|
2017-10-24 07:45:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void ATVDemodGUI::on_bfo_valueChanged(int value)
|
|
|
|
{
|
2019-12-01 09:13:35 -05:00
|
|
|
m_settings.m_bfoFrequency = value;
|
2017-10-24 07:45:10 -04:00
|
|
|
ui->bfoText->setText(QString("%1").arg(value * 1.0, 0, 'f', 0));
|
2019-12-01 09:13:35 -05:00
|
|
|
applySettings();
|
2017-10-24 07:45:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void ATVDemodGUI::on_fmDeviation_valueChanged(int value)
|
|
|
|
{
|
2019-12-01 09:13:35 -05:00
|
|
|
m_settings.m_fmDeviation = value / 1000.0f;
|
2017-10-24 07:45:10 -04:00
|
|
|
ui->fmDeviationText->setText(QString("%1").arg(value / 10.0, 0, 'f', 1));
|
2019-12-01 09:13:35 -05:00
|
|
|
applySettings();
|
2017-10-24 07:45:10 -04:00
|
|
|
}
|
|
|
|
|
2018-11-12 18:45:03 -05:00
|
|
|
void ATVDemodGUI::on_screenTabWidget_currentChanged(int index)
|
2017-10-24 07:45:10 -04:00
|
|
|
{
|
2019-12-01 09:13:35 -05:00
|
|
|
m_atvDemod->setVideoTabIndex(index);
|
2017-10-24 07:45:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void ATVDemodGUI::lineTimeUpdate()
|
|
|
|
{
|
2019-12-01 09:13:35 -05:00
|
|
|
float nominalLineTime = ATVDemodSettings::getNominalLineTime(m_settings.m_nbLines, m_settings.m_fps);
|
2017-10-24 07:45:10 -04:00
|
|
|
int lineTimeScaleFactor = (int) std::log10(nominalLineTime);
|
|
|
|
|
2019-12-01 09:13:35 -05:00
|
|
|
if (m_tvSampleRate == 0) {
|
2017-10-24 07:45:10 -04:00
|
|
|
m_fltLineTimeMultiplier = std::pow(10.0, lineTimeScaleFactor-3);
|
|
|
|
} else {
|
2019-12-01 09:13:35 -05:00
|
|
|
m_fltLineTimeMultiplier = 1.0f / m_tvSampleRate;
|
2017-10-24 07:45:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
float lineTime = nominalLineTime + m_fltLineTimeMultiplier * ui->lineTime->value();
|
|
|
|
|
|
|
|
if (lineTime < 0.0)
|
|
|
|
ui->lineTimeText->setText("invalid");
|
|
|
|
else if(lineTime < 0.000001)
|
|
|
|
ui->lineTimeText->setText(tr("%1 ns").arg(lineTime * 1000000000.0, 0, 'f', 2));
|
|
|
|
else if(lineTime < 0.001)
|
|
|
|
ui->lineTimeText->setText(tr("%1 µs").arg(lineTime * 1000000.0, 0, 'f', 2));
|
|
|
|
else if(lineTime < 1.0)
|
|
|
|
ui->lineTimeText->setText(tr("%1 ms").arg(lineTime * 1000.0, 0, 'f', 2));
|
|
|
|
else
|
|
|
|
ui->lineTimeText->setText(tr("%1 s").arg(lineTime * 1.0, 0, 'f', 2));
|
|
|
|
}
|
|
|
|
|
|
|
|
void ATVDemodGUI::topTimeUpdate()
|
|
|
|
{
|
2019-12-01 09:13:35 -05:00
|
|
|
float nominalTopTime = ATVDemodSettings::getNominalLineTime(m_settings.m_nbLines, m_settings.m_fps) * (4.7f / 64.0f);
|
2017-10-24 07:45:10 -04:00
|
|
|
int topTimeScaleFactor = (int) std::log10(nominalTopTime);
|
|
|
|
|
2019-12-01 09:13:35 -05:00
|
|
|
if (m_tvSampleRate == 0) {
|
2017-10-24 07:45:10 -04:00
|
|
|
m_fltTopTimeMultiplier = std::pow(10.0, topTimeScaleFactor-3);
|
|
|
|
} else {
|
2019-12-01 09:13:35 -05:00
|
|
|
m_fltTopTimeMultiplier = 1.0f / m_tvSampleRate;
|
2017-10-24 07:45:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
float topTime = nominalTopTime + m_fltTopTimeMultiplier * ui->topTime->value();
|
|
|
|
|
|
|
|
if (topTime < 0.0)
|
|
|
|
ui->topTimeText->setText("invalid");
|
|
|
|
else if (topTime < 0.000001)
|
|
|
|
ui->topTimeText->setText(tr("%1 ns").arg(topTime * 1000000000.0, 0, 'f', 2));
|
|
|
|
else if(topTime < 0.001)
|
|
|
|
ui->topTimeText->setText(tr("%1 µs").arg(topTime * 1000000.0, 0, 'f', 2));
|
|
|
|
else if(topTime < 1.0)
|
|
|
|
ui->topTimeText->setText(tr("%1 ms").arg(topTime * 1000.0, 0, 'f', 2));
|
|
|
|
else
|
|
|
|
ui->topTimeText->setText(tr("%1 s").arg(topTime * 1.0, 0, 'f', 2));
|
|
|
|
}
|