SDRPlay plugin: gain GUI refactoring

pull/27/head
f4exb 2016-11-17 18:35:17 +01:00
rodzic 2e4ee9b13d
commit d25e7b613e
6 zmienionych plików z 165 dodań i 63 usunięć

Wyświetl plik

@ -223,28 +223,30 @@ void SDRPlayGui::displaySettings()
if (m_gains.size() > 0)
{
int dist = abs(m_settings.m_gain - m_gains[0]);
int dist = abs(m_settings.m_tunerGain - m_gains[0]);
int pos = 0;
for (uint i = 1; i < m_gains.size(); i++)
{
if (abs(m_settings.m_gain - m_gains[i]) < dist)
if (abs(m_settings.m_tunerGain - m_gains[i]) < dist)
{
dist = abs(m_settings.m_gain - m_gains[i]);
dist = abs(m_settings.m_tunerGain - m_gains[i]);
pos = i;
}
}
ui->gainText->setText(tr("%1.%2").arg(m_gains[pos] / 10).arg(abs(m_gains[pos] % 10)));
ui->gain->setMaximum(m_gains.size() - 1);
ui->gain->setEnabled(true);
ui->gain->setValue(pos);
QString gainText;
gainText.sprintf("%03d", m_gains[pos]);
ui->gainTunerText->setText(gainText);
ui->gainTuner->setMaximum(m_gains.size() - 1);
ui->gainTuner->setEnabled(true);
ui->gainTuner->setValue(pos);
}
else
{
ui->gain->setMaximum(0);
ui->gain->setEnabled(false);
ui->gain->setValue(0);
ui->gainTuner->setMaximum(0);
ui->gainTuner->setEnabled(false);
ui->gainTuner->setValue(0);
}
}
@ -361,7 +363,12 @@ void SDRPlayGui::on_fcPos_currentIndexChanged(int index)
sendSettings();
}
void SDRPlayGui::on_gain_valueChanged(int value)
void SDRPlayGui::on_gainTunerOn_toggled(bool checked)
{
// TODO
}
void SDRPlayGui::on_gainTuner_valueChanged(int value)
{
if (value > (int)m_gains.size())
{
@ -369,12 +376,34 @@ void SDRPlayGui::on_gain_valueChanged(int value)
}
int gain = m_gains[value];
ui->gainText->setText(tr("%1.%2").arg(gain / 10).arg(abs(gain % 10)));
m_settings.m_gain = gain;
QString gainText;
gainText.sprintf("%03d", gain);
ui->gainTunerText->setText(gainText);
m_settings.m_tunerGain = gain;
sendSettings();
}
void SDRPlayGui::on_gainManualOn_toggled(bool checked)
{
// TODO
}
void SDRPlayGui::on_gainLNA_toggled(bool checked)
{
// TODO
}
void SDRPlayGui::on_gainMixer_toggled(bool checked)
{
// TODO
}
void SDRPlayGui::on_gainBaseband_valueChanged(int value)
{
// TODO
}
void SDRPlayGui::on_startStop_toggled(bool checked)
{
if (checked)

Wyświetl plik

@ -83,7 +83,12 @@ private slots:
void on_ifFrequency_currentIndexChanged(int index);
void on_decim_currentIndexChanged(int index);
void on_fcPos_currentIndexChanged(int index);
void on_gain_valueChanged(int value);
void on_gainTunerOn_toggled(bool checked);
void on_gainTuner_valueChanged(int value);
void on_gainManualOn_toggled(bool checked);
void on_gainLNA_toggled(bool checked);
void on_gainMixer_toggled(bool checked);
void on_gainBaseband_valueChanged(int value);
void on_startStop_toggled(bool checked);
void on_record_toggled(bool checked);
};

Wyświetl plik

@ -35,7 +35,16 @@
<property name="spacing">
<number>3</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
@ -521,47 +530,6 @@
<property name="spacing">
<number>3</number>
</property>
<item row="0" column="1">
<widget class="QSlider" name="gain">
<property name="toolTip">
<string>Tuner gain</string>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>0</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>0</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="gainText">
<property name="minimumSize">
<size>
<width>40</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string/>
</property>
<property name="text">
<string>000</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="gainLabel">
<property name="text">
@ -569,6 +537,106 @@
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QRadioButton" name="gainTunerOn">
<property name="toolTip">
<string>Use global tuner gain</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="7">
<widget class="ButtonSwitch" name="gainLNA">
<property name="toolTip">
<string>LNA toggle</string>
</property>
<property name="text">
<string>LNA</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QDial" name="gainTuner">
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="toolTip">
<string>Tuner gain in step units</string>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item row="0" column="6">
<widget class="QRadioButton" name="gainManualOn">
<property name="toolTip">
<string>Use individual LNA, Mixer and Baseband gains</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="8">
<widget class="ButtonSwitch" name="gainMixer">
<property name="toolTip">
<string>Mixer amplifier toggle</string>
</property>
<property name="text">
<string>MIX</string>
</property>
</widget>
</item>
<item row="0" column="9">
<widget class="QDial" name="gainBaseband">
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="toolTip">
<string>Baseband gain (dB)</string>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QLabel" name="gainTunerText">
<property name="toolTip">
<string>Current tuner gain step unit</string>
</property>
<property name="text">
<string>000</string>
</property>
</widget>
</item>
<item row="0" column="10">
<widget class="QLabel" name="gainBasebandText">
<property name="toolTip">
<string>Baseband amplifier gain in dB</string>
</property>
<property name="text">
<string>00</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="Line" name="line_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
</layout>
</item>
<item>

Wyświetl plik

@ -267,13 +267,13 @@ bool SDRPlayInput::applySettings(const SDRPlaySettings& settings, bool force)
m_deviceAPI->configureCorrections(m_settings.m_dcBlock, m_settings.m_iqCorrection);
}
if ((m_settings.m_gain != settings.m_gain) || force)
if ((m_settings.m_tunerGain != settings.m_tunerGain) || force)
{
m_settings.m_gain = settings.m_gain;
m_settings.m_tunerGain = settings.m_tunerGain;
if(m_dev != 0)
{
int r = mirisdr_set_tuner_gain(m_dev, m_settings.m_gain);
int r = mirisdr_set_tuner_gain(m_dev, m_settings.m_tunerGain);
if (r < 0)
{

Wyświetl plik

@ -27,7 +27,7 @@ SDRPlaySettings::SDRPlaySettings()
void SDRPlaySettings::resetToDefaults()
{
m_centerFrequency = 7040*1000;
m_gain = 0;
m_tunerGain = 0;
m_LOppmTenths = 0;
m_frequencyBandIndex = 0;
m_ifFrequencyIndex = 0;
@ -46,7 +46,7 @@ QByteArray SDRPlaySettings::serialize() const
s.writeS32(1, m_LOppmTenths);
s.writeU32(2, m_frequencyBandIndex);
s.writeU32(3, m_ifFrequencyIndex);
s.writeS32(4, m_gain);
s.writeS32(4, m_tunerGain);
s.writeU32(5, m_bandwidthIndex);
s.writeU32(6, m_devSampleRateIndex);
s.writeU32(7, m_log2Decim);
@ -74,7 +74,7 @@ bool SDRPlaySettings::deserialize(const QByteArray& data)
d.readS32(1, &m_LOppmTenths, 0);
d.readU32(2, &m_frequencyBandIndex, 0);
d.readU32(3, &m_ifFrequencyIndex, 0);
d.readS32(4, &m_gain, 0);
d.readS32(4, &m_tunerGain, 0);
d.readU32(5, &m_bandwidthIndex, 0);
d.readU32(6, &m_devSampleRateIndex, 0);
d.readU32(7, &m_log2Decim, 0);

Wyświetl plik

@ -28,7 +28,7 @@ struct SDRPlaySettings {
} fcPos_t;
uint64_t m_centerFrequency;
qint32 m_gain;
qint32 m_tunerGain;
int32_t m_LOppmTenths;
uint32_t m_frequencyBandIndex;
uint32_t m_ifFrequencyIndex;