mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-12-23 01:55:48 -05:00
Gain settings.
This commit is contained in:
parent
c46e841a48
commit
00ed2c2004
@ -10,7 +10,7 @@ V4LGui::V4LGui(PluginAPI* pluginAPI, QWidget* parent) :
|
||||
m_sampleSource(NULL)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->centerFrequency->setValueRange(7, 20000U, 2200000U);
|
||||
ui->centerFrequency->setValueRange(7, 50000U, 1999000U);
|
||||
connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateHardware()));
|
||||
displaySettings();
|
||||
|
||||
@ -82,37 +82,15 @@ bool V4LGui::deserialize(const QByteArray& data)
|
||||
|
||||
bool V4LGui::handleMessage(Message* message)
|
||||
{
|
||||
if(V4LInput::MsgReportV4L::match(message)) {
|
||||
m_gains = ((V4LInput::MsgReportV4L*)message)->getGains();
|
||||
displaySettings();
|
||||
message->completed();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void V4LGui::displaySettings()
|
||||
{
|
||||
ui->centerFrequency->setValue(m_generalSettings.m_centerFrequency / 1000);
|
||||
if(m_gains.size() > 0) {
|
||||
int dist = abs(m_settings.m_gain - 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) {
|
||||
dist = abs(m_settings.m_gain - 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);
|
||||
} else {
|
||||
ui->gain->setMaximum(0);
|
||||
ui->gain->setEnabled(false);
|
||||
ui->gain->setValue(0);
|
||||
}
|
||||
ui->ifgain->setValue(1);
|
||||
ui->checkBoxL->setChecked(m_settings.m_lna);
|
||||
ui->checkBoxM->setChecked(m_settings.m_mix);
|
||||
}
|
||||
|
||||
void V4LGui::sendSettings()
|
||||
@ -127,12 +105,12 @@ void V4LGui::on_centerFrequency_changed(quint64 value)
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
void V4LGui::on_gain_valueChanged(int value)
|
||||
void V4LGui::on_ifgain_valueChanged(int value)
|
||||
{
|
||||
if(value > (int)m_gains.size())
|
||||
if(value > 8)
|
||||
return;
|
||||
int gain = m_gains[value];
|
||||
ui->gainText->setText(tr("%1.%2").arg(gain / 10).arg(abs(gain % 10)));
|
||||
int gain = value * 6;
|
||||
ui->gainText->setText( tr("%1").arg(gain) );
|
||||
m_settings.m_gain = gain;
|
||||
sendSettings();
|
||||
}
|
||||
@ -143,3 +121,21 @@ void V4LGui::updateHardware()
|
||||
message->submit(m_pluginAPI->getDSPEngineMessageQueue());
|
||||
m_updateTimer.stop();
|
||||
}
|
||||
|
||||
void V4LGui::on_checkBoxL_stateChanged(int state)
|
||||
{
|
||||
if (state == Qt::Checked)
|
||||
m_settings.m_lna = 1;
|
||||
else
|
||||
m_settings.m_lna = 0;
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
void V4LGui::on_checkBoxM_stateChanged(int state)
|
||||
{
|
||||
if (state == Qt::Checked)
|
||||
m_settings.m_mix = 1;
|
||||
else
|
||||
m_settings.m_mix = 0;
|
||||
sendSettings();
|
||||
}
|
||||
|
@ -44,7 +44,9 @@ private:
|
||||
|
||||
private slots:
|
||||
void on_centerFrequency_changed(quint64 value);
|
||||
void on_gain_valueChanged(int value);
|
||||
void on_ifgain_valueChanged(int value);
|
||||
void on_checkBoxL_stateChanged(int state);
|
||||
void on_checkBoxM_stateChanged(int state);
|
||||
void updateHardware();
|
||||
};
|
||||
|
||||
|
@ -107,6 +107,24 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayoutG">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxL">
|
||||
<property name="text">
|
||||
<string>LNA AMP</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxM">
|
||||
<property name="text">
|
||||
<string>Mix AMP</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="spacing">
|
||||
@ -126,18 +144,12 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QSlider" name="gain">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<widget class="QSlider" name="ifgain">
|
||||
<property name="toolTip">
|
||||
<string>LNA amplification</string>
|
||||
<string>IF amplification</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="pageStep">
|
||||
<number>1</number>
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
|
@ -23,16 +23,19 @@
|
||||
#include "util/simpleserializer.h"
|
||||
|
||||
MESSAGE_CLASS_DEFINITION(V4LInput::MsgConfigureV4L, Message)
|
||||
MESSAGE_CLASS_DEFINITION(V4LInput::MsgReportV4L, Message)
|
||||
|
||||
V4LInput::Settings::Settings() :
|
||||
m_gain(6)
|
||||
m_gain(1),
|
||||
m_lna(0),
|
||||
m_mix(0)
|
||||
{
|
||||
}
|
||||
|
||||
void V4LInput::Settings::resetToDefaults()
|
||||
{
|
||||
m_gain = 6;
|
||||
m_gain = 1;
|
||||
m_lna = 0;
|
||||
m_mix = 0;
|
||||
}
|
||||
|
||||
QByteArray V4LInput::Settings::serialize() const
|
||||
@ -53,7 +56,7 @@ bool V4LInput::Settings::deserialize(const QByteArray& data)
|
||||
}
|
||||
|
||||
if(d.getVersion() == 1) {
|
||||
d.readS32(1, &m_gain, 6);
|
||||
d.readS32(1, &m_gain, 1);
|
||||
//d.readS32(2, &m_samplerate, 0);
|
||||
return true;
|
||||
} else {
|
||||
@ -155,13 +158,19 @@ void V4LInput::applySettings(const GeneralSettings& generalSettings, const Setti
|
||||
|
||||
if((m_generalSettings.m_centerFrequency != generalSettings.m_centerFrequency) || force) {
|
||||
m_V4LThread->set_center_freq( (double)generalSettings.m_centerFrequency );
|
||||
m_generalSettings.m_centerFrequency = generalSettings.m_centerFrequency;
|
||||
}
|
||||
m_generalSettings.m_centerFrequency = generalSettings.m_centerFrequency;
|
||||
#if 0
|
||||
|
||||
if((m_settings.m_gain != settings.m_gain) || force) {
|
||||
m_settings.m_gain = settings.m_gain;
|
||||
m_V4LThread->set_tuner_gain((double)m_settings.m_gain);
|
||||
}
|
||||
#endif
|
||||
|
||||
if((m_settings.m_lna != settings.m_lna) || (m_settings.m_mix != settings.m_mix) || force) {
|
||||
m_settings.m_lna = settings.m_lna;
|
||||
m_settings.m_mix = settings.m_mix;
|
||||
m_V4LThread->set_amps(1, m_settings.m_lna);
|
||||
m_V4LThread->set_amps(0, m_settings.m_mix);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ class V4LThread;
|
||||
class V4LInput : public SampleSource {
|
||||
public:
|
||||
struct Settings {
|
||||
qint32 m_gain;
|
||||
qint32 m_gain, m_lna, m_mix;
|
||||
|
||||
Settings();
|
||||
void resetToDefaults();
|
||||
@ -62,26 +62,6 @@ public:
|
||||
{ }
|
||||
};
|
||||
|
||||
class MsgReportV4L : public Message {
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
public:
|
||||
const std::vector<int>& getGains() const { return m_gains; }
|
||||
|
||||
static MsgReportV4L* create(const std::vector<int>& gains)
|
||||
{
|
||||
return new MsgReportV4L(gains);
|
||||
}
|
||||
|
||||
protected:
|
||||
std::vector<int> m_gains;
|
||||
|
||||
MsgReportV4L(const std::vector<int>& gains) :
|
||||
Message(),
|
||||
m_gains(gains)
|
||||
{ }
|
||||
};
|
||||
|
||||
V4LInput(MessageQueue* msgQueueToGUI);
|
||||
~V4LInput();
|
||||
|
||||
@ -98,7 +78,6 @@ private:
|
||||
Settings m_settings;
|
||||
V4LThread* m_V4LThread;
|
||||
QString m_deviceDescription;
|
||||
std::vector<int> m_gains;
|
||||
|
||||
void applySettings(const GeneralSettings& generalSettings, const Settings& settings, bool force);
|
||||
};
|
||||
|
@ -6,9 +6,9 @@
|
||||
#include "v4lgui.h"
|
||||
|
||||
const PluginDescriptor V4LPlugin::m_pluginDescriptor = {
|
||||
QString("V4L Input"),
|
||||
QString("V4L SDRplay Input"),
|
||||
QString("4.0"),
|
||||
QString("(c) 2014 John Greb"),
|
||||
QString("(c) 2015 John Greb"),
|
||||
QString("http://palosaari.fi/linux/"),
|
||||
true,
|
||||
QString("github.com/hexameron/rtl-sdrangelove")
|
||||
|
@ -146,10 +146,7 @@ V4LThread::set_sample_rate(double samp_rate)
|
||||
frequency.tuner = 0;
|
||||
frequency.type = V4L2_TUNER_ADC;
|
||||
frequency.frequency = samp_rate;
|
||||
|
||||
xioctl(fd, VIDIOC_S_FREQUENCY, &frequency);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Cannot change freq while streaming
|
||||
@ -164,10 +161,7 @@ V4LThread::set_center_freq(double freq)
|
||||
frequency.tuner = 1;
|
||||
frequency.type = V4L2_TUNER_RF;
|
||||
frequency.frequency = freq;
|
||||
|
||||
xioctl(fd, VIDIOC_S_FREQUENCY, &frequency);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
@ -196,8 +190,6 @@ V4LThread::set_bandwidth(double bandwidth)
|
||||
ext_ctrls.count = 1;
|
||||
ext_ctrls.controls = &ext_ctrl;
|
||||
xioctl(fd, VIDIOC_S_EXT_CTRLS, &ext_ctrls);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
@ -216,7 +208,29 @@ V4LThread::set_tuner_gain(double gain)
|
||||
ext_ctrls.count = 1;
|
||||
ext_ctrls.controls = &ext_ctrl;
|
||||
xioctl(fd, VIDIOC_S_EXT_CTRLS, &ext_ctrls);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
V4LThread::set_amps(bool lna, bool on)
|
||||
{
|
||||
struct v4l2_ext_controls ext_ctrls;
|
||||
struct v4l2_ext_control ext_ctrl;
|
||||
|
||||
if (fd <= 0)
|
||||
return;
|
||||
|
||||
memset (&ext_ctrl, 0, sizeof(ext_ctrl));
|
||||
memset (&ext_ctrls, 0, sizeof(ext_ctrls));
|
||||
if (lna)
|
||||
ext_ctrl.id = CID_TUNER_LNA_GAIN;
|
||||
else
|
||||
ext_ctrl.id = CID_TUNER_MIXER_GAIN;
|
||||
ext_ctrl.value = on;
|
||||
ext_ctrls.ctrl_class = CID_CLASS_RF;
|
||||
ext_ctrls.count = 1;
|
||||
ext_ctrls.controls = &ext_ctrl;
|
||||
xioctl(fd, VIDIOC_S_EXT_CTRLS, &ext_ctrls);
|
||||
}
|
||||
|
||||
#define CASTUP (int)(qint16)
|
||||
|
@ -43,6 +43,7 @@ public:
|
||||
void set_center_freq(double freq);
|
||||
void set_bandwidth(double bandwidth);
|
||||
void set_tuner_gain(double gain);
|
||||
void set_amps(bool lna, bool on);
|
||||
int work(int n_items);
|
||||
private:
|
||||
int fd;
|
||||
|
Loading…
Reference in New Issue
Block a user