提交 86388722 编写于 作者: M manjaro

Add channel selection

上级 a0742c64
......@@ -5,7 +5,8 @@
specWidget::specWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::specWidget),
m_runth(new uhd_io_thread(this))
m_runth(new uhd_io_thread(this)),
m_attenMod(new QStandardItemModel(this))
{
ui->setupUi(this);
Bookmarks::create();
......@@ -20,13 +21,15 @@ specWidget::specWidget(QWidget *parent) :
//选择带宽
ui->plotter->setFilterBoxEnabled(true);
//中心频率
//ui->plotter->setCenterFreq(101700000);
//选择频率
//ui->plotter->setDemodCenterFreq(102300000);
ui->plotter->setTooltipsEnabled(true);
ui->plotter->setPeakDetection(false,128.0);
m_attenMod->appendRow(new QStandardItem("TX/RX"));
m_attenMod->appendRow(new QStandardItem("RX2"));
m_attenMod->appendRow(new QStandardItem("RX"));
m_attenMod->appendRow(new QStandardItem("TX"));
ui->comboBox_atn->setModel(m_attenMod);
//连接
//connect (ui->plotter,&CPlotter::newDemodFreq,ui->freqCtrl,&CFreqCtrl::setFrequency);
......@@ -199,8 +202,22 @@ bool specWidget::saveWaterfall(const QString & filename)
void specWidget::on_pushButton_reset_clicked()
{
saveSettings();
loadSettings();
resetFFT();
if (m_runth->isRunning())
{
if (m_nTimerID>=0)
killTimer(m_nTimerID);
if (usrp)
{
close_device();
}
ui->pushButton_reset->setText(tr("Start"));
}
else
{
loadSettings();
resetFFT();
}
}
void specWidget::loadSettings()
......@@ -286,6 +303,8 @@ void specWidget::freeFFT()
}
void specWidget::resetFFT()
{
ui->pushButton_reset->setText(tr("Start"));
m_channel = ui->spinBox_chan->value();
freeFFT();
m_pFFTIn = (fftw_complex *) fftw_malloc(sizeof(fftw_complex) * m_nFFTSize);
m_pFFTOut = (fftw_complex *) fftw_malloc(sizeof(fftw_complex) * m_nFFTSize);
......@@ -312,7 +331,9 @@ void specWidget::resetFFT()
setSampleRate(getSampleRate());
setCenterFreq(ui->plotter->getCenterFreq());
QString atn = ui->comboBox_atn->currentText();
if (atn.size())
usrp->set_rx_antenna(atn.toStdString(),m_channel);
if (m_runth->isRunning())
{
stop_signal_called = true;
......@@ -324,7 +345,7 @@ void specWidget::resetFFT()
});
m_runth->start();
m_nTimerID = startTimer(updateIntelv);
ui->pushButton_reset->setText(tr("Stop"));
}
void specWidget::appendWavComplex(const double (* pWav)[2], const int count, double voltage_ref)
......@@ -390,7 +411,15 @@ void specWidget::timerEvent(QTimerEvent * e)
ui->sMeter->setLevel(m_dFFTAmp[m_nCurrentCenter]);
//ui->sMeter->setSqlLevel(m_dFFTAmp[m_nCurrentCenter]);
}
static int ccct = 0;
if (++ccct % 10==0)
{
if (!m_runth->isRunning())
ui->pushButton_reset->setText(tr("Start"));
else
ui->pushButton_reset->setText(tr("Stop"));
}
}
}
......@@ -437,3 +466,17 @@ void specWidget::on_doubleSpinBox_range_min_valueChanged(double arg1)
{
ui->plotter->setWaterfallRange(ui->doubleSpinBox_range_min->value(),ui->doubleSpinBox_range_max->value());
}
void specWidget::on_comboBox_atn_currentIndexChanged(const QString &arg1)
{
if (arg1.size())
{
if (usrp)
usrp->set_rx_antenna(arg1.toStdString(),m_channel);
}
}
void specWidget::on_spinBox_chan_valueChanged(int arg1)
{
m_channel = arg1;
}
......@@ -103,6 +103,10 @@ private slots:
void on_doubleSpinBox_range_min_valueChanged(double arg1);
void on_comboBox_atn_currentIndexChanged(const QString &arg1);
void on_spinBox_chan_valueChanged(int arg1);
private:
void loadSettings();
void saveSettings();
......@@ -110,6 +114,7 @@ private:
void freeFFT();
private:
Ui::specWidget *ui = nullptr;
QStandardItemModel * m_attenMod = nullptr;
private:
int m_nFFTSize = 16384;
std::vector<double> m_dHammingWnd;
......
......@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>738</width>
<width>787</width>
<height>466</height>
</rect>
</property>
......@@ -33,7 +33,7 @@
<item>
<widget class="QPushButton" name="pushButton_reset">
<property name="text">
<string>Apply</string>
<string>Start</string>
</property>
<property name="icon">
<iconset>
......@@ -241,14 +241,14 @@
<x>0</x>
<y>0</y>
<width>310</width>
<height>380</height>
<height>348</height>
</rect>
</property>
<attribute name="label">
<string>Radio</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_2">
<item row="4" column="1">
<item row="7" column="1">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
......@@ -261,7 +261,26 @@
</property>
</spacer>
</item>
<item row="1" column="1">
<item row="0" column="1">
<widget class="QLineEdit" name="lineEdit_dev"/>
</item>
<item row="4" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBox_spr">
<property name="decimals">
<number>6</number>
</property>
<property name="minimum">
<double>0.000001000000000</double>
</property>
<property name="maximum">
<double>1024.000000000000000</double>
</property>
<property name="value">
<double>10.000000000000000</double>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBox_center">
<property name="decimals">
<number>6</number>
......@@ -277,36 +296,41 @@
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineEdit_dev"/>
<item row="5" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Gain</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QSpinBox" name="spinBox_gain"/>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="spinBox_chan">
<property name="maximum">
<number>1</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Center Freq(Mhz)</string>
<string>Channel</string>
</property>
</widget>
</item>
<item row="2" column="0">
<item row="4" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Sample Rate(Mhz)</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBox_spr">
<property name="decimals">
<number>6</number>
</property>
<property name="minimum">
<double>0.000001000000000</double>
</property>
<property name="maximum">
<double>1024.000000000000000</double>
</property>
<property name="value">
<double>10.000000000000000</double>
<item row="3" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Center Freq(Mhz)</string>
</property>
</widget>
</item>
......@@ -317,15 +341,19 @@
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_5">
<item row="2" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Gain</string>
<string>Antenna</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QSpinBox" name="spinBox_gain"/>
<item row="2" column="1">
<widget class="QComboBox" name="comboBox_atn">
<property name="editable">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
......@@ -493,6 +521,19 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="save">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>310</width>
<height>348</height>
</rect>
</property>
<attribute name="label">
<string>Save</string>
</attribute>
</widget>
</widget>
</item>
</layout>
......
......@@ -108,7 +108,7 @@ void uhd_device::run_IO()
{
//创建流对象实例
uhd::stream_args_t stream_args_rx("sc16", "sc16");
stream_args_rx.channels.push_back(0);
stream_args_rx.channels.push_back(m_channel);
rx_streamer::sptr rx_stream = usrp->get_rx_stream(stream_args_rx);
rx_count = 0;
......
......@@ -3,7 +3,7 @@ QT += core gui network
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11
CONFIG += console
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册