2018-09-29 03:56:54 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2018 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. //
|
2018-09-29 03:56:54 -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 <QDebug>
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
|
|
|
#include <libbladeRF.h>
|
|
|
|
|
|
|
|
#include "ui_bladerf2outputgui.h"
|
|
|
|
#include "gui/colormapper.h"
|
|
|
|
#include "gui/glspectrum.h"
|
2018-12-26 13:22:52 -05:00
|
|
|
#include "gui/basicdevicesettingsdialog.h"
|
2022-12-20 05:31:15 -05:00
|
|
|
#include "gui/dialogpositioner.h"
|
2018-09-29 03:56:54 -04:00
|
|
|
#include "dsp/dspengine.h"
|
|
|
|
#include "dsp/dspcommands.h"
|
2019-05-08 16:11:53 -04:00
|
|
|
#include "device/deviceapi.h"
|
2018-09-29 03:56:54 -04:00
|
|
|
#include "device/deviceuiset.h"
|
|
|
|
|
|
|
|
#include "bladerf2outputgui.h"
|
|
|
|
|
|
|
|
BladeRF2OutputGui::BladeRF2OutputGui(DeviceUISet *deviceUISet, QWidget* parent) :
|
2020-10-05 13:23:13 -04:00
|
|
|
DeviceGUI(parent),
|
2018-09-29 03:56:54 -04:00
|
|
|
ui(new Ui::BladeRF2OutputGui),
|
|
|
|
m_doApplySettings(true),
|
|
|
|
m_forceSettings(true),
|
|
|
|
m_settings(),
|
2019-04-12 08:14:17 -04:00
|
|
|
m_sampleRateMode(true),
|
2018-09-29 03:56:54 -04:00
|
|
|
m_sampleRate(0),
|
2019-05-08 16:11:53 -04:00
|
|
|
m_lastEngineState(DeviceAPI::StNotStarted)
|
2018-09-29 03:56:54 -04:00
|
|
|
{
|
2022-05-13 16:24:48 -04:00
|
|
|
m_deviceUISet = deviceUISet;
|
2022-04-07 10:32:03 -04:00
|
|
|
setAttribute(Qt::WA_DeleteOnClose, true);
|
2019-05-08 16:11:53 -04:00
|
|
|
m_sampleSink = (BladeRF2Output*) m_deviceUISet->m_deviceAPI->getSampleSink();
|
2018-09-29 03:56:54 -04:00
|
|
|
int max, min, step;
|
2020-09-14 17:19:05 -04:00
|
|
|
float scale;
|
2018-09-29 03:56:54 -04:00
|
|
|
uint64_t f_min, f_max;
|
|
|
|
|
2022-04-07 10:32:03 -04:00
|
|
|
ui->setupUi(getContents());
|
2022-11-09 10:53:44 -05:00
|
|
|
sizeToContents();
|
2022-04-23 20:13:18 -04:00
|
|
|
getContents()->setStyleSheet("#BladeRF2OutputGui { background-color: rgb(64, 64, 64); }");
|
2022-04-07 10:32:03 -04:00
|
|
|
m_helpURL = "plugins/samplesink/bladerf2output/readme.md"; ui->centerFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));
|
2018-09-29 03:56:54 -04:00
|
|
|
|
2020-09-14 17:19:05 -04:00
|
|
|
m_sampleSink->getFrequencyRange(f_min, f_max, step, scale);
|
2019-04-20 18:13:14 -04:00
|
|
|
qDebug("BladeRF2OutputGui::BladeRF2OutputGui: getFrequencyRange: [%lu,%lu] step: %d", f_min, f_max, step);
|
2018-09-29 03:56:54 -04:00
|
|
|
ui->centerFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));
|
2022-10-17 08:43:32 -04:00
|
|
|
ui->centerFrequency->setValueRange(7, f_min/1000, f_max/1000);
|
2018-09-29 03:56:54 -04:00
|
|
|
|
2020-09-14 17:19:05 -04:00
|
|
|
m_sampleSink->getSampleRateRange(min, max, step, scale);
|
2018-09-29 04:53:44 -04:00
|
|
|
qDebug("BladeRF2OutputGui::BladeRF2OutputGui: getSampleRateRange: [%d,%d] step: %d", min, max, step);
|
2018-09-29 03:56:54 -04:00
|
|
|
ui->sampleRate->setColorMapper(ColorMapper(ColorMapper::GrayGreenYellow));
|
|
|
|
ui->sampleRate->setValueRange(8, min, max);
|
|
|
|
|
2020-09-14 17:19:05 -04:00
|
|
|
m_sampleSink->getBandwidthRange(min, max, step, scale);
|
2018-09-29 04:53:44 -04:00
|
|
|
qDebug("BladeRF2OutputGui::BladeRF2OutputGui: getBandwidthRange: [%d,%d] step: %d", min, max, step);
|
2018-09-29 03:56:54 -04:00
|
|
|
ui->bandwidth->setColorMapper(ColorMapper(ColorMapper::GrayYellow));
|
|
|
|
ui->bandwidth->setValueRange(5, min/1000, max/1000);
|
|
|
|
|
2020-09-14 17:04:35 -04:00
|
|
|
m_sampleSink->getGlobalGainRange(m_gainMin, m_gainMax, m_gainStep, m_gainScale);
|
|
|
|
qDebug("BladeRF2OutputGui::BladeRF2OutputGui: getGlobalGainRange: [%d,%d] step: %d scale: %f", m_gainMin, m_gainMax, m_gainStep, m_gainScale);
|
|
|
|
ui->gain->setMinimum(m_gainMin/m_gainStep);
|
|
|
|
ui->gain->setMaximum(m_gainMax/m_gainStep);
|
2018-09-29 04:53:44 -04:00
|
|
|
ui->gain->setPageStep(1);
|
|
|
|
ui->gain->setSingleStep(1);
|
2018-09-29 03:56:54 -04:00
|
|
|
|
|
|
|
connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateHardware()));
|
|
|
|
connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus()));
|
|
|
|
m_statusTimer.start(500);
|
|
|
|
|
2022-04-16 19:31:50 -04:00
|
|
|
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(openDeviceSettingsDialog(const QPoint &)));
|
2018-12-26 13:22:52 -05:00
|
|
|
|
2018-09-29 03:56:54 -04:00
|
|
|
displaySettings();
|
2022-04-07 10:32:03 -04:00
|
|
|
makeUIConnections();
|
2018-09-29 03:56:54 -04:00
|
|
|
|
|
|
|
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()), Qt::QueuedConnection);
|
|
|
|
m_sampleSink->setMessageQueueToGUI(&m_inputMessageQueue);
|
|
|
|
}
|
|
|
|
|
|
|
|
BladeRF2OutputGui::~BladeRF2OutputGui()
|
|
|
|
{
|
2022-10-05 10:40:09 -04:00
|
|
|
m_statusTimer.stop();
|
|
|
|
m_updateTimer.stop();
|
2018-09-29 03:56:54 -04:00
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BladeRF2OutputGui::destroy()
|
|
|
|
{
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BladeRF2OutputGui::resetToDefaults()
|
|
|
|
{
|
|
|
|
m_settings.resetToDefaults();
|
|
|
|
displaySettings();
|
2022-10-29 23:50:53 -04:00
|
|
|
m_forceSettings = true;
|
2018-09-29 03:56:54 -04:00
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray BladeRF2OutputGui::serialize() const
|
|
|
|
{
|
|
|
|
return m_settings.serialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BladeRF2OutputGui::deserialize(const QByteArray& data)
|
|
|
|
{
|
|
|
|
if(m_settings.deserialize(data)) {
|
|
|
|
displaySettings();
|
|
|
|
m_forceSettings = true;
|
|
|
|
sendSettings();
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
resetToDefaults();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-03 00:14:26 -04:00
|
|
|
void BladeRF2OutputGui::updateFrequencyLimits()
|
|
|
|
{
|
|
|
|
// values in kHz
|
|
|
|
uint64_t f_min, f_max;
|
|
|
|
int step;
|
2020-09-14 17:19:05 -04:00
|
|
|
float scale;
|
2018-10-03 00:14:26 -04:00
|
|
|
qint64 deltaFrequency = m_settings.m_transverterMode ? m_settings.m_transverterDeltaFrequency/1000 : 0;
|
2020-09-14 17:19:05 -04:00
|
|
|
m_sampleSink->getFrequencyRange(f_min, f_max, step, scale);
|
2018-10-03 00:14:26 -04:00
|
|
|
qint64 minLimit = f_min/1000 + deltaFrequency;
|
|
|
|
qint64 maxLimit = f_max/1000 + deltaFrequency;
|
|
|
|
|
2022-10-17 08:43:32 -04:00
|
|
|
if (m_settings.m_transverterMode)
|
|
|
|
{
|
|
|
|
minLimit = minLimit < 0 ? 0 : minLimit > 999999999 ? 999999999 : minLimit;
|
|
|
|
maxLimit = maxLimit < 0 ? 0 : maxLimit > 999999999 ? 999999999 : maxLimit;
|
|
|
|
ui->centerFrequency->setValueRange(9, minLimit, maxLimit);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
minLimit = minLimit < 0 ? 0 : minLimit > 9999999 ? 9999999 : minLimit;
|
|
|
|
maxLimit = maxLimit < 0 ? 0 : maxLimit > 9999999 ? 9999999 : maxLimit;
|
|
|
|
ui->centerFrequency->setValueRange(7, minLimit, maxLimit);
|
|
|
|
}
|
2018-10-03 00:14:26 -04:00
|
|
|
qDebug("BladeRF2OutputGui::updateFrequencyLimits: delta: %lld min: %lld max: %lld", deltaFrequency, minLimit, maxLimit);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BladeRF2OutputGui::setCenterFrequencySetting(uint64_t kHzValue)
|
|
|
|
{
|
|
|
|
int64_t centerFrequency = kHzValue*1000;
|
|
|
|
|
|
|
|
m_settings.m_centerFrequency = centerFrequency < 0 ? 0 : (uint64_t) centerFrequency;
|
|
|
|
ui->centerFrequency->setToolTip(QString("Main center frequency in kHz (LO: %1 kHz)").arg(centerFrequency/1000));
|
|
|
|
}
|
|
|
|
|
2018-09-29 03:56:54 -04:00
|
|
|
bool BladeRF2OutputGui::handleMessage(const Message& message)
|
|
|
|
{
|
|
|
|
if (BladeRF2Output::MsgConfigureBladeRF2::match(message))
|
|
|
|
{
|
|
|
|
const BladeRF2Output::MsgConfigureBladeRF2& cfg = (BladeRF2Output::MsgConfigureBladeRF2&) message;
|
2022-10-29 23:50:53 -04:00
|
|
|
|
|
|
|
if (cfg.getForce()) {
|
|
|
|
m_settings = cfg.getSettings();
|
|
|
|
} else {
|
|
|
|
m_settings.applySettings(cfg.getSettingsKeys(), cfg.getSettings());
|
|
|
|
}
|
|
|
|
|
2018-09-29 03:56:54 -04:00
|
|
|
blockApplySettings(true);
|
2020-09-14 17:04:35 -04:00
|
|
|
m_sampleSink->getGlobalGainRange(m_gainMin, m_gainMax, m_gainStep, m_gainScale);
|
|
|
|
ui->gain->setMinimum(m_gainMin/m_gainStep);
|
|
|
|
ui->gain->setMaximum(m_gainMax/m_gainStep);
|
2018-09-29 04:53:44 -04:00
|
|
|
ui->gain->setPageStep(1);
|
|
|
|
ui->gain->setSingleStep(1);
|
2018-09-29 03:56:54 -04:00
|
|
|
displaySettings();
|
|
|
|
blockApplySettings(false);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (BladeRF2Output::MsgReportGainRange::match(message))
|
|
|
|
{
|
|
|
|
const BladeRF2Output::MsgReportGainRange& cfg = (BladeRF2Output::MsgReportGainRange&) message;
|
2020-09-14 17:04:35 -04:00
|
|
|
m_gainMin = cfg.getMin();
|
|
|
|
m_gainMax = cfg.getMax();
|
|
|
|
m_gainStep = cfg.getStep();
|
|
|
|
m_gainScale = cfg.getScale();
|
|
|
|
ui->gain->setMinimum(m_gainMin/m_gainStep);
|
|
|
|
ui->gain->setMaximum(m_gainMax/m_gainStep);
|
2018-09-29 04:53:44 -04:00
|
|
|
ui->gain->setSingleStep(1);
|
|
|
|
ui->gain->setPageStep(1);
|
2018-09-29 03:56:54 -04:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (BladeRF2Output::MsgStartStop::match(message))
|
|
|
|
{
|
|
|
|
BladeRF2Output::MsgStartStop& notif = (BladeRF2Output::MsgStartStop&) message;
|
|
|
|
blockApplySettings(true);
|
|
|
|
ui->startStop->setChecked(notif.getStartStop());
|
|
|
|
blockApplySettings(false);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BladeRF2OutputGui::handleInputMessages()
|
|
|
|
{
|
|
|
|
Message* message;
|
|
|
|
|
|
|
|
while ((message = m_inputMessageQueue.pop()) != 0)
|
|
|
|
{
|
|
|
|
qDebug("BladeRF2OutputGui::handleInputMessages: message: %s", message->getIdentifier());
|
|
|
|
|
|
|
|
if (DSPSignalNotification::match(*message))
|
|
|
|
{
|
|
|
|
DSPSignalNotification* notif = (DSPSignalNotification*) message;
|
|
|
|
m_sampleRate = notif->getSampleRate();
|
|
|
|
m_deviceCenterFrequency = notif->getCenterFrequency();
|
|
|
|
qDebug("BladeRF2OutputGui::handleInputMessages: DSPSignalNotification: SampleRate:%d, CenterFrequency:%llu", notif->getSampleRate(), notif->getCenterFrequency());
|
|
|
|
updateSampleRateAndFrequency();
|
|
|
|
|
|
|
|
delete message;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (handleMessage(*message))
|
|
|
|
{
|
|
|
|
delete message;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BladeRF2OutputGui::updateSampleRateAndFrequency()
|
|
|
|
{
|
|
|
|
m_deviceUISet->getSpectrum()->setSampleRate(m_sampleRate);
|
|
|
|
m_deviceUISet->getSpectrum()->setCenterFrequency(m_deviceCenterFrequency);
|
2019-04-12 08:14:17 -04:00
|
|
|
displaySampleRate();
|
|
|
|
}
|
|
|
|
|
|
|
|
void BladeRF2OutputGui::displaySampleRate()
|
|
|
|
{
|
|
|
|
int max, min, step;
|
2020-09-14 17:19:05 -04:00
|
|
|
float scale;
|
|
|
|
m_sampleSink->getSampleRateRange(min, max, step, scale);
|
2019-04-12 08:14:17 -04:00
|
|
|
|
|
|
|
ui->sampleRate->blockSignals(true);
|
|
|
|
|
|
|
|
if (m_sampleRateMode)
|
|
|
|
{
|
|
|
|
ui->sampleRateMode->setStyleSheet("QToolButton { background:rgb(60,60,60); }");
|
|
|
|
ui->sampleRateMode->setText("SR");
|
|
|
|
ui->sampleRate->setValueRange(8, min, max);
|
|
|
|
ui->sampleRate->setValue(m_settings.m_devSampleRate);
|
2019-04-13 17:00:02 -04:00
|
|
|
ui->sampleRate->setToolTip("Host to device sample rate (S/s)");
|
2019-04-12 08:14:17 -04:00
|
|
|
ui->deviceRateText->setToolTip("Baseband sample rate (S/s)");
|
|
|
|
uint32_t basebandSampleRate = m_settings.m_devSampleRate/(1<<m_settings.m_log2Interp);
|
|
|
|
ui->deviceRateText->setText(tr("%1k").arg(QString::number(basebandSampleRate / 1000.0f, 'g', 5)));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui->sampleRateMode->setStyleSheet("QToolButton { background:rgb(50,50,50); }");
|
|
|
|
ui->sampleRateMode->setText("BB");
|
|
|
|
ui->sampleRate->setValueRange(8, min/(1<<m_settings.m_log2Interp), max/(1<<m_settings.m_log2Interp));
|
|
|
|
ui->sampleRate->setValue(m_settings.m_devSampleRate/(1<<m_settings.m_log2Interp));
|
|
|
|
ui->sampleRate->setToolTip("Baseband sample rate (S/s)");
|
2019-04-13 17:00:02 -04:00
|
|
|
ui->deviceRateText->setToolTip("Host to device sample rate (S/s)");
|
2019-04-12 08:14:17 -04:00
|
|
|
ui->deviceRateText->setText(tr("%1k").arg(QString::number(m_settings.m_devSampleRate / 1000.0f, 'g', 5)));
|
|
|
|
}
|
|
|
|
|
|
|
|
ui->sampleRate->blockSignals(false);
|
2018-09-29 03:56:54 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void BladeRF2OutputGui::displaySettings()
|
|
|
|
{
|
|
|
|
blockApplySettings(true);
|
|
|
|
|
2019-01-16 15:28:35 -05:00
|
|
|
ui->transverter->setDeltaFrequency(m_settings.m_transverterDeltaFrequency);
|
|
|
|
ui->transverter->setDeltaFrequencyActive(m_settings.m_transverterMode);
|
|
|
|
|
2020-04-25 06:25:50 -04:00
|
|
|
updateFrequencyLimits();
|
|
|
|
|
2018-09-29 03:56:54 -04:00
|
|
|
ui->centerFrequency->setValue(m_settings.m_centerFrequency / 1000);
|
2018-09-30 04:59:52 -04:00
|
|
|
ui->LOppm->setValue(m_settings.m_LOppmTenths);
|
|
|
|
ui->LOppmText->setText(QString("%1").arg(QString::number(m_settings.m_LOppmTenths/10.0, 'f', 1)));
|
2020-04-25 06:25:50 -04:00
|
|
|
|
2019-04-12 08:14:17 -04:00
|
|
|
displaySampleRate();
|
2018-09-29 03:56:54 -04:00
|
|
|
|
2020-04-25 06:25:50 -04:00
|
|
|
ui->bandwidth->setValue(m_settings.m_bandwidth / 1000);
|
2018-09-29 03:56:54 -04:00
|
|
|
ui->interp->setCurrentIndex(m_settings.m_log2Interp);
|
2020-09-14 17:04:35 -04:00
|
|
|
ui->gainText->setText(tr("%1 dB").arg(QString::number(m_settings.m_globalGain, 'f', 2)));
|
|
|
|
ui->gain->setValue(getGainValue(m_settings.m_globalGain));
|
2019-01-16 15:28:35 -05:00
|
|
|
ui->biasTee->setChecked(m_settings.m_biasTee);
|
2018-09-29 03:56:54 -04:00
|
|
|
|
|
|
|
blockApplySettings(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BladeRF2OutputGui::sendSettings()
|
|
|
|
{
|
2022-10-29 23:50:53 -04:00
|
|
|
if (!m_updateTimer.isActive()) {
|
2018-09-29 03:56:54 -04:00
|
|
|
m_updateTimer.start(100);
|
2022-10-29 23:50:53 -04:00
|
|
|
}
|
2018-09-29 03:56:54 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void BladeRF2OutputGui::on_centerFrequency_changed(quint64 value)
|
|
|
|
{
|
|
|
|
m_settings.m_centerFrequency = value * 1000;
|
2022-10-29 23:50:53 -04:00
|
|
|
m_settingsKeys.append("centerFrequency");
|
2018-09-29 03:56:54 -04:00
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
2018-09-30 04:59:52 -04:00
|
|
|
void BladeRF2OutputGui::on_LOppm_valueChanged(int value)
|
|
|
|
{
|
|
|
|
ui->LOppmText->setText(QString("%1").arg(QString::number(value/10.0, 'f', 1)));
|
|
|
|
m_settings.m_LOppmTenths = value;
|
2022-10-29 23:50:53 -04:00
|
|
|
m_settingsKeys.append("LOppmTenths");
|
2018-09-30 04:59:52 -04:00
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
2018-09-29 03:56:54 -04:00
|
|
|
void BladeRF2OutputGui::on_sampleRate_changed(quint64 value)
|
|
|
|
{
|
2019-04-12 08:14:17 -04:00
|
|
|
if (m_sampleRateMode) {
|
|
|
|
m_settings.m_devSampleRate = value;
|
|
|
|
} else {
|
|
|
|
m_settings.m_devSampleRate = value * (1 << m_settings.m_log2Interp);
|
|
|
|
}
|
|
|
|
|
2022-10-29 23:50:53 -04:00
|
|
|
m_settingsKeys.append("devSampleRate");
|
2018-09-29 03:56:54 -04:00
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void BladeRF2OutputGui::on_biasTee_toggled(bool checked)
|
|
|
|
{
|
|
|
|
m_settings.m_biasTee = checked;
|
2022-10-29 23:50:53 -04:00
|
|
|
m_settingsKeys.append("biasTee");
|
2018-09-29 03:56:54 -04:00
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void BladeRF2OutputGui::on_bandwidth_changed(quint64 value)
|
|
|
|
{
|
|
|
|
m_settings.m_bandwidth = value * 1000;
|
2022-10-29 23:50:53 -04:00
|
|
|
m_settingsKeys.append("bandwidth");
|
2018-09-29 03:56:54 -04:00
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void BladeRF2OutputGui::on_interp_currentIndexChanged(int index)
|
|
|
|
{
|
2019-04-12 08:14:17 -04:00
|
|
|
if ((index <0) || (index > 6)) {
|
2018-09-29 03:56:54 -04:00
|
|
|
return;
|
2019-04-12 08:14:17 -04:00
|
|
|
}
|
|
|
|
|
2018-09-29 03:56:54 -04:00
|
|
|
m_settings.m_log2Interp = index;
|
2022-10-29 23:50:53 -04:00
|
|
|
m_settingsKeys.append("log2Interp");
|
2019-04-12 08:14:17 -04:00
|
|
|
displaySampleRate();
|
|
|
|
|
|
|
|
if (m_sampleRateMode) {
|
|
|
|
m_settings.m_devSampleRate = ui->sampleRate->getValueNew();
|
|
|
|
} else {
|
|
|
|
m_settings.m_devSampleRate = ui->sampleRate->getValueNew() * (1 << m_settings.m_log2Interp);
|
|
|
|
}
|
|
|
|
|
2022-10-29 23:50:53 -04:00
|
|
|
m_settingsKeys.append("devSampleRate");
|
2018-09-29 03:56:54 -04:00
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void BladeRF2OutputGui::on_gain_valueChanged(int value)
|
|
|
|
{
|
2020-09-14 17:04:35 -04:00
|
|
|
float displayableGain = getGainDB(value);
|
|
|
|
ui->gainText->setText(tr("%1 dB").arg(QString::number(displayableGain, 'f', 2)));
|
|
|
|
m_settings.m_globalGain = (int) displayableGain;
|
2022-10-29 23:50:53 -04:00
|
|
|
m_settingsKeys.append("globalGain");
|
2018-09-29 03:56:54 -04:00
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
2018-10-03 00:14:26 -04:00
|
|
|
void BladeRF2OutputGui::on_transverter_clicked()
|
|
|
|
{
|
|
|
|
m_settings.m_transverterMode = ui->transverter->getDeltaFrequencyAcive();
|
|
|
|
m_settings.m_transverterDeltaFrequency = ui->transverter->getDeltaFrequency();
|
|
|
|
qDebug("LimeSDRInputGUI::on_transverter_clicked: %lld Hz %s", m_settings.m_transverterDeltaFrequency, m_settings.m_transverterMode ? "on" : "off");
|
|
|
|
updateFrequencyLimits();
|
|
|
|
setCenterFrequencySetting(ui->centerFrequency->getValueNew());
|
2022-10-29 23:50:53 -04:00
|
|
|
m_settingsKeys.append("transverterMode");
|
|
|
|
m_settingsKeys.append("transverterDeltaFrequency");
|
|
|
|
m_settingsKeys.append("centerFrequency");
|
2018-10-03 00:14:26 -04:00
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
2018-09-29 03:56:54 -04:00
|
|
|
void BladeRF2OutputGui::on_startStop_toggled(bool checked)
|
|
|
|
{
|
|
|
|
if (m_doApplySettings)
|
|
|
|
{
|
|
|
|
BladeRF2Output::MsgStartStop *message = BladeRF2Output::MsgStartStop::create(checked);
|
|
|
|
m_sampleSink->getInputMessageQueue()->push(message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-12 08:14:17 -04:00
|
|
|
void BladeRF2OutputGui::on_sampleRateMode_toggled(bool checked)
|
|
|
|
{
|
|
|
|
m_sampleRateMode = checked;
|
|
|
|
displaySampleRate();
|
|
|
|
}
|
|
|
|
|
2018-09-29 03:56:54 -04:00
|
|
|
void BladeRF2OutputGui::updateHardware()
|
|
|
|
{
|
|
|
|
if (m_doApplySettings)
|
|
|
|
{
|
|
|
|
qDebug() << "BladeRF2OutputGui::updateHardware";
|
2022-10-29 23:50:53 -04:00
|
|
|
BladeRF2Output::MsgConfigureBladeRF2* message = BladeRF2Output::MsgConfigureBladeRF2::create(m_settings, m_settingsKeys, m_forceSettings);
|
2018-09-29 03:56:54 -04:00
|
|
|
m_sampleSink->getInputMessageQueue()->push(message);
|
|
|
|
m_forceSettings = false;
|
2022-10-29 23:50:53 -04:00
|
|
|
m_settingsKeys.clear();
|
2018-09-29 03:56:54 -04:00
|
|
|
m_updateTimer.stop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BladeRF2OutputGui::updateStatus()
|
|
|
|
{
|
2019-05-08 16:11:53 -04:00
|
|
|
int state = m_deviceUISet->m_deviceAPI->state();
|
2018-09-29 03:56:54 -04:00
|
|
|
|
|
|
|
if(m_lastEngineState != state)
|
|
|
|
{
|
|
|
|
switch(state)
|
|
|
|
{
|
2019-05-08 16:11:53 -04:00
|
|
|
case DeviceAPI::StNotStarted:
|
2018-09-29 03:56:54 -04:00
|
|
|
ui->startStop->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
|
|
|
|
break;
|
2019-05-08 16:11:53 -04:00
|
|
|
case DeviceAPI::StIdle:
|
2018-09-29 03:56:54 -04:00
|
|
|
ui->startStop->setStyleSheet("QToolButton { background-color : blue; }");
|
|
|
|
break;
|
2019-05-08 16:11:53 -04:00
|
|
|
case DeviceAPI::StRunning:
|
2018-09-29 03:56:54 -04:00
|
|
|
ui->startStop->setStyleSheet("QToolButton { background-color : green; }");
|
|
|
|
break;
|
2019-05-08 16:11:53 -04:00
|
|
|
case DeviceAPI::StError:
|
2018-09-29 03:56:54 -04:00
|
|
|
ui->startStop->setStyleSheet("QToolButton { background-color : red; }");
|
2019-05-08 16:11:53 -04:00
|
|
|
QMessageBox::information(this, tr("Message"), m_deviceUISet->m_deviceAPI->errorMessage());
|
2018-09-29 03:56:54 -04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_lastEngineState = state;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-26 13:22:52 -05:00
|
|
|
void BladeRF2OutputGui::openDeviceSettingsDialog(const QPoint& p)
|
|
|
|
{
|
2022-04-16 19:31:50 -04:00
|
|
|
if (m_contextMenuType == ContextMenuDeviceSettings)
|
|
|
|
{
|
|
|
|
BasicDeviceSettingsDialog dialog(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);
|
2018-12-26 13:22:52 -05:00
|
|
|
|
2022-04-16 19:31:50 -04:00
|
|
|
dialog.move(p);
|
2022-12-20 05:31:15 -05:00
|
|
|
new DialogPositioner(&dialog, false);
|
2022-04-16 19:31:50 -04:00
|
|
|
dialog.exec();
|
2018-12-26 13:22:52 -05:00
|
|
|
|
2022-04-16 19:31:50 -04:00
|
|
|
m_settings.m_useReverseAPI = dialog.useReverseAPI();
|
|
|
|
m_settings.m_reverseAPIAddress = dialog.getReverseAPIAddress();
|
|
|
|
m_settings.m_reverseAPIPort = dialog.getReverseAPIPort();
|
|
|
|
m_settings.m_reverseAPIDeviceIndex = dialog.getReverseAPIDeviceIndex();
|
2022-10-29 23:50:53 -04:00
|
|
|
m_settingsKeys.append("useReverseAPI");
|
|
|
|
m_settingsKeys.append("reverseAPIAddress");
|
|
|
|
m_settingsKeys.append("reverseAPIPort");
|
|
|
|
m_settingsKeys.append("reverseAPIDeviceIndex");
|
2018-12-26 13:22:52 -05:00
|
|
|
|
2022-04-16 19:31:50 -04:00
|
|
|
sendSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
resetContextMenuType();
|
2018-12-26 13:22:52 -05:00
|
|
|
}
|
2020-09-14 17:04:35 -04:00
|
|
|
|
|
|
|
float BladeRF2OutputGui::getGainDB(int gainValue)
|
|
|
|
{
|
|
|
|
float gain = gainValue*m_gainStep*m_gainScale;
|
|
|
|
// qDebug("BladeRF2OutputGui::getGainDB: gainValue: %d m_gainMin: %d m_gainMax: %d m_gainStep: %d gain: %f",
|
|
|
|
// gainValue, m_gainMin, m_gainMax, m_gainStep, gain);
|
|
|
|
return gain;
|
|
|
|
}
|
|
|
|
|
|
|
|
int BladeRF2OutputGui::getGainValue(float gainDB)
|
|
|
|
{
|
|
|
|
int gain = (gainDB/m_gainScale) / m_gainStep;
|
|
|
|
// qDebug("BladeRF2OutputGui::getGainValue: gainDB: %f m_gainMin: %d m_gainMax: %d m_gainStep: %d gain: %d",
|
|
|
|
// gainDB, m_gainMin, m_gainMax, m_gainStep, gain);
|
|
|
|
return gain;
|
|
|
|
}
|
2022-04-07 10:32:03 -04:00
|
|
|
|
|
|
|
void BladeRF2OutputGui::makeUIConnections()
|
|
|
|
{
|
|
|
|
QObject::connect(ui->centerFrequency, &ValueDial::changed, this, &BladeRF2OutputGui::on_centerFrequency_changed);
|
|
|
|
QObject::connect(ui->LOppm, &QSlider::valueChanged, this, &BladeRF2OutputGui::on_LOppm_valueChanged);
|
|
|
|
QObject::connect(ui->biasTee, &ButtonSwitch::toggled, this, &BladeRF2OutputGui::on_biasTee_toggled);
|
|
|
|
QObject::connect(ui->sampleRate, &ValueDial::changed, this, &BladeRF2OutputGui::on_sampleRate_changed);
|
|
|
|
QObject::connect(ui->bandwidth, &ValueDial::changed, this, &BladeRF2OutputGui::on_bandwidth_changed);
|
|
|
|
QObject::connect(ui->interp, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &BladeRF2OutputGui::on_interp_currentIndexChanged);
|
|
|
|
QObject::connect(ui->gain, &QSlider::valueChanged, this, &BladeRF2OutputGui::on_gain_valueChanged);
|
|
|
|
QObject::connect(ui->startStop, &ButtonSwitch::toggled, this, &BladeRF2OutputGui::on_startStop_toggled);
|
|
|
|
QObject::connect(ui->transverter, &TransverterButton::clicked, this, &BladeRF2OutputGui::on_transverter_clicked);
|
|
|
|
QObject::connect(ui->sampleRateMode, &QToolButton::toggled, this, &BladeRF2OutputGui::on_sampleRateMode_toggled);
|
|
|
|
}
|