2020-09-18 11:36:27 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2016 Edouard Griffiths, F4EXB //
|
|
|
|
// Copyright (C) 2020 Jon Beniston, M7RCE //
|
|
|
|
// //
|
|
|
|
// 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 //
|
|
|
|
// (at your option) any later version. //
|
|
|
|
// //
|
|
|
|
// 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 <QFileDialog>
|
|
|
|
#include <QTime>
|
|
|
|
#include <QDebug>
|
|
|
|
|
|
|
|
#include "dsp/spectrumvis.h"
|
2022-04-13 05:08:21 -04:00
|
|
|
#include "dsp/dspengine.h"
|
|
|
|
#include "dsp/dspcommands.h"
|
2020-09-18 11:36:27 -04:00
|
|
|
#include "device/deviceuiset.h"
|
|
|
|
#include "plugin/pluginapi.h"
|
|
|
|
#include "util/simpleserializer.h"
|
|
|
|
#include "util/db.h"
|
|
|
|
#include "gui/glspectrum.h"
|
|
|
|
#include "gui/crightclickenabler.h"
|
|
|
|
#include "gui/basicchannelsettingsdialog.h"
|
|
|
|
#include "gui/devicestreamselectiondialog.h"
|
|
|
|
#include "gui/fmpreemphasisdialog.h"
|
2022-12-20 05:31:15 -05:00
|
|
|
#include "gui/dialpopup.h"
|
|
|
|
#include "gui/dialogpositioner.h"
|
2020-10-12 15:59:04 -04:00
|
|
|
#include "maincore.h"
|
2020-09-18 11:36:27 -04:00
|
|
|
|
|
|
|
#include "ui_packetmodgui.h"
|
|
|
|
#include "packetmodgui.h"
|
|
|
|
#include "packetmodrepeatdialog.h"
|
|
|
|
#include "packetmodtxsettingsdialog.h"
|
2020-09-23 08:42:29 -04:00
|
|
|
#include "packetmodbpfdialog.h"
|
2020-09-18 11:36:27 -04:00
|
|
|
|
|
|
|
|
|
|
|
PacketModGUI* PacketModGUI::create(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSource *channelTx)
|
|
|
|
{
|
|
|
|
PacketModGUI* gui = new PacketModGUI(pluginAPI, deviceUISet, channelTx);
|
|
|
|
return gui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PacketModGUI::destroy()
|
|
|
|
{
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PacketModGUI::resetToDefaults()
|
|
|
|
{
|
|
|
|
m_settings.resetToDefaults();
|
|
|
|
displaySettings();
|
|
|
|
applySettings(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray PacketModGUI::serialize() const
|
|
|
|
{
|
|
|
|
return m_settings.serialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool PacketModGUI::deserialize(const QByteArray& data)
|
|
|
|
{
|
|
|
|
if(m_settings.deserialize(data)) {
|
|
|
|
displaySettings();
|
|
|
|
applySettings(true);
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
resetToDefaults();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool PacketModGUI::handleMessage(const Message& message)
|
|
|
|
{
|
|
|
|
if (PacketMod::MsgConfigurePacketMod::match(message))
|
|
|
|
{
|
|
|
|
const PacketMod::MsgConfigurePacketMod& cfg = (PacketMod::MsgConfigurePacketMod&) message;
|
|
|
|
m_settings = cfg.getSettings();
|
|
|
|
blockApplySettings(true);
|
2021-12-03 16:32:54 -05:00
|
|
|
m_channelMarker.updateSettings(static_cast<const ChannelMarker*>(m_settings.m_channelMarker));
|
2020-09-18 11:36:27 -04:00
|
|
|
displaySettings();
|
|
|
|
blockApplySettings(false);
|
|
|
|
return true;
|
|
|
|
}
|
2021-11-14 16:26:02 -05:00
|
|
|
else if (PacketMod::MsgReportTx::match(message))
|
|
|
|
{
|
|
|
|
QString str = m_settings.m_callsign + ">" + m_settings.m_to + "," + m_settings.m_via + ":" + m_settings.m_data;
|
|
|
|
ui->transmittedText->appendPlainText(str);
|
|
|
|
return true;
|
|
|
|
}
|
2022-04-13 05:08:21 -04:00
|
|
|
else if (DSPSignalNotification::match(message))
|
|
|
|
{
|
|
|
|
const DSPSignalNotification& notif = (const 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;
|
|
|
|
}
|
2020-09-18 11:36:27 -04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PacketModGUI::channelMarkerChangedByCursor()
|
|
|
|
{
|
|
|
|
ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency());
|
|
|
|
m_settings.m_inputFrequencyOffset = m_channelMarker.getCenterFrequency();
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PacketModGUI::handleSourceMessages()
|
|
|
|
{
|
|
|
|
Message* message;
|
|
|
|
|
|
|
|
while ((message = getInputMessageQueue()->pop()) != 0)
|
|
|
|
{
|
|
|
|
if (handleMessage(*message))
|
|
|
|
{
|
|
|
|
delete message;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PacketModGUI::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();
|
2020-09-18 11:36:27 -04:00
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2020-09-23 08:42:29 -04:00
|
|
|
void PacketModGUI::on_mode_currentIndexChanged(int value)
|
|
|
|
{
|
|
|
|
QString mode = ui->mode->currentText();
|
|
|
|
|
|
|
|
// If m_doApplySettings is set, we are here from a call to displaySettings,
|
|
|
|
// so we only want to display the current settings, not update them
|
|
|
|
// as though a user had selected a new mode
|
|
|
|
if (m_doApplySettings)
|
|
|
|
m_settings.setMode(mode);
|
|
|
|
|
|
|
|
ui->rfBWText->setText(QString("%1k").arg(m_settings.m_rfBandwidth / 1000.0, 0, 'f', 1));
|
|
|
|
ui->fmDevText->setText(QString("%1k").arg(m_settings.m_fmDeviation / 1000.0, 0, 'f', 1));
|
|
|
|
ui->fmDev->setValue(m_settings.m_fmDeviation / 100.0);
|
|
|
|
ui->glSpectrum->setCenterFrequency(m_settings.m_spectrumRate/4);
|
|
|
|
ui->glSpectrum->setSampleRate(m_settings.m_spectrumRate/2);
|
|
|
|
applySettings();
|
|
|
|
|
|
|
|
// Remove custom mode when deselected, as we no longer know how to set it
|
|
|
|
if (value < 2)
|
|
|
|
ui->mode->removeItem(2);
|
|
|
|
}
|
|
|
|
|
2020-09-18 11:36:27 -04:00
|
|
|
void PacketModGUI::on_rfBW_valueChanged(int value)
|
|
|
|
{
|
|
|
|
float bw = value * 100.0f;
|
|
|
|
ui->rfBWText->setText(QString("%1k").arg(value / 10.0, 0, 'f', 1));
|
|
|
|
m_channelMarker.setBandwidth(bw);
|
|
|
|
m_settings.m_rfBandwidth = bw;
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PacketModGUI::on_fmDev_valueChanged(int value)
|
|
|
|
{
|
|
|
|
ui->fmDevText->setText(QString("%1k").arg(value / 10.0, 0, 'f', 1));
|
|
|
|
m_settings.m_fmDeviation = value * 100.0;
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PacketModGUI::on_gain_valueChanged(int value)
|
|
|
|
{
|
|
|
|
ui->gainText->setText(QString("%1dB").arg(value));
|
|
|
|
m_settings.m_gain = value;
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PacketModGUI::on_channelMute_toggled(bool checked)
|
|
|
|
{
|
|
|
|
m_settings.m_channelMute = checked;
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2020-11-14 05:13:32 -05:00
|
|
|
void PacketModGUI::on_txButton_clicked()
|
2020-09-18 11:36:27 -04:00
|
|
|
{
|
|
|
|
transmit();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PacketModGUI::on_packet_returnPressed()
|
|
|
|
{
|
|
|
|
transmit();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PacketModGUI::on_callsign_editingFinished()
|
|
|
|
{
|
|
|
|
m_settings.m_callsign = ui->callsign->text();
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PacketModGUI::on_to_currentTextChanged(const QString &text)
|
|
|
|
{
|
|
|
|
m_settings.m_to = text;
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PacketModGUI::on_via_currentTextChanged(const QString &text)
|
|
|
|
{
|
|
|
|
m_settings.m_via = text;
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PacketModGUI::on_packet_editingFinished()
|
|
|
|
{
|
|
|
|
m_settings.m_data = ui->packet->text();
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2020-11-14 05:13:32 -05:00
|
|
|
void PacketModGUI::on_insertPosition_clicked()
|
2020-09-18 11:36:27 -04:00
|
|
|
{
|
2020-10-12 15:59:04 -04:00
|
|
|
float latitude = MainCore::instance()->getSettings().getLatitude();
|
|
|
|
float longitude = MainCore::instance()->getSettings().getLongitude();
|
2020-09-18 11:36:27 -04:00
|
|
|
|
|
|
|
int latDeg, latMin, latFrac, latNorth;
|
|
|
|
int longDeg, longMin, longFrac, longEast;
|
2020-09-18 11:52:21 -04:00
|
|
|
char latBuf[40];
|
|
|
|
char longBuf[40];
|
2020-09-18 11:36:27 -04:00
|
|
|
|
|
|
|
// Convert decimal latitude to degrees, min and hundreths of a minute
|
|
|
|
latNorth = latitude >= 0.0f;
|
|
|
|
latitude = abs(latitude);
|
|
|
|
latDeg = (int)latitude;
|
|
|
|
latitude -= (float)latDeg;
|
|
|
|
latitude *= 60.0f;
|
|
|
|
latMin = (int)latitude;
|
|
|
|
latitude -= (float)latMin;
|
|
|
|
latitude *= 100.0f;
|
|
|
|
latFrac = round(latitude);
|
|
|
|
|
|
|
|
// Convert decimal longitude
|
|
|
|
longEast = longitude >= 0.0f;
|
|
|
|
longitude = abs(longitude);
|
|
|
|
longDeg = (int)longitude;
|
|
|
|
longitude -= (float)longDeg;
|
|
|
|
longitude *= 60.0f;
|
|
|
|
longMin = (int)longitude;
|
|
|
|
longitude -= (float)longMin;
|
|
|
|
longitude *= 100.0f;
|
|
|
|
longFrac = round(longitude);
|
|
|
|
|
|
|
|
// Insert position with house symbol (-) in to data field
|
|
|
|
sprintf(latBuf, "%02d%02d.%02d%c", latDeg, latMin, latFrac, latNorth ? 'N' : 'S');
|
|
|
|
sprintf(longBuf, "%03d%02d.%02d%c", longDeg, longMin, longFrac, longEast ? 'E' : 'W');
|
|
|
|
QString packet = QString("%1/%2-").arg(latBuf).arg(longBuf);
|
|
|
|
ui->packet->insert(packet);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PacketModGUI::on_repeat_toggled(bool checked)
|
|
|
|
{
|
|
|
|
m_settings.m_repeat = checked;
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PacketModGUI::on_preEmphasis_toggled(bool checked)
|
|
|
|
{
|
|
|
|
m_settings.m_preEmphasis = checked;
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2020-09-23 08:42:29 -04:00
|
|
|
void PacketModGUI::on_bpf_toggled(bool checked)
|
|
|
|
{
|
|
|
|
m_settings.m_bpf = checked;
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2022-12-28 14:33:28 -05:00
|
|
|
void PacketModGUI::preEmphasisSelect(const QPoint& p)
|
2020-09-18 11:36:27 -04:00
|
|
|
{
|
|
|
|
FMPreemphasisDialog dialog(m_settings.m_preEmphasisTau, m_settings.m_preEmphasisHighFreq);
|
2022-12-28 14:33:28 -05:00
|
|
|
dialog.move(p);
|
2023-09-01 15:09:54 -04:00
|
|
|
new DialogPositioner(&dialog, false);
|
2022-12-28 14:33:28 -05:00
|
|
|
|
2020-09-18 11:36:27 -04:00
|
|
|
if (dialog.exec() == QDialog::Accepted)
|
|
|
|
{
|
|
|
|
m_settings.m_preEmphasisTau = dialog.m_tau;
|
|
|
|
m_settings.m_preEmphasisHighFreq = dialog.m_highFreq;
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-28 14:33:28 -05:00
|
|
|
void PacketModGUI::bpfSelect(const QPoint& p)
|
2020-09-23 08:42:29 -04:00
|
|
|
{
|
|
|
|
PacketModBPFDialog dialog(m_settings.m_bpfLowCutoff, m_settings.m_bpfHighCutoff, m_settings.m_bpfTaps);
|
2022-12-28 14:33:28 -05:00
|
|
|
dialog.move(p);
|
2023-09-01 15:09:54 -04:00
|
|
|
new DialogPositioner(&dialog, false);
|
2022-12-28 14:33:28 -05:00
|
|
|
|
2020-09-23 08:42:29 -04:00
|
|
|
if (dialog.exec() == QDialog::Accepted)
|
|
|
|
{
|
|
|
|
m_settings.m_bpfLowCutoff = dialog.m_lowFreq;
|
|
|
|
m_settings.m_bpfHighCutoff = dialog.m_highFreq;
|
|
|
|
m_settings.m_bpfTaps = dialog.m_taps;
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-28 14:33:28 -05:00
|
|
|
void PacketModGUI::repeatSelect(const QPoint& p)
|
2020-09-18 11:36:27 -04:00
|
|
|
{
|
|
|
|
PacketModRepeatDialog dialog(m_settings.m_repeatDelay, m_settings.m_repeatCount);
|
2022-12-28 14:33:28 -05:00
|
|
|
dialog.move(p);
|
2023-09-01 15:09:54 -04:00
|
|
|
new DialogPositioner(&dialog, false);
|
2022-12-28 14:33:28 -05:00
|
|
|
|
2020-09-18 11:36:27 -04:00
|
|
|
if (dialog.exec() == QDialog::Accepted)
|
|
|
|
{
|
|
|
|
m_settings.m_repeatDelay = dialog.m_repeatDelay;
|
|
|
|
m_settings.m_repeatCount = dialog.m_repeatCount;
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-28 14:33:28 -05:00
|
|
|
void PacketModGUI::txSettingsSelect(const QPoint& p)
|
2020-09-18 11:36:27 -04:00
|
|
|
{
|
|
|
|
PacketModTXSettingsDialog dialog(m_settings.m_rampUpBits, m_settings.m_rampDownBits,
|
|
|
|
m_settings.m_rampRange, m_settings.m_modulateWhileRamping,
|
2020-09-23 08:42:29 -04:00
|
|
|
m_settings.m_modulation, m_settings.m_baud,
|
2020-09-18 11:36:27 -04:00
|
|
|
m_settings.m_markFrequency, m_settings.m_spaceFrequency,
|
2020-09-23 08:42:29 -04:00
|
|
|
m_settings.m_pulseShaping, m_settings.m_beta, m_settings.m_symbolSpan,
|
|
|
|
m_settings.m_scramble, m_settings.m_polynomial,
|
2020-09-18 11:36:27 -04:00
|
|
|
m_settings.m_ax25PreFlags, m_settings.m_ax25PostFlags,
|
|
|
|
m_settings.m_ax25Control, m_settings.m_ax25PID,
|
|
|
|
m_settings.m_lpfTaps,
|
|
|
|
m_settings.m_bbNoise, m_settings.m_rfNoise,
|
|
|
|
m_settings.m_writeToFile);
|
2022-12-28 14:33:28 -05:00
|
|
|
|
|
|
|
dialog.move(p);
|
2023-09-01 15:09:54 -04:00
|
|
|
new DialogPositioner(&dialog, false);
|
2022-12-28 14:33:28 -05:00
|
|
|
|
2020-09-18 11:36:27 -04:00
|
|
|
if (dialog.exec() == QDialog::Accepted)
|
|
|
|
{
|
|
|
|
m_settings.m_rampUpBits = dialog.m_rampUpBits;
|
|
|
|
m_settings.m_rampDownBits = dialog.m_rampDownBits;
|
|
|
|
m_settings.m_rampRange = dialog.m_rampRange;
|
|
|
|
m_settings.m_modulateWhileRamping = dialog.m_modulateWhileRamping;
|
2020-09-23 08:42:29 -04:00
|
|
|
m_settings.m_modulation = static_cast<PacketModSettings::Modulation>(dialog.m_modulation);
|
|
|
|
m_settings.m_baud = dialog.m_baud;
|
2020-09-18 11:36:27 -04:00
|
|
|
m_settings.m_markFrequency = dialog.m_markFrequency;
|
|
|
|
m_settings.m_spaceFrequency = dialog.m_spaceFrequency;
|
2020-09-23 08:42:29 -04:00
|
|
|
m_settings.m_pulseShaping = dialog.m_pulseShaping;
|
|
|
|
m_settings.m_beta = dialog.m_beta;
|
|
|
|
m_settings.m_symbolSpan = dialog.m_symbolSpan;
|
|
|
|
m_settings.m_scramble = dialog.m_scramble;
|
|
|
|
m_settings.m_polynomial = dialog.m_polynomial;
|
2020-09-18 11:36:27 -04:00
|
|
|
m_settings.m_ax25PreFlags = dialog.m_ax25PreFlags;
|
|
|
|
m_settings.m_ax25PostFlags = dialog.m_ax25PostFlags;
|
|
|
|
m_settings.m_ax25Control = dialog.m_ax25Control;
|
|
|
|
m_settings.m_ax25PID = dialog.m_ax25PID;
|
|
|
|
m_settings.m_lpfTaps = dialog.m_lpfTaps;
|
|
|
|
m_settings.m_bbNoise = dialog.m_bbNoise;
|
|
|
|
m_settings.m_rfNoise = dialog.m_rfNoise;
|
|
|
|
m_settings.m_writeToFile = dialog.m_writeToFile;
|
2020-09-23 08:42:29 -04:00
|
|
|
displaySettings();
|
2020-09-18 11:36:27 -04:00
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-07 16:06:00 -04:00
|
|
|
void PacketModGUI::on_udpEnabled_clicked(bool checked)
|
|
|
|
{
|
|
|
|
m_settings.m_udpEnabled = checked;
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PacketModGUI::on_udpAddress_editingFinished()
|
|
|
|
{
|
|
|
|
m_settings.m_udpAddress = ui->udpAddress->text();
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PacketModGUI::on_udpPort_editingFinished()
|
|
|
|
{
|
|
|
|
m_settings.m_udpPort = ui->udpPort->text().toInt();
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
2020-09-18 11:36:27 -04:00
|
|
|
void PacketModGUI::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();
|
2020-09-18 11:36:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void PacketModGUI::onMenuDialogCalled(const QPoint &p)
|
|
|
|
{
|
|
|
|
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_packetMod->getNumberOfDeviceStreams());
|
|
|
|
dialog.setStreamIndex(m_settings.m_streamIndex);
|
|
|
|
}
|
|
|
|
|
2020-09-18 11:36:27 -04:00
|
|
|
dialog.move(p);
|
2022-12-20 05:31:15 -05:00
|
|
|
new DialogPositioner(&dialog, false);
|
2020-09-18 11:36:27 -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());
|
2020-09-18 11:36:27 -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();
|
|
|
|
}
|
2020-09-18 11:36:27 -04:00
|
|
|
|
|
|
|
applySettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
resetContextMenuType();
|
|
|
|
}
|
|
|
|
|
|
|
|
PacketModGUI::PacketModGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampleSource *channelTx, QWidget* parent) :
|
2020-10-04 00:16:15 -04:00
|
|
|
ChannelGUI(parent),
|
2020-09-18 11:36:27 -04:00
|
|
|
ui(new Ui::PacketModGUI),
|
|
|
|
m_pluginAPI(pluginAPI),
|
|
|
|
m_deviceUISet(deviceUISet),
|
|
|
|
m_channelMarker(this),
|
2022-04-13 05:08:21 -04:00
|
|
|
m_deviceCenterFrequency(0),
|
|
|
|
m_basebandSampleRate(1),
|
2020-09-18 11:36:27 -04:00
|
|
|
m_doApplySettings(true)
|
|
|
|
{
|
|
|
|
setAttribute(Qt::WA_DeleteOnClose, true);
|
2022-04-24 06:28:56 -04:00
|
|
|
m_helpURL = "plugins/channeltx/modpacket/readme.md";
|
|
|
|
RollupContents *rollupContents = getRollupContents();
|
|
|
|
ui->setupUi(rollupContents);
|
|
|
|
setSizePolicy(rollupContents->sizePolicy());
|
|
|
|
rollupContents->arrangeRollups();
|
|
|
|
connect(rollupContents, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
|
2020-09-18 11:36:27 -04:00
|
|
|
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(onMenuDialogCalled(const QPoint &)));
|
|
|
|
|
|
|
|
m_packetMod = (PacketMod*) channelTx;
|
|
|
|
m_packetMod->setMessageQueueToGUI(getInputMessageQueue());
|
|
|
|
|
2020-10-12 15:59:04 -04:00
|
|
|
connect(&MainCore::instance()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick()));
|
2020-09-18 11:36:27 -04:00
|
|
|
|
|
|
|
m_spectrumVis = m_packetMod->getSpectrumVis();
|
|
|
|
m_spectrumVis->setGLSpectrum(ui->glSpectrum);
|
|
|
|
|
2023-06-06 17:17:43 -04:00
|
|
|
ui->spectrumGUI->setBuddies(m_spectrumVis, ui->glSpectrum);
|
|
|
|
|
2020-09-18 11:36:27 -04:00
|
|
|
// Extra /2 here because SSB?
|
|
|
|
ui->glSpectrum->setCenterFrequency(m_settings.m_spectrumRate/4);
|
|
|
|
ui->glSpectrum->setSampleRate(m_settings.m_spectrumRate/2);
|
|
|
|
ui->glSpectrum->setLsbDisplay(false);
|
2023-04-09 05:47:50 -04:00
|
|
|
|
|
|
|
SpectrumSettings spectrumSettings = m_spectrumVis->getSettings();
|
|
|
|
spectrumSettings.m_ssb = true;
|
|
|
|
spectrumSettings.m_displayCurrent = true;
|
|
|
|
spectrumSettings.m_displayWaterfall = false;
|
|
|
|
spectrumSettings.m_displayMaxHold = false;
|
|
|
|
spectrumSettings.m_displayHistogram = false;
|
|
|
|
SpectrumVis::MsgConfigureSpectrumVis *msg = SpectrumVis::MsgConfigureSpectrumVis::create(spectrumSettings, false);
|
|
|
|
m_spectrumVis->getInputMessageQueue()->push(msg);
|
2020-09-18 11:36:27 -04:00
|
|
|
|
|
|
|
CRightClickEnabler *repeatRightClickEnabler = new CRightClickEnabler(ui->repeat);
|
2022-12-28 14:33:28 -05:00
|
|
|
connect(repeatRightClickEnabler, SIGNAL(rightClick(const QPoint &)), this, SLOT(repeatSelect(const QPoint &)));
|
2020-09-18 11:36:27 -04:00
|
|
|
|
|
|
|
CRightClickEnabler *txRightClickEnabler = new CRightClickEnabler(ui->txButton);
|
2022-12-28 14:33:28 -05:00
|
|
|
connect(txRightClickEnabler, SIGNAL(rightClick(const QPoint &)), this, SLOT(txSettingsSelect(const QPoint &)));
|
2020-09-18 11:36:27 -04:00
|
|
|
|
|
|
|
CRightClickEnabler *preempRightClickEnabler = new CRightClickEnabler(ui->preEmphasis);
|
2022-12-28 14:33:28 -05:00
|
|
|
connect(preempRightClickEnabler, SIGNAL(rightClick(const QPoint &)), this, SLOT(preEmphasisSelect(const QPoint &)));
|
2020-09-18 11:36:27 -04:00
|
|
|
|
2020-09-23 08:42:29 -04:00
|
|
|
CRightClickEnabler *bpfRightClickEnabler = new CRightClickEnabler(ui->bpf);
|
2022-12-28 14:33:28 -05:00
|
|
|
connect(bpfRightClickEnabler, SIGNAL(rightClick(const QPoint &)), this, SLOT(bpfSelect(const QPoint &)));
|
2020-09-23 08:42:29 -04:00
|
|
|
|
2020-09-18 11:36:27 -04:00
|
|
|
ui->deltaFrequencyLabel->setText(QString("%1f").arg(QChar(0x94, 0x03)));
|
|
|
|
ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));
|
|
|
|
ui->deltaFrequency->setValueRange(false, 7, -9999999, 9999999);
|
|
|
|
|
|
|
|
m_channelMarker.blockSignals(true);
|
|
|
|
m_channelMarker.setColor(Qt::red);
|
|
|
|
m_channelMarker.setBandwidth(12500);
|
|
|
|
m_channelMarker.setCenterFrequency(0);
|
|
|
|
m_channelMarker.setTitle("Packet Modulator");
|
|
|
|
m_channelMarker.setSourceOrSinkStream(false);
|
|
|
|
m_channelMarker.blockSignals(false);
|
|
|
|
m_channelMarker.setVisible(true); // activate signal on the last setting only
|
|
|
|
|
|
|
|
m_deviceUISet->addChannelMarker(&m_channelMarker);
|
|
|
|
|
|
|
|
connect(&m_channelMarker, SIGNAL(changedByCursor()), this, SLOT(channelMarkerChangedByCursor()));
|
|
|
|
|
|
|
|
connect(getInputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleSourceMessages()));
|
|
|
|
m_packetMod->setLevelMeter(ui->volumeMeter);
|
|
|
|
|
|
|
|
m_settings.setChannelMarker(&m_channelMarker);
|
2022-01-08 23:27:12 -05:00
|
|
|
m_settings.setRollupState(&m_rollupState);
|
2020-09-18 11:36:27 -04:00
|
|
|
|
2021-07-15 07:03:48 -04:00
|
|
|
ui->spectrumContainer->setVisible(false);
|
|
|
|
|
2020-09-18 11:36:27 -04:00
|
|
|
displaySettings();
|
2022-04-12 10:20:45 -04:00
|
|
|
makeUIConnections();
|
2020-09-18 11:36:27 -04:00
|
|
|
applySettings();
|
2022-12-20 05:31:15 -05:00
|
|
|
DialPopup::addPopupsToChildDials(this);
|
2020-09-18 11:36:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
PacketModGUI::~PacketModGUI()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PacketModGUI::transmit()
|
|
|
|
{
|
|
|
|
// TODO: Any validation?
|
2021-11-14 16:26:02 -05:00
|
|
|
QString str = m_settings.m_callsign + ">" + m_settings.m_to + "," + m_settings.m_via + ":" + m_settings.m_data;
|
|
|
|
ui->transmittedText->appendPlainText(str);
|
|
|
|
PacketMod::MsgTx *msg = PacketMod::MsgTx::create();
|
2020-09-18 11:36:27 -04:00
|
|
|
m_packetMod->getInputMessageQueue()->push(msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PacketModGUI::blockApplySettings(bool block)
|
|
|
|
{
|
|
|
|
m_doApplySettings = !block;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PacketModGUI::applySettings(bool force)
|
|
|
|
{
|
|
|
|
if (m_doApplySettings)
|
|
|
|
{
|
|
|
|
PacketMod::MsgConfigurePacketMod *msg = PacketMod::MsgConfigurePacketMod::create(m_settings, force);
|
|
|
|
m_packetMod->getInputMessageQueue()->push(msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PacketModGUI::displaySettings()
|
|
|
|
{
|
|
|
|
m_channelMarker.blockSignals(true);
|
|
|
|
m_channelMarker.setCenterFrequency(m_settings.m_inputFrequencyOffset);
|
|
|
|
m_channelMarker.setTitle(m_settings.m_title);
|
|
|
|
m_channelMarker.setBandwidth(m_settings.m_rfBandwidth);
|
|
|
|
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());
|
2022-04-17 19:42:03 -04:00
|
|
|
updateIndexLabel();
|
2020-09-18 11:36:27 -04:00
|
|
|
|
|
|
|
blockApplySettings(true);
|
|
|
|
|
|
|
|
ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency());
|
2020-09-23 08:42:29 -04:00
|
|
|
if ((m_settings.m_baud == 1200) && (m_settings.m_modulation == PacketModSettings::AFSK))
|
|
|
|
ui->mode->setCurrentIndex(0);
|
|
|
|
else if ((m_settings.m_baud == 9600) && (m_settings.m_modulation == PacketModSettings::FSK))
|
|
|
|
ui->mode->setCurrentIndex(1);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui->mode->removeItem(2);
|
|
|
|
ui->mode->addItem(m_settings.getMode());
|
|
|
|
ui->mode->setCurrentIndex(2);
|
|
|
|
}
|
|
|
|
ui->glSpectrum->setCenterFrequency(m_settings.m_spectrumRate/4);
|
|
|
|
ui->glSpectrum->setSampleRate(m_settings.m_spectrumRate/2);
|
2020-09-18 11:36:27 -04:00
|
|
|
|
|
|
|
ui->rfBWText->setText(QString("%1k").arg(m_settings.m_rfBandwidth / 1000.0, 0, 'f', 1));
|
|
|
|
ui->rfBW->setValue(m_settings.m_rfBandwidth / 100.0);
|
|
|
|
|
|
|
|
ui->fmDevText->setText(QString("%1k").arg(m_settings.m_fmDeviation / 1000.0, 0, 'f', 1));
|
|
|
|
ui->fmDev->setValue(m_settings.m_fmDeviation / 100.0);
|
|
|
|
|
|
|
|
ui->gainText->setText(QString("%1").arg((double)m_settings.m_gain, 0, 'f', 1));
|
|
|
|
ui->gain->setValue(m_settings.m_gain);
|
|
|
|
|
2021-04-07 16:06:00 -04:00
|
|
|
ui->udpEnabled->setChecked(m_settings.m_udpEnabled);
|
|
|
|
ui->udpAddress->setText(m_settings.m_udpAddress);
|
|
|
|
ui->udpPort->setText(QString::number(m_settings.m_udpPort));
|
|
|
|
|
2020-09-18 11:36:27 -04:00
|
|
|
ui->channelMute->setChecked(m_settings.m_channelMute);
|
|
|
|
ui->repeat->setChecked(m_settings.m_repeat);
|
|
|
|
|
|
|
|
ui->callsign->setText(m_settings.m_callsign);
|
|
|
|
ui->to->lineEdit()->setText(m_settings.m_to);
|
|
|
|
ui->via->lineEdit()->setText(m_settings.m_via);
|
|
|
|
ui->packet->setText(m_settings.m_data);
|
|
|
|
|
2022-04-12 10:20:45 -04:00
|
|
|
getRollupContents()->restoreState(m_rollupState);
|
2022-04-13 05:08:21 -04:00
|
|
|
updateAbsoluteCenterFrequency();
|
2020-09-18 11:36:27 -04:00
|
|
|
blockApplySettings(false);
|
|
|
|
}
|
|
|
|
|
2022-04-22 13:21:24 -04:00
|
|
|
void PacketModGUI::leaveEvent(QEvent* event)
|
2020-09-18 11:36:27 -04:00
|
|
|
{
|
|
|
|
m_channelMarker.setHighlighted(false);
|
2022-04-22 13:21:24 -04:00
|
|
|
ChannelGUI::leaveEvent(event);
|
2020-09-18 11:36:27 -04:00
|
|
|
}
|
|
|
|
|
2022-11-17 09:36:12 -05:00
|
|
|
void PacketModGUI::enterEvent(EnterEventType* event)
|
2020-09-18 11:36:27 -04:00
|
|
|
{
|
|
|
|
m_channelMarker.setHighlighted(true);
|
2022-04-22 13:21:24 -04:00
|
|
|
ChannelGUI::enterEvent(event);
|
2020-09-18 11:36:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void PacketModGUI::tick()
|
|
|
|
{
|
|
|
|
double powDb = CalcDb::dbPower(m_packetMod->getMagSq());
|
|
|
|
m_channelPowerDbAvg(powDb);
|
|
|
|
ui->channelPower->setText(tr("%1 dB").arg(m_channelPowerDbAvg.asDouble(), 0, 'f', 1));
|
|
|
|
}
|
2022-04-12 10:20:45 -04:00
|
|
|
|
|
|
|
void PacketModGUI::makeUIConnections()
|
|
|
|
{
|
|
|
|
QObject::connect(ui->deltaFrequency, &ValueDialZ::changed, this, &PacketModGUI::on_deltaFrequency_changed);
|
|
|
|
QObject::connect(ui->mode, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &PacketModGUI::on_mode_currentIndexChanged);
|
|
|
|
QObject::connect(ui->rfBW, &QSlider::valueChanged, this, &PacketModGUI::on_rfBW_valueChanged);
|
|
|
|
QObject::connect(ui->fmDev, &QSlider::valueChanged, this, &PacketModGUI::on_fmDev_valueChanged);
|
|
|
|
QObject::connect(ui->gain, &QDial::valueChanged, this, &PacketModGUI::on_gain_valueChanged);
|
|
|
|
QObject::connect(ui->channelMute, &QToolButton::toggled, this, &PacketModGUI::on_channelMute_toggled);
|
|
|
|
QObject::connect(ui->txButton, &QToolButton::clicked, this, &PacketModGUI::on_txButton_clicked);
|
|
|
|
QObject::connect(ui->callsign, &QLineEdit::editingFinished, this, &PacketModGUI::on_callsign_editingFinished);
|
|
|
|
QObject::connect(ui->to, &QComboBox::currentTextChanged, this, &PacketModGUI::on_to_currentTextChanged);
|
|
|
|
QObject::connect(ui->via, &QComboBox::currentTextChanged, this, &PacketModGUI::on_via_currentTextChanged);
|
|
|
|
QObject::connect(ui->packet, &QLineEdit::editingFinished, this, &PacketModGUI::on_packet_editingFinished);
|
|
|
|
QObject::connect(ui->insertPosition, &QToolButton::clicked, this, &PacketModGUI::on_insertPosition_clicked);
|
|
|
|
QObject::connect(ui->packet, &QLineEdit::returnPressed, this, &PacketModGUI::on_packet_returnPressed);
|
|
|
|
QObject::connect(ui->repeat, &ButtonSwitch::toggled, this, &PacketModGUI::on_repeat_toggled);
|
|
|
|
QObject::connect(ui->preEmphasis, &ButtonSwitch::toggled, this, &PacketModGUI::on_preEmphasis_toggled);
|
|
|
|
QObject::connect(ui->bpf, &ButtonSwitch::toggled, this, &PacketModGUI::on_bpf_toggled);
|
|
|
|
QObject::connect(ui->udpEnabled, &QCheckBox::clicked, this, &PacketModGUI::on_udpEnabled_clicked);
|
|
|
|
QObject::connect(ui->udpAddress, &QLineEdit::editingFinished, this, &PacketModGUI::on_udpAddress_editingFinished);
|
|
|
|
QObject::connect(ui->udpPort, &QLineEdit::editingFinished, this, &PacketModGUI::on_udpPort_editingFinished);
|
|
|
|
}
|
2022-04-13 05:08:21 -04:00
|
|
|
|
|
|
|
void PacketModGUI::updateAbsoluteCenterFrequency()
|
|
|
|
{
|
|
|
|
setStatusFrequency(m_deviceCenterFrequency + m_settings.m_inputFrequencyOffset);
|
|
|
|
}
|