1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-23 10:05:46 -05:00

RTLSDR tranverter mode interim state (1)

This commit is contained in:
f4exb 2017-09-24 02:08:08 +02:00
parent 25272f21d0
commit 87a60ff220
8 changed files with 67 additions and 37 deletions

View File

@ -179,12 +179,15 @@ void RTLSDRGui::updateSampleRateAndFrequency()
void RTLSDRGui::updateFrequencyLimits()
{
// values in kHz
qint64 minLimit = (m_settings.m_noModMode ? RTLSDRInput::frequencyLowRangeMin : RTLSDRInput::frequencyHighRangeMin) + m_settings.m_transverterDeltaFrequency/1000;
qint64 maxLimit = (m_settings.m_noModMode ? RTLSDRInput::frequencyLowRangeMax : RTLSDRInput::frequencyHighRangeMax) + m_settings.m_transverterDeltaFrequency/1000;
qint64 deltaFrequency = m_settings.m_transverterMode ? m_settings.m_transverterDeltaFrequency/1000 : 0;
qint64 minLimit = (m_settings.m_noModMode ? RTLSDRInput::frequencyLowRangeMin : RTLSDRInput::frequencyHighRangeMin) + deltaFrequency;
qint64 maxLimit = (m_settings.m_noModMode ? RTLSDRInput::frequencyLowRangeMax : RTLSDRInput::frequencyHighRangeMax) + deltaFrequency;
minLimit = minLimit < 0 ? 0 : minLimit > 9999999 ? 9999999 : minLimit;
maxLimit = maxLimit < 0 ? 0 : maxLimit > 9999999 ? 9999999 : maxLimit;
qDebug("RTLSDRGui::updateFrequencyLimits: delta: %lld min: %lld max: %lld", deltaFrequency, minLimit, maxLimit);
ui->centerFrequency->setValueRange(7, minLimit, maxLimit);
}
@ -299,10 +302,6 @@ void RTLSDRGui::on_gain_valueChanged(int value)
sendSettings();
}
void RTLSDRGui::on_sampleRate_currentIndexChanged(int index __attribute__((unused)))
{
}
void RTLSDRGui::on_startStop_toggled(bool checked)
{
if (checked)
@ -332,10 +331,11 @@ void RTLSDRGui::on_record_toggled(bool checked)
m_sampleSource->getInputMessageQueue()->push(message);
}
void RTLSDRGui::on_transverter_toggled(bool checked)
void RTLSDRGui::on_transverter_clicked()
{
m_settings.m_transverterMode = checked;
m_settings.m_transverterDeltaFrequency = checked ? ui->transverter->getDeltaFrequency() : 0;
m_settings.m_transverterMode = ui->transverter->getDeltaFrequencyAcive();
m_settings.m_transverterDeltaFrequency = ui->transverter->getDeltaFrequency();
qDebug("RTLSDRGui::on_transverter_clicked: %lld Hz %s", m_settings.m_transverterDeltaFrequency, m_settings.m_transverterMode ? "on" : "off");
updateFrequencyLimits();
m_settings.m_centerFrequency = ui->centerFrequency->getValueNew()*1000;
sendSettings();

View File

@ -82,12 +82,11 @@ private slots:
void on_fcPos_currentIndexChanged(int index);
void on_ppm_valueChanged(int value);
void on_gain_valueChanged(int value);
void on_sampleRate_currentIndexChanged(int index);
void on_checkBox_stateChanged(int state);
void on_agc_stateChanged(int state);
void on_startStop_toggled(bool checked);
void on_record_toggled(bool checked);
void on_transverter_toggled(bool checked);
void on_transverter_clicked();
void updateHardware();
void updateStatus();
};

View File

@ -300,12 +300,21 @@
</item>
<item row="0" column="6">
<widget class="TransverterButton" name="transverter">
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="toolTip">
<string>Transverter frequency translation toggle</string>
</property>
<property name="text">
<string>X</string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
</widget>
</item>
</layout>

View File

@ -22,22 +22,18 @@
#include "transverterbutton.h"
TransverterButton::TransverterButton(QWidget* parent) :
ButtonSwitch(parent),
m_deltaFrequency(0)
QPushButton(parent),
m_deltaFrequency(0),
m_deltaFrequencyActive(false)
{
connect(this, SIGNAL(toggled(bool)), this, SLOT(onToggled(bool)));
connect(this, SIGNAL(clicked(bool)), this, SLOT(onClicked(bool)));
}
void TransverterButton::onToggled(bool checked)
void TransverterButton::onClicked()
{
if (checked) {
TransverterDialog transverterDialog(&m_deltaFrequency, this);
transverterDialog.exec();
setToolTip(tr("Transverter frequency translation toggle. Delta frequency %1 MHz").arg(m_deltaFrequency/1000000.0));
}
}
void TransverterButton::doToggle(bool checked)
{
onToggled(checked);
TransverterDialog transverterDialog(m_deltaFrequency, m_deltaFrequencyActive, this);
transverterDialog.exec();
setToolTip(tr("Transverter frequency translation dialog. Delta frequency %1 MHz %2")
.arg(m_deltaFrequency/1000000.0)
.arg(m_deltaFrequencyActive ? "enabled" : "disabled"));
}

View File

@ -21,22 +21,24 @@
#ifndef SDRBASE_GUI_TRANSVERTERBUTTON_H_
#define SDRBASE_GUI_TRANSVERTERBUTTON_H_
#include "buttonswitch.h"
#include <QPushButton>
class TransverterButton : public ButtonSwitch {
class TransverterButton : public QPushButton {
Q_OBJECT
public:
TransverterButton(QWidget* parent = 0);
void doToggle(bool checked);
qint64 getDeltaFrequency() const { return m_deltaFrequency; }
void setDeltaFrequency(qint64 deltaFrequency) { m_deltaFrequency = deltaFrequency; }
bool getDeltaFrequencyAcive() const { return m_deltaFrequencyActive; }
void setDeltaFrequencyActive(bool active) { m_deltaFrequencyActive = active; }
private slots:
void onToggled(bool checked);
void onClicked();
private:
qint64 m_deltaFrequency;
bool m_deltaFrequencyActive;
};

View File

@ -23,16 +23,18 @@
#include "ui_transverterdialog.h"
TransverterDialog::TransverterDialog(qint64 *deltaFrequency, QWidget* parent) :
TransverterDialog::TransverterDialog(qint64& deltaFrequency, bool& deltaFrequencyActive, QWidget* parent) :
QDialog(parent),
ui(new Ui::TransverterDialog),
m_deltaFrequency(deltaFrequency)
m_deltaFrequency(deltaFrequency),
m_deltaFrequencyActive(deltaFrequencyActive)
{
ui->setupUi(this);
ui->deltaFrequencyLabel->setText(QString("%1f").arg(QChar(0x94, 0x03)));
ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));
ui->deltaFrequency->setValueRange(false, 10, -9999999999L, 9999999999L);
ui->deltaFrequency->setValue(*m_deltaFrequency);
ui->deltaFrequency->setValue(m_deltaFrequency);
ui->deltaFrequencyActive->setChecked(m_deltaFrequencyActive);
}
TransverterDialog::~TransverterDialog()
@ -42,6 +44,7 @@ TransverterDialog::~TransverterDialog()
void TransverterDialog::accept()
{
*m_deltaFrequency = ui->deltaFrequency->getValueNew();
m_deltaFrequency = ui->deltaFrequency->getValueNew();
m_deltaFrequencyActive = ui->deltaFrequencyActive->isChecked();
QDialog::accept();
}

View File

@ -31,12 +31,13 @@ class TransverterDialog : public QDialog {
Q_OBJECT
public:
explicit TransverterDialog(qint64 *deltaFrequency, QWidget* parent = 0);
explicit TransverterDialog(qint64& deltaFrequency, bool& deltaFrequencyActive, QWidget* parent = 0);
~TransverterDialog();
private:
Ui::TransverterDialog* ui;
qint64 *m_deltaFrequency;
qint64& m_deltaFrequency;
bool& m_deltaFrequencyActive;
private slots:
void accept();

View File

@ -60,7 +60,6 @@
<property name="toolTip">
<string>Transverter delta frequency (Hz)</string>
</property>
<zorder>deltaFrequencyUnits</zorder>
</widget>
</item>
<item>
@ -83,6 +82,20 @@
</property>
</spacer>
</item>
<item>
<widget class="ButtonSwitch" name="deltaFrequencyActive">
<property name="toolTip">
<string>Enable or disable frequency translation</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../resources/res.qrc">
<normaloff>:/checkmark.png</normaloff>:/checkmark.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
</layout>
@ -106,11 +119,18 @@
<header>gui/valuedialz.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ButtonSwitch</class>
<extends>QToolButton</extends>
<header>gui/buttonswitch.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>buttonBox</tabstop>
</tabstops>
<resources/>
<resources>
<include location="../resources/res.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>