1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-12 19:36:10 -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() void RTLSDRGui::updateFrequencyLimits()
{ {
// values in kHz // values in kHz
qint64 minLimit = (m_settings.m_noModMode ? RTLSDRInput::frequencyLowRangeMin : RTLSDRInput::frequencyHighRangeMin) + m_settings.m_transverterDeltaFrequency/1000; qint64 deltaFrequency = m_settings.m_transverterMode ? m_settings.m_transverterDeltaFrequency/1000 : 0;
qint64 maxLimit = (m_settings.m_noModMode ? RTLSDRInput::frequencyLowRangeMax : RTLSDRInput::frequencyHighRangeMax) + m_settings.m_transverterDeltaFrequency/1000; 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; minLimit = minLimit < 0 ? 0 : minLimit > 9999999 ? 9999999 : minLimit;
maxLimit = maxLimit < 0 ? 0 : maxLimit > 9999999 ? 9999999 : maxLimit; 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); ui->centerFrequency->setValueRange(7, minLimit, maxLimit);
} }
@ -299,10 +302,6 @@ void RTLSDRGui::on_gain_valueChanged(int value)
sendSettings(); sendSettings();
} }
void RTLSDRGui::on_sampleRate_currentIndexChanged(int index __attribute__((unused)))
{
}
void RTLSDRGui::on_startStop_toggled(bool checked) void RTLSDRGui::on_startStop_toggled(bool checked)
{ {
if (checked) if (checked)
@ -332,10 +331,11 @@ void RTLSDRGui::on_record_toggled(bool checked)
m_sampleSource->getInputMessageQueue()->push(message); 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_transverterMode = ui->transverter->getDeltaFrequencyAcive();
m_settings.m_transverterDeltaFrequency = checked ? ui->transverter->getDeltaFrequency() : 0; 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(); updateFrequencyLimits();
m_settings.m_centerFrequency = ui->centerFrequency->getValueNew()*1000; m_settings.m_centerFrequency = ui->centerFrequency->getValueNew()*1000;
sendSettings(); sendSettings();

View File

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

View File

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

View File

@ -22,22 +22,18 @@
#include "transverterbutton.h" #include "transverterbutton.h"
TransverterButton::TransverterButton(QWidget* parent) : TransverterButton::TransverterButton(QWidget* parent) :
ButtonSwitch(parent), QPushButton(parent),
m_deltaFrequency(0) 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, m_deltaFrequencyActive, this);
TransverterDialog transverterDialog(&m_deltaFrequency, this);
transverterDialog.exec(); transverterDialog.exec();
setToolTip(tr("Transverter frequency translation toggle. Delta frequency %1 MHz").arg(m_deltaFrequency/1000000.0)); setToolTip(tr("Transverter frequency translation dialog. Delta frequency %1 MHz %2")
} .arg(m_deltaFrequency/1000000.0)
} .arg(m_deltaFrequencyActive ? "enabled" : "disabled"));
void TransverterButton::doToggle(bool checked)
{
onToggled(checked);
} }

View File

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

View File

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

View File

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

View File

@ -60,7 +60,6 @@
<property name="toolTip"> <property name="toolTip">
<string>Transverter delta frequency (Hz)</string> <string>Transverter delta frequency (Hz)</string>
</property> </property>
<zorder>deltaFrequencyUnits</zorder>
</widget> </widget>
</item> </item>
<item> <item>
@ -83,6 +82,20 @@
</property> </property>
</spacer> </spacer>
</item> </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> </layout>
</item> </item>
</layout> </layout>
@ -106,11 +119,18 @@
<header>gui/valuedialz.h</header> <header>gui/valuedialz.h</header>
<container>1</container> <container>1</container>
</customwidget> </customwidget>
<customwidget>
<class>ButtonSwitch</class>
<extends>QToolButton</extends>
<header>gui/buttonswitch.h</header>
</customwidget>
</customwidgets> </customwidgets>
<tabstops> <tabstops>
<tabstop>buttonBox</tabstop> <tabstop>buttonBox</tabstop>
</tabstops> </tabstops>
<resources/> <resources>
<include location="../resources/res.qrc"/>
</resources>
<connections> <connections>
<connection> <connection>
<sender>buttonBox</sender> <sender>buttonBox</sender>