Skip to content

Commit

Permalink
Basic receiver that can actually receive NFM.
Browse files Browse the repository at this point in the history
  • Loading branch information
csete committed May 22, 2011
1 parent aea19fe commit f062d0c
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 13 deletions.
23 changes: 23 additions & 0 deletions mainwindow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
#include <QDebug>
#include "mainwindow.h"
#include "ui_mainwindow.h"

Expand All @@ -25,9 +26,31 @@ MainWindow::MainWindow(QWidget *parent) :
ui(new Ui::MainWindow)
{
ui->setupUi(this);

/* create receiver object */
rx = new receiver("hw:1");

rx->set_rf_freq(144500000.0f);
rx->set_filter_offset(25000.0);
}

MainWindow::~MainWindow()
{
delete ui;
delete rx;
}


void MainWindow::on_rxStartStopButton_toggled(bool checked)
{
if (checked) {
/* start receiver and update button label */
rx->start();
ui->rxStartStopButton->setText(tr("Stop"));
}
else {
/* stop receiver and update label */
rx->stop();
ui->rxStartStopButton->setText(tr("Start"));
}
}
7 changes: 7 additions & 0 deletions mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#define MAINWINDOW_H

#include <QMainWindow>
#include <receiver.h>


namespace Ui {
class MainWindow;
Expand All @@ -36,6 +38,11 @@ class MainWindow : public QMainWindow

private:
Ui::MainWindow *ui;

receiver *rx;

private slots:
void on_rxStartStopButton_toggled(bool checked); /*! RX start/stop button toggled. */
};

#endif // MAINWINDOW_H
55 changes: 44 additions & 11 deletions mainwindow.ui
Original file line number Diff line number Diff line change
@@ -1,24 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow" >
<property name="geometry" >
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
<width>461</width>
<height>309</height>
</rect>
</property>
<property name="windowTitle" >
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QMenuBar" name="menuBar" />
<widget class="QToolBar" name="mainToolBar" />
<widget class="QWidget" name="centralWidget" />
<widget class="QStatusBar" name="statusBar" />
<widget class="QWidget" name="centralWidget">
<widget class="QPushButton" name="rxStartStopButton">
<property name="geometry">
<rect>
<x>20</x>
<y>210</y>
<width>98</width>
<height>27</height>
</rect>
</property>
<property name="text">
<string>Start</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>461</width>
<height>25</height>
</rect>
</property>
</widget>
<widget class="QToolBar" name="mainToolBar">
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
<widget class="QStatusBar" name="statusBar"/>
</widget>
<layoutDefault spacing="6" margin="11" />
<pixmapfunction></pixmapfunction>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>
12 changes: 10 additions & 2 deletions receiver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,22 @@ receiver::receiver(const std::string input_device, const std::string audio_devic
tb = gr_make_top_block("gqrx");

fcd_src = fcd_make_source_c(input_device);
fcd_src->set_freq(144500000.0f);
filter = make_rx_filter(d_bandwidth, 0.0, -5000.0, 5000.0, 1000.0);
demod_fm = make_rx_demod_fm(48000.0, 48000.0, 5000.0, 50.0e-6);

audio_snk = audio_make_sink(d_audio_rate, audio_device, true);

tb->connect(fcd_src, 0, audio_snk, 0);
tb->connect(fcd_src, 0, filter, 0);
tb->connect(filter, 0, demod_fm, 0);
tb->connect(demod_fm, 0, audio_snk, 0);

}

receiver::~receiver()
{
tb->stop();
tb->wait();


/* FIXME: delete blocks? */
}
Expand All @@ -51,11 +56,14 @@ void receiver::start()
void receiver::stop()
{
tb->stop();
tb->wait(); // If the graph is needed to run again, wait() must be called after stop
// FIXME: aUaO
}


receiver::status receiver::set_rf_freq(float freq_hz)
{
fcd_src->set_freq(freq_hz);
return STATUS_OK;
}

Expand Down
4 changes: 4 additions & 0 deletions receiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include <gr_top_block.h>
#include <gr_audio_sink.h>
#include <fcd/fcd_source_c.h>
#include <rx_filter.h>
#include <rx_demod_fm.h>


/*! \defgroup DSP Digital signal processing library based on GNU Radio */
Expand Down Expand Up @@ -126,6 +128,8 @@ class receiver

gr_top_block_sptr tb; /*! The GNU Radio top block. */
fcd_source_c_sptr fcd_src; /*! Funcube Dongle source. */
rx_filter_sptr filter;
rx_demod_fm_sptr demod_fm;

audio_sink::sptr audio_snk; /*! Audio sink. */

Expand Down

0 comments on commit f062d0c

Please sign in to comment.