Skip to content

Commit

Permalink
Remove obsolete gain controls.
Browse files Browse the repository at this point in the history
Issue #90.
  • Loading branch information
csete committed Sep 23, 2013
1 parent be2de44 commit 493878f
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 139 deletions.
13 changes: 1 addition & 12 deletions applications/gqrx/mainwindow.cpp
Expand Up @@ -140,8 +140,7 @@ MainWindow::MainWindow(const QString cfgfile, bool edit_conf, QWidget *parent) :
/* connect signals and slots */
connect(ui->freqCtrl, SIGNAL(newFrequency(qint64)), this, SLOT(setNewFrequency(qint64)));
connect(uiDockInputCtl, SIGNAL(lnbLoChanged(double)), this, SLOT(setLnbLo(double)));
connect(uiDockInputCtl, SIGNAL(gainChanged(double)), SLOT(setRfGain(double)));
connect(uiDockInputCtl, SIGNAL(namedGainChanged(QString, double)), this, SLOT(setGain(QString,double)));
connect(uiDockInputCtl, SIGNAL(gainChanged(QString, double)), this, SLOT(setGain(QString,double)));
connect(uiDockInputCtl, SIGNAL(freqCorrChanged(int)), this, SLOT(setFreqCorr(int)));
connect(uiDockInputCtl, SIGNAL(iqSwapChanged(bool)), this, SLOT(setIqSwap(bool)));
connect(uiDockInputCtl, SIGNAL(dcCancelChanged(bool)), this, SLOT(setDcCancel(bool)));
Expand Down Expand Up @@ -552,16 +551,6 @@ void MainWindow::setFilterOffset(qint64 freq_hz)
ui->freqCtrl->setFrequency(rx_freq);
}

/*! \brief Set RF gain.
* \param gain The new RF gain.
*
* Valid range depends on hardware.
*/
void MainWindow::setRfGain(double gain)
{
rx->set_rf_gain(gain);
}

/*! \brief Set a specific gain.
* \param name The name of the gain stage to adjust.
* \param gain The new value.
Expand Down
1 change: 0 additions & 1 deletion applications/gqrx/mainwindow.h
Expand Up @@ -116,7 +116,6 @@ private slots:

/* baseband receiver */
void setFilterOffset(qint64 freq_hz);
void setRfGain(double gain);
void setGain(QString name, double gain);
void setFreqCorr(int ppm);
void setIqSwap(bool reversed);
Expand Down
14 changes: 7 additions & 7 deletions applications/gqrx/mainwindow.ui
Expand Up @@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>900</width>
<width>950</width>
<height>600</height>
</rect>
</property>
Expand Down Expand Up @@ -127,8 +127,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>900</width>
<height>25</height>
<width>950</width>
<height>29</height>
</rect>
</property>
<widget class="QMenu" name="menu_File">
Expand Down Expand Up @@ -376,15 +376,15 @@
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>CPlotter</class>
<class>CFreqCtrl</class>
<extends>QFrame</extends>
<header>qtgui/plotter.h</header>
<header>qtgui/freqctrl.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>CFreqCtrl</class>
<class>CPlotter</class>
<extends>QFrame</extends>
<header>qtgui/freqctrl.h</header>
<header>qtgui/plotter.h</header>
<container>1</container>
</customwidget>
<customwidget>
Expand Down
69 changes: 17 additions & 52 deletions qtgui/dockinputctl.cpp
Expand Up @@ -32,7 +32,7 @@ DockInputCtl::DockInputCtl(QWidget *parent) :

// Grid layout with gain contorls (device dependent)
gainLayout = new QGridLayout(this);
ui->verticalLayout->insertLayout(1, gainLayout);
ui->verticalLayout->insertLayout(2, gainLayout);
}

DockInputCtl::~DockInputCtl()
Expand Down Expand Up @@ -66,9 +66,9 @@ void DockInputCtl::readSettings(QSettings *settings)
emit ignoreLimitsChanged(ignore_limits);

// FIXME
double gain = settings->value("input/gain", -1).toDouble(&conv_ok);
setGain(gain);
emit gainChanged(gain);
//double gain = settings->value("input/gain", -1).toDouble(&conv_ok);
//setGain(gain);
//emit gainChanged(gain);

// Ignore antenna selection if there is only one option
if (ui->antSelector->count() > 1)
Expand All @@ -88,8 +88,8 @@ void DockInputCtl::saveSettings(QSettings *settings)
settings->remove("input/lnb_lo");

// FIXME
double dblval = gain();
settings->setValue("input/gain", dblval);
//double dblval = gain();
//settings->setValue("input/gain", dblval);

if (freqCorr())
settings->setValue("input/corr_freq", freqCorr());
Expand Down Expand Up @@ -133,34 +133,11 @@ double DockInputCtl::lnbLo()
return ui->lnbSpinBox->value();
}


/*! \brief Set new relative gain.
* \param gain The new gain in the range 0.0 .. 1.0 or -1 to enable AGC.
*/
void DockInputCtl::setGain(double gain)
{
if (gain > 1.0)
{
qDebug() << "DockInputCtl::setGain :" << gain;
gain = 1.0;
}

if (gain < 0.0)
{
ui->gainButton->setChecked(true);
}
else
{
ui->gainButton->setChecked(false);
ui->gainSlider->setValue((int)(gain*100.0));
}
}

/*! \brief Set new value of a specific gain.
* \param name The name of the gain to change.
* \param value The new value.
*/
void DockInputCtl::setNamedGain(QString &name, double value)
void DockInputCtl::setGain(QString &name, double value)
{
int gain = -1;

Expand All @@ -178,11 +155,12 @@ void DockInputCtl::setNamedGain(QString &name, double value)
/*! \brief Get current gain.
* \returns The relative gain between 0.0 and 1.0 or -1 if HW AGC is enabled.
*/
double DockInputCtl::gain()
double DockInputCtl::gain(QString &name)
{
double gain = ui->gainButton->isChecked() ? -1.0 : (double)ui->gainSlider->value()/100.0;
qDebug() << "*** FIXME:" << __func__;
//double gain = ui->gainButton->isChecked() ? -1.0 : (double)ui->gainSlider->value()/100.0;

return gain;
return 0.0;
}


Expand Down Expand Up @@ -287,7 +265,7 @@ void DockInputCtl::setGainStages(gain_list_t &gain_list)
step = (int)(10.0 * gain_list[i].step);
gain = (int)(10.0 * gain_list[i].value);

label = new QLabel(gain_list[i].name.c_str(), this);
label = new QLabel(QString("%1 gain").arg(gain_list[i].name.c_str()), this);
label->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum));

value = new QLabel(QString("%1 dB").arg(gain_list[i].value, 0, 'f', 1), this);
Expand Down Expand Up @@ -331,30 +309,17 @@ void DockInputCtl::on_lnbSpinBox_valueChanged(double value)
emit lnbLoChanged(value);
}


/*! \brief Manual gain value has changed. */
/*void DockInputCtl::on_gainSlider_valueChanged(int value)
{
double gain = (double)value/100.0;
emit gainChanged(gain);
}*/

/*! \brief Automatic gain control button has been toggled. */
void DockInputCtl::on_gainButton_toggled(bool checked)
{
double gain = checked ? -1.0 : (double)ui->gainSlider->value()/100.0;
qDebug() << "*** FIXME:" << __func__;
/* double gain = checked ? -1.0 : (double)ui->gainSlider->value()/100.0;
ui->gainSlider->setEnabled(!checked);
emit gainChanged(gain);
*/
}

/*! \brief Gain options buttion clicked. Show dialog. */
/*void DockInputCtl::on_gainOptButton_pressed()
{
gainOpt->show();
}*/

/*! \brief Frequency correction changed.
* \param value The new frequency correction in ppm.
*/
Expand Down Expand Up @@ -403,7 +368,6 @@ void DockInputCtl::on_antSelector_currentIndexChanged(const QString &antenna)
emit antennaSelected(antenna);
}


/*! \brief Remove all widgets from the lists. */
void DockInputCtl::clearWidgets()
{
Expand Down Expand Up @@ -450,7 +414,8 @@ void DockInputCtl::sliderValueChanged(int value)
// convert to double and send signal
double gain = (double)value / 10.0;
updateLabel(idx, gain);
emit namedGainChanged(gain_labels.at(idx)->text(), gain);

emit gainChanged(gain_labels.at(idx)->text(), gain);
}

/*! \brief Update value label
Expand Down
12 changes: 3 additions & 9 deletions qtgui/dockinputctl.h
Expand Up @@ -71,10 +71,8 @@ class DockInputCtl : public QDockWidget
void setLnbLo(double freq_mhz);
double lnbLo();

void setGain(double gain);
double gain();

void setNamedGain(QString &name, double value);
void setGain(QString &name, double value);
double gain(QString &name);

void setFreqCorr(int corr);
int freqCorr();
Expand All @@ -97,8 +95,7 @@ class DockInputCtl : public QDockWidget
void setGainStages(gain_list_t &gain_list);

signals:
void gainChanged(double gain); // FIXME
void namedGainChanged(QString name, double value); // FIXME
void gainChanged(QString name, double value);
void freqCorrChanged(int value);
void lnbLoChanged(double freq_mhz);
void iqSwapChanged(bool reverse);
Expand All @@ -109,9 +106,7 @@ class DockInputCtl : public QDockWidget

private slots:
void on_lnbSpinBox_valueChanged(double value);
//void on_gainSlider_valueChanged(int value);
void on_gainButton_toggled(bool checked);
//void on_gainOptButton_pressed();
void on_freqCorrSpinBox_valueChanged(int value);
void on_iqSwapButton_toggled(bool checked);
void on_dcCancelButton_toggled(bool checked);
Expand All @@ -120,7 +115,6 @@ private slots:
void on_antSelector_currentIndexChanged(const QString &antenna);

void sliderValueChanged(int value);
//void gainChanged(QString name, double value);

private:
void clearWidgets();
Expand Down
69 changes: 11 additions & 58 deletions qtgui/dockinputctl.ui
Expand Up @@ -113,50 +113,31 @@
<item>
<widget class="QLabel" name="gainLabel">
<property name="text">
<string>Gain</string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="gainSlider">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Manual gain control.&lt;/p&gt;&lt;p&gt;This control will try to distribute the gain between the available stages. Known to work with USRP and single-stage devices such as rtlsdr.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="value">
<number>50</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::NoTicks</enum>
</property>
<property name="tickInterval">
<number>10</number>
<string>Gain:</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="gainButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>28</width>
<height>28</height>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>28</width>
<height>28</height>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="baseSize">
Expand All @@ -166,44 +147,16 @@
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Automatic gain control.&lt;br/&gt;Requires hardware support. Know to work with rtl-sdr.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Automatic gain control.&lt;br/&gt;Requires hardware support. Known to work with rtl-sdr.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>A</string>
<string>Auto</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="gainOptButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>28</width>
<height>28</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>28</width>
<height>28</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Manual gain control.&lt;/p&gt;&lt;p&gt;Allows you to adjust the gain of each individual stage.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
Expand Down

0 comments on commit 493878f

Please sign in to comment.