Switch to new AGC control widgets.

This commit is contained in:
Alexandru Csete 2012-12-29 22:51:02 +01:00
parent 4e69ad61b7
commit 11e6eccb7b
7 changed files with 170 additions and 238 deletions

View File

@ -3,6 +3,7 @@
NEW: I/Q swapping option.
NEW: Save and restore FFT settings.
FIXED: Removed graphics redraw delay when changing frequency or demodulator.
IMPROVED: AGC settings moved to dialog window.
2.1.148 Released on December 9, 2012

View File

@ -17,6 +17,7 @@
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
#include <QDebug>
#include <QString>
#include "agc_options.h"
#include "ui_agc_options.h"
@ -33,17 +34,75 @@ CAgcOptions::~CAgcOptions()
delete ui;
}
/*! \brief Catch window close events.
*
* This method is called when the uses closes the dialog window using the
* window close icon. We catch the event and hide the dialog but keep it
* around for later use.
*/
void CAgcOptions::closeEvent(QCloseEvent *event)
{
hide();
event->ignore();
}
/*! \brief Get current gain slider value. */
int CAgcOptions::gain()
{
return ui->gainSlider->value();
}
/*! \brief Set AGC preset. */
void CAgcOptions::setPreset(agc_preset_e preset)
{
switch (preset)
{
case AGC_FAST:
setDecay(100);
enableDecay(false);
setSlope(2);
enableSlope(false);
enableGain(false);
break;
case AGC_MEDIUM:
setDecay(800);
enableDecay(false);
setSlope(2);
enableSlope(false);
enableGain(false);
break;
case AGC_SLOW:
setDecay(2000);
enableDecay(false);
setSlope(2);
enableSlope(false);
enableGain(false);
break;
case AGC_USER:
enableDecay(true);
enableSlope(true);
enableGain(false);
break;
case AGC_OFF:
enableGain(true);
break;
default:
qDebug() << __func__ << "Invalid AGC preset" << preset;
break;
}
}
/*! \brief Set new gain slider value. */
void CAgcOptions::setGain(int value)
{
ui->gainSlider->setValue(value);
ui->gainLabel->setText(QString::number(ui->gainSlider->value()));
ui->gainLabel->setText(QString("%1 dB").arg(ui->gainSlider->value()));
}
/*! \brief Enable or disable gain slider.
@ -69,7 +128,7 @@ int CAgcOptions::threshold()
void CAgcOptions::setThreshold(int value)
{
ui->thresholdSlider->setValue(value);
ui->thresholdLabel->setText(QString::number(ui->thresholdSlider->value()));
ui->thresholdLabel->setText(QString("%1 dB").arg(ui->thresholdSlider->value()));
}
/*! \brief Get current AGC slope. */
@ -82,7 +141,7 @@ int CAgcOptions::slope()
void CAgcOptions::setSlope(int value)
{
ui->slopeSlider->setValue(value);
ui->slopeLabel->setText(QString::number(ui->slopeSlider->value()));
ui->slopeLabel->setText(QString("%1 dB").arg(ui->slopeSlider->value()));
}
/*! \brief Enable or disable AGC slope slider.
@ -107,7 +166,7 @@ int CAgcOptions::decay()
void CAgcOptions::setDecay(int value)
{
ui->decaySlider->setValue(value);
ui->decayLabel->setText(QString::number(ui->decaySlider->value()));
ui->decayLabel->setText(QString("%1 ms").arg(ui->decaySlider->value()));
}
/*! \brief Enable or disable AGC decay slider.
@ -139,29 +198,34 @@ void CAgcOptions::setHang(bool checked)
/*! \brief AGC gain slider value has changed. */
void CAgcOptions::on_gainSlider_valueChanged(int gain)
{
ui->gainLabel->setText(QString("%1 dB").arg(ui->gainSlider->value()));
emit gainChanged(gain);
}
/*! \brief AGC threshold slider value has changed. */
void CAgcOptions::on_thresholdSlider_valueChanged(int threshold)
{
ui->thresholdLabel->setText(QString("%1 dB").arg(ui->thresholdSlider->value()));
emit thresholdChanged(threshold);
}
/*! \brief AGC slope slider value has changed. */
void CAgcOptions::on_slopeSlider_valueChanged(int slope)
{
ui->slopeLabel->setText(QString("%1 dB").arg(ui->slopeSlider->value()));
emit slopeChanged(slope);
}
/*! \brief AGC decay slider value has changed. */
void CAgcOptions::on_decaySlider_valueChanged(int decay)
{
ui->decayLabel->setText(QString("%1 ms").arg(ui->decaySlider->value()));
emit decayChanged(decay);
}
/*! \brief AGC hang button has been toggled. */
void CAgcOptions::on_hangButton_toggled(bool checked)
{
ui->hangButton->setText(checked ? tr("Enabled") : tr("Disabled"));
emit hangChanged(checked);
}

View File

@ -21,6 +21,7 @@
#define AGC_OPTIONS_H
#include <QDialog>
#include <QCloseEvent>
namespace Ui {
class CAgcOptions;
@ -45,6 +46,8 @@ class CAgcOptions : public QDialog
public:
explicit CAgcOptions(QWidget *parent = 0);
~CAgcOptions();
void closeEvent(QCloseEvent *event);
int gain();
void setGain(int value);
@ -64,6 +67,17 @@ public:
bool hang();
void setHang(bool checked);
enum agc_preset_e
{
AGC_FAST = 0, /*! decay = 500 ms, slope = 2 */
AGC_MEDIUM = 1, /*! decay = 1500 ms, slope = 2 */
AGC_SLOW = 2, /*! decay = 3000 ms, slope = 2 */
AGC_USER = 3,
AGC_OFF = 4
};
void setPreset(agc_preset_e preset);
signals:
void gainChanged(int gain);
void thresholdChanged(int threshold);

View File

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>237</width>
<width>263</width>
<height>197</height>
</rect>
</property>
@ -84,10 +84,10 @@
<item row="2" column="2">
<widget class="QLabel" name="thresholdLabel">
<property name="text">
<string>-100</string>
<string>-100 dB</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
@ -132,10 +132,10 @@
<string>Manual gain. Used when AGC is switched off</string>
</property>
<property name="text">
<string>0</string>
<string>0 dB</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
@ -176,10 +176,10 @@
<bool>false</bool>
</property>
<property name="text">
<string>100</string>
<string>100 ms</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
@ -221,10 +221,10 @@
<bool>false</bool>
</property>
<property name="text">
<string>2</string>
<string>2 dB</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>

View File

@ -39,12 +39,21 @@ DockRxOpt::DockRxOpt(qint64 filterOffsetRange, QWidget *parent) :
demodOpt->setCurrentPage(CDemodOptions::PAGE_FM_OPT);
connect(demodOpt, SIGNAL(fmMaxdevSelected(float)), this, SLOT(demodOpt_fmMaxdevSelected(float)));
connect(demodOpt, SIGNAL(fmEmphSelected(double)), this, SLOT(demodOpt_fmEmphSelected(double)));
/* AGC options dialog */
agcOpt = new CAgcOptions(this);
connect(agcOpt, SIGNAL(gainChanged(int)), this, SLOT(agcOpt_gainChanged(int)));
connect(agcOpt, SIGNAL(thresholdChanged(int)), this, SLOT(agcOpt_thresholdChanged(int)));
connect(agcOpt, SIGNAL(decayChanged(int)), this, SLOT(agcOpt_decayChanged(int)));
connect(agcOpt, SIGNAL(slopeChanged(int)), this, SLOT(agcOpt_slopeChanged(int)));
connect(agcOpt, SIGNAL(hangChanged(bool)), this, SLOT(agcOpt_hangToggled(bool)));
}
DockRxOpt::~DockRxOpt()
{
delete ui;
delete demodOpt;
delete agcOpt;
}
/*! \brief Set value of channel filter offset selector.
@ -218,91 +227,57 @@ void DockRxOpt::on_modeButton_clicked()
demodOpt->show();
}
/*! \brief AGC preset has changed.
*
* 0: Fast decay = 500 msec
* 1: Medium decay = 1500 msec
* 2: Slow decay = 3000 msec
* 3: User decay = set by user
* 4: Off Only fixed gain
/*! \brief Show AGC options.
*/
void DockRxOpt::on_agcButton_clicked()
{
agcOpt->show();
}
/*! \brief AGC preset has changed. */
void DockRxOpt::on_agcPresetCombo_activated(int index)
{
qDebug() << "NEW AGC preset:" << index;
CAgcOptions::agc_preset_e preset = (CAgcOptions::agc_preset_e) index;
switch (index) {
case 0:
if (!agc_is_on) {
switch (preset)
{
case CAgcOptions::AGC_FAST:
case CAgcOptions::AGC_MEDIUM:
case CAgcOptions::AGC_SLOW:
case CAgcOptions::AGC_USER:
if (!agc_is_on)
{
emit agcToggled(true);
agc_is_on = true;
}
// decay
ui->agcDecayDial->setValue(100);
emit agcDecayChanged(100);
ui->agcDecayDial->setEnabled(false);
// slope
ui->agcSlopeDial->setValue(2);
emit agcSlopeChanged(2);
ui->agcSlopeDial->setEnabled(false);
agcOpt->setPreset(preset);
break;
case 1:
if (!agc_is_on) {
emit agcToggled(true);
agc_is_on = true;
}
// decay
ui->agcDecayDial->setValue(800);
emit agcDecayChanged(800);
ui->agcDecayDial->setEnabled(false);
// slope
ui->agcSlopeDial->setValue(2);
emit agcSlopeChanged(2);
ui->agcSlopeDial->setEnabled(false);
break;
case 2:
if (!agc_is_on) {
emit agcToggled(true);
agc_is_on = true;
}
// decay
ui->agcDecayDial->setValue(2000);
emit agcDecayChanged(2000);
ui->agcDecayDial->setEnabled(false);
// slope
ui->agcSlopeDial->setValue(2);
emit agcSlopeChanged(2);
ui->agcSlopeDial->setEnabled(false);
break;
case 3:
if (!agc_is_on) {
emit agcToggled(true);
agc_is_on = true;
}
ui->agcDecayDial->setEnabled(true);
ui->agcSlopeDial->setEnabled(true);
break;
case 4:
if (agc_is_on) {
case CAgcOptions::AGC_OFF:
if (agc_is_on)
{
emit agcToggled(false);
agc_is_on = false;
}
agcOpt->setPreset(preset);
break;
default:
qDebug() << "Invalid AGC preset:" << index;
}
}
void DockRxOpt::on_agcHangButton_toggled(bool checked)
void DockRxOpt::agcOpt_hangToggled(bool checked)
{
qDebug() << "AGC hang" << (checked ? "ON" : "OFF");
emit agcHangToggled(checked);
}
/*! \brief AGC threshold ("knee") changed.
* \param value The new AGC threshold in dB.
*/
void DockRxOpt::on_agcThresholdDial_valueChanged(int value)
void DockRxOpt::agcOpt_thresholdChanged(int value)
{
qDebug() << "AGC threshold:" << value;
emit agcThresholdChanged(value);
@ -311,16 +286,16 @@ void DockRxOpt::on_agcThresholdDial_valueChanged(int value)
/*! \brief AGC slope factor changed.
* \param value The new slope factor in dB.
*/
void DockRxOpt::on_agcSlopeDial_valueChanged(int value)
void DockRxOpt::agcOpt_slopeChanged(int value)
{
qDebug() << "AGC slope:" << value;
emit agcSlopeChanged(value);
}
/*! \brief AGC decay changed.
* \param value The new slope factor in dB.
* \param value The new decay rate in ms (tbc).
*/
void DockRxOpt::on_agcDecayDial_valueChanged(int value)
void DockRxOpt::agcOpt_decayChanged(int value)
{
qDebug() << "AGC decay:" << value;
emit agcDecayChanged(value);
@ -329,7 +304,7 @@ void DockRxOpt::on_agcDecayDial_valueChanged(int value)
/*! \brief AGC manual gain changed.
* \param gain The new gain in dB.
*/
void DockRxOpt::on_agcGainDial_valueChanged(int gain)
void DockRxOpt::agcOpt_gainChanged(int gain)
{
qDebug() << "AGC manual gain:" << gain;
emit agcGainChanged(gain);

View File

@ -21,6 +21,7 @@
#define DOCKRXOPT_H
#include <QDockWidget>
#include "qtgui/agc_options.h"
#include "qtgui/demod-options.h"
@ -96,7 +97,7 @@ signals:
void amDcrToggled(bool enabled);
/*! \brief Signal emitted when baseband gain has changed. Gain is in dB. */
void bbGainChanged(float gain);
//void bbGainChanged(float gain);
/*! \brief Signal emitted when squelch level has changed. Level is in dBFS. */
void sqlLevelChanged(double level);
@ -129,12 +130,8 @@ private slots:
void on_filterButton_clicked();
void on_modeSelector_activated(int index);
void on_modeButton_clicked();
void on_agcButton_clicked();
void on_agcPresetCombo_activated(int index);
void on_agcHangButton_toggled(bool checked);
void on_agcGainDial_valueChanged(int value);
void on_agcThresholdDial_valueChanged(int value);
void on_agcSlopeDial_valueChanged(int value);
void on_agcDecayDial_valueChanged(int value);
void on_sqlSlider_valueChanged(int value);
void on_nb1Button_toggled(bool checked);
void on_nb2Button_toggled(bool checked);
@ -145,9 +142,17 @@ private slots:
void demodOpt_fmMaxdevSelected(float max_dev);
void demodOpt_fmEmphSelected(double tau);
/* Signals coming from AGC options popup */
void agcOpt_hangToggled(bool checked);
void agcOpt_gainChanged(int value);
void agcOpt_thresholdChanged(int value);
void agcOpt_slopeChanged(int value);
void agcOpt_decayChanged(int value);
private:
Ui::DockRxOpt *ui; /*! The Qt designer UI file. */
CDemodOptions *demodOpt; /*! Demodulator options. */
CAgcOptions *agcOpt; /*! AGC options. */
bool agc_is_on;

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>224</width>
<height>383</height>
<width>230</width>
<height>352</height>
</rect>
</property>
<property name="sizePolicy">
@ -18,13 +18,13 @@
</property>
<property name="minimumSize">
<size>
<width>224</width>
<height>383</height>
<width>230</width>
<height>350</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>400</width>
<width>524287</width>
<height>524287</height>
</size>
</property>
@ -105,12 +105,9 @@ as rf_freq + filter_offset</string>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<property name="horizontalSpacing">
<property name="spacing">
<number>5</number>
</property>
<property name="verticalSpacing">
<number>2</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="filterLabel">
<property name="text">
@ -126,6 +123,12 @@ as rf_freq + filter_offset</string>
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Apply mode dependent filter preset</string>
</property>
@ -224,6 +227,12 @@ as rf_freq + filter_offset</string>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="modeSelector">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Demodulator type (mode)</string>
</property>
@ -341,7 +350,7 @@ as rf_freq + filter_offset</string>
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -377,7 +386,7 @@ as rf_freq + filter_offset</string>
</widget>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="agcHangButton">
<widget class="QPushButton" name="agcButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
@ -396,13 +405,17 @@ as rf_freq + filter_offset</string>
</font>
</property>
<property name="toolTip">
<string>Enable/disable AGC hang.</string>
<string>AGC options</string>
</property>
<property name="text">
<string>H</string>
<string/>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/icons/settings.svg</normaloff>:/icons/icons/settings.svg</iconset>
</property>
<property name="checkable">
<bool>true</bool>
<bool>false</bool>
</property>
<property name="checked">
<bool>false</bool>
@ -411,146 +424,6 @@ as rf_freq + filter_offset</string>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="spacing">
<number>2</number>
</property>
<item>
<widget class="QDial" name="agcGainDial">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="toolTip">
<string>Manual gain. Used when AGC is switched off.</string>
</property>
<property name="maximum">
<number>100</number>
</property>
</widget>
</item>
<item>
<widget class="QDial" name="agcThresholdDial">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="toolTip">
<string>AGC threshold (aka. &quot;knee&quot;)</string>
</property>
<property name="minimum">
<number>-160</number>
</property>
<property name="maximum">
<number>0</number>
</property>
<property name="value">
<number>-100</number>
</property>
</widget>
</item>
<item>
<widget class="QDial" name="agcSlopeDial">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="toolTip">
<string>AGC slope</string>
</property>
<property name="maximum">
<number>10</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>2</number>
</property>
</widget>
</item>
<item>
<widget class="QDial" name="agcDecayDial">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="toolTip">
<string>AGC decay time</string>
</property>
<property name="minimum">
<number>50</number>
</property>
<property name="maximum">
<number>5000</number>
</property>
<property name="singleStep">
<number>50</number>
</property>
<property name="pageStep">
<number>50</number>
</property>
<property name="value">
<number>100</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="hline2">
<property name="orientation">