summaryrefslogtreecommitdiff
path: root/gr-qtgui/apps
diff options
context:
space:
mode:
Diffstat (limited to 'gr-qtgui/apps')
-rw-r--r--gr-qtgui/apps/Makefile.am6
-rwxr-xr-xgr-qtgui/apps/pyqt_example_c.py176
-rwxr-xr-xgr-qtgui/apps/pyqt_example_f.py178
-rwxr-xr-xgr-qtgui/apps/pyqt_time_c.py189
-rwxr-xr-xgr-qtgui/apps/pyqt_time_f.py189
-rwxr-xr-xgr-qtgui/apps/uhd_display.py (renamed from gr-qtgui/apps/usrp2_display.py)81
-rwxr-xr-xgr-qtgui/apps/usrp_display.py299
7 files changed, 44 insertions, 1074 deletions
diff --git a/gr-qtgui/apps/Makefile.am b/gr-qtgui/apps/Makefile.am
index 7b35d949e..4d0c550a1 100644
--- a/gr-qtgui/apps/Makefile.am
+++ b/gr-qtgui/apps/Makefile.am
@@ -28,13 +28,9 @@ nodist_bin_SCRIPTS = \
usrp_display_qtgui.ui
noinst_PYTHON = \
- pyqt_example_f.py \
- pyqt_example_c.py \
- pyqt_time_c.py \
qt_digital.py \
qt_digital_window.py \
- usrp2_display.py \
- usrp_display.py \
+ uhd_display.py \
qt_digital_window.py \
usrp_display_qtgui.py
diff --git a/gr-qtgui/apps/pyqt_example_c.py b/gr-qtgui/apps/pyqt_example_c.py
deleted file mode 100755
index 553d346c9..000000000
--- a/gr-qtgui/apps/pyqt_example_c.py
+++ /dev/null
@@ -1,176 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2011 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-from gnuradio import gr
-import sys
-
-try:
- from gnuradio import qtgui
- from PyQt4 import QtGui, QtCore
- import sip
-except ImportError:
- print "Error: Program requires PyQt4 and gr-qtgui."
- sys.exit(1)
-
-class dialog_box(QtGui.QWidget):
- def __init__(self, display, control):
- QtGui.QWidget.__init__(self, None)
- self.setWindowTitle('PyQt Test GUI')
-
- self.boxlayout = QtGui.QBoxLayout(QtGui.QBoxLayout.LeftToRight, self)
- self.boxlayout.addWidget(display, 1)
- self.boxlayout.addWidget(control)
-
- self.resize(800, 500)
-
-class control_box(QtGui.QWidget):
- def __init__(self, parent=None):
- QtGui.QWidget.__init__(self, parent)
- self.setWindowTitle('Control Panel')
-
- self.setToolTip('Control the signals')
- QtGui.QToolTip.setFont(QtGui.QFont('OldEnglish', 10))
-
- self.layout = QtGui.QFormLayout(self)
-
- # Control the first signal
- self.freq1Edit = QtGui.QLineEdit(self)
- self.freq1Edit.setMinimumWidth(100)
- self.layout.addRow("Signal 1 Frequency:", self.freq1Edit)
- self.connect(self.freq1Edit, QtCore.SIGNAL("editingFinished()"),
- self.freq1EditText)
-
- self.amp1Edit = QtGui.QLineEdit(self)
- self.amp1Edit.setMinimumWidth(100)
- self.layout.addRow("Signal 1 Amplitude:", self.amp1Edit)
- self.connect(self.amp1Edit, QtCore.SIGNAL("editingFinished()"),
- self.amp1EditText)
-
-
- # Control the second signal
- self.freq2Edit = QtGui.QLineEdit(self)
- self.freq2Edit.setMinimumWidth(100)
- self.layout.addRow("Signal 2 Frequency:", self.freq2Edit)
- self.connect(self.freq2Edit, QtCore.SIGNAL("editingFinished()"),
- self.freq2EditText)
-
-
- self.amp2Edit = QtGui.QLineEdit(self)
- self.amp2Edit.setMinimumWidth(100)
- self.layout.addRow("Signal 2 Amplitude:", self.amp2Edit)
- self.connect(self.amp2Edit, QtCore.SIGNAL("editingFinished()"),
- self.amp2EditText)
-
- self.quit = QtGui.QPushButton('Close', self)
- self.quit.setMinimumWidth(100)
- self.layout.addWidget(self.quit)
-
- self.connect(self.quit, QtCore.SIGNAL('clicked()'),
- QtGui.qApp, QtCore.SLOT('quit()'))
-
- def attach_signal1(self, signal):
- self.signal1 = signal
- self.freq1Edit.setText(QtCore.QString("%1").arg(self.signal1.frequency()))
- self.amp1Edit.setText(QtCore.QString("%1").arg(self.signal1.amplitude()))
-
- def attach_signal2(self, signal):
- self.signal2 = signal
- self.freq2Edit.setText(QtCore.QString("%1").arg(self.signal2.frequency()))
- self.amp2Edit.setText(QtCore.QString("%1").arg(self.signal2.amplitude()))
-
- def freq1EditText(self):
- try:
- newfreq = float(self.freq1Edit.text())
- self.signal1.set_frequency(newfreq)
- except ValueError:
- print "Bad frequency value entered"
-
- def amp1EditText(self):
- try:
- newamp = float(self.amp1Edit.text())
- self.signal1.set_amplitude(newamp)
- except ValueError:
- print "Bad amplitude value entered"
-
-
- def freq2EditText(self):
- try:
- newfreq = float(self.freq2Edit.text())
- self.signal2.set_frequency(newfreq)
- except ValueError:
- print "Bad frequency value entered"
-
- def amp2EditText(self):
- try:
- newamp = float(self.amp2Edit.text())
- self.signal2.set_amplitude(newamp)
- except ValueError:
- print "Bad amplitude value entered"
-
-
-class my_top_block(gr.top_block):
- def __init__(self):
- gr.top_block.__init__(self)
-
- Rs = 8000
- f1 = 1000
- f2 = 2000
-
- fftsize = 2048
-
- self.qapp = QtGui.QApplication(sys.argv)
-
- src1 = gr.sig_source_c(Rs, gr.GR_SIN_WAVE, f1, 0.1, 0)
- src2 = gr.sig_source_c(Rs, gr.GR_SIN_WAVE, f2, 0.1, 0)
- src = gr.add_cc()
- channel = gr.channel_model(0.001)
- thr = gr.throttle(gr.sizeof_gr_complex, 100*fftsize)
- self.snk1 = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS,
- 0, Rs,
- "Complex Signal Example",
- True, True, True, False)
-
- self.connect(src1, (src,0))
- self.connect(src2, (src,1))
- self.connect(src, channel, thr, self.snk1)
-
- self.ctrl_win = control_box()
- self.ctrl_win.attach_signal1(src1)
- self.ctrl_win.attach_signal2(src2)
-
- # Get the reference pointer to the SpectrumDisplayForm QWidget
- pyQt = self.snk1.pyqwidget()
-
- # Wrap the pointer as a PyQt SIP object
- # This can now be manipulated as a PyQt4.QtGui.QWidget
- pyWin = sip.wrapinstance(pyQt, QtGui.QWidget)
-
- self.main_box = dialog_box(pyWin, self.ctrl_win)
-
- self.main_box.show()
-
-if __name__ == "__main__":
- tb = my_top_block();
- tb.start()
- tb.qapp.exec_()
- tb.stop()
-
diff --git a/gr-qtgui/apps/pyqt_example_f.py b/gr-qtgui/apps/pyqt_example_f.py
deleted file mode 100755
index 5e432fe78..000000000
--- a/gr-qtgui/apps/pyqt_example_f.py
+++ /dev/null
@@ -1,178 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2011 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-from gnuradio import gr
-import sys
-
-try:
- from gnuradio import qtgui
- from PyQt4 import QtGui, QtCore
- import sip
-except ImportError:
- print "Error: Program requires PyQt4 and gr-qtgui."
- sys.exit(1)
-
-class dialog_box(QtGui.QWidget):
- def __init__(self, display, control):
- QtGui.QWidget.__init__(self, None)
- self.setWindowTitle('PyQt Test GUI')
-
- self.boxlayout = QtGui.QBoxLayout(QtGui.QBoxLayout.LeftToRight, self)
- self.boxlayout.addWidget(display, 1)
- self.boxlayout.addWidget(control)
-
- self.resize(800, 500)
-
-class control_box(QtGui.QWidget):
- def __init__(self, parent=None):
- QtGui.QWidget.__init__(self, parent)
- self.setWindowTitle('Control Panel')
-
- self.setToolTip('Control the signals')
- QtGui.QToolTip.setFont(QtGui.QFont('OldEnglish', 10))
-
- self.layout = QtGui.QFormLayout(self)
-
- # Control the first signal
- self.freq1Edit = QtGui.QLineEdit(self)
- self.freq1Edit.setMinimumWidth(100)
- self.layout.addRow("Signal 1 Frequency:", self.freq1Edit)
- self.connect(self.freq1Edit, QtCore.SIGNAL("editingFinished()"),
- self.freq1EditText)
-
- self.amp1Edit = QtGui.QLineEdit(self)
- self.amp1Edit.setMinimumWidth(100)
- self.layout.addRow("Signal 1 Amplitude:", self.amp1Edit)
- self.connect(self.amp1Edit, QtCore.SIGNAL("editingFinished()"),
- self.amp1EditText)
-
-
- # Control the second signal
- self.freq2Edit = QtGui.QLineEdit(self)
- self.freq2Edit.setMinimumWidth(100)
- self.layout.addRow("Signal 2 Frequency:", self.freq2Edit)
- self.connect(self.freq2Edit, QtCore.SIGNAL("editingFinished()"),
- self.freq2EditText)
-
-
- self.amp2Edit = QtGui.QLineEdit(self)
- self.amp2Edit.setMinimumWidth(100)
- self.layout.addRow("Signal 2 Amplitude:", self.amp2Edit)
- self.connect(self.amp2Edit, QtCore.SIGNAL("editingFinished()"),
- self.amp2EditText)
-
- self.quit = QtGui.QPushButton('Close', self)
- self.quit.setMinimumWidth(100)
- self.layout.addWidget(self.quit)
-
- self.connect(self.quit, QtCore.SIGNAL('clicked()'),
- QtGui.qApp, QtCore.SLOT('quit()'))
-
- def attach_signal1(self, signal):
- self.signal1 = signal
- self.freq1Edit.setText(QtCore.QString("%1").arg(self.signal1.frequency()))
- self.amp1Edit.setText(QtCore.QString("%1").arg(self.signal1.amplitude()))
-
- def attach_signal2(self, signal):
- self.signal2 = signal
- self.freq2Edit.setText(QtCore.QString("%1").arg(self.signal2.frequency()))
- self.amp2Edit.setText(QtCore.QString("%1").arg(self.signal2.amplitude()))
-
- def freq1EditText(self):
- try:
- newfreq = float(self.freq1Edit.text())
- self.signal1.set_frequency(newfreq)
- except ValueError:
- print "Bad frequency value entered"
-
- def amp1EditText(self):
- try:
- newamp = float(self.amp1Edit.text())
- self.signal1.set_amplitude(newamp)
- except ValueError:
- print "Bad amplitude value entered"
-
-
- def freq2EditText(self):
- try:
- newfreq = float(self.freq2Edit.text())
- self.signal2.set_frequency(newfreq)
- except ValueError:
- print "Bad frequency value entered"
-
- def amp2EditText(self):
- try:
- newamp = float(self.amp2Edit.text())
- self.signal2.set_amplitude(newamp)
- except ValueError:
- print "Bad amplitude value entered"
-
-
-class my_top_block(gr.top_block):
- def __init__(self):
- gr.top_block.__init__(self)
-
- Rs = 8000
- f1 = 1000
- f2 = 2000
-
- fftsize = 2048
-
- self.qapp = QtGui.QApplication(sys.argv)
-
- src1 = gr.sig_source_f(Rs, gr.GR_SIN_WAVE, f1, 0.1, 0)
- src2 = gr.sig_source_f(Rs, gr.GR_SIN_WAVE, f2, 0.1, 0)
- src = gr.add_ff()
- thr = gr.throttle(gr.sizeof_float, 100*fftsize)
- noise = gr.noise_source_f(gr.GR_GAUSSIAN, 0.001)
- add = gr.add_ff()
- self.snk1 = qtgui.sink_f(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS,
- 0, Rs,
- "Float Signal Example",
- True, True, True, False)
-
- self.connect(src1, (src,0))
- self.connect(src2, (src,1))
- self.connect(src, thr, (add,0))
- self.connect(noise, (add,1))
- self.connect(add, self.snk1)
-
- self.ctrl_win = control_box()
- self.ctrl_win.attach_signal1(src1)
- self.ctrl_win.attach_signal2(src2)
-
- # Get the reference pointer to the SpectrumDisplayForm QWidget
- pyQt = self.snk1.pyqwidget()
-
- # Wrap the pointer as a PyQt SIP object
- # This can now be manipulated as a PyQt4.QtGui.QWidget
- pyWin = sip.wrapinstance(pyQt, QtGui.QWidget)
-
- self.main_box = dialog_box(pyWin, self.ctrl_win)
-
- self.main_box.show()
-
-if __name__ == "__main__":
- tb = my_top_block();
- tb.start()
- tb.qapp.exec_()
- tb.stop()
diff --git a/gr-qtgui/apps/pyqt_time_c.py b/gr-qtgui/apps/pyqt_time_c.py
deleted file mode 100755
index a47302d19..000000000
--- a/gr-qtgui/apps/pyqt_time_c.py
+++ /dev/null
@@ -1,189 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2011 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-from gnuradio import gr
-import sys
-
-try:
- from gnuradio import qtgui
- from PyQt4 import QtGui, QtCore
- import sip
-except ImportError:
- print "Error: Program requires PyQt4 and gr-qtgui."
- sys.exit(1)
-
-class dialog_box(QtGui.QWidget):
- def __init__(self, display, control):
- QtGui.QWidget.__init__(self, None)
- self.setWindowTitle('PyQt Test GUI')
-
- self.boxlayout = QtGui.QBoxLayout(QtGui.QBoxLayout.LeftToRight, self)
- self.boxlayout.addWidget(display, 1)
- self.boxlayout.addWidget(control)
-
- self.resize(800, 500)
-
-class control_box(QtGui.QWidget):
- def __init__(self, parent=None):
- QtGui.QWidget.__init__(self, parent)
- self.setWindowTitle('Control Panel')
-
- self.setToolTip('Control the signals')
- QtGui.QToolTip.setFont(QtGui.QFont('OldEnglish', 10))
-
- self.layout = QtGui.QFormLayout(self)
-
- # Control the first signal
- self.freq1Edit = QtGui.QLineEdit(self)
- self.freq1Edit.setMinimumWidth(100)
- self.layout.addRow("Signal 1 Frequency:", self.freq1Edit)
- self.connect(self.freq1Edit, QtCore.SIGNAL("editingFinished()"),
- self.freq1EditText)
-
- self.amp1Edit = QtGui.QLineEdit(self)
- self.amp1Edit.setMinimumWidth(100)
- self.layout.addRow("Signal 1 Amplitude:", self.amp1Edit)
- self.connect(self.amp1Edit, QtCore.SIGNAL("editingFinished()"),
- self.amp1EditText)
-
-
- # Control the second signal
- self.freq2Edit = QtGui.QLineEdit(self)
- self.freq2Edit.setMinimumWidth(100)
- self.layout.addRow("Signal 2 Frequency:", self.freq2Edit)
- self.connect(self.freq2Edit, QtCore.SIGNAL("editingFinished()"),
- self.freq2EditText)
-
-
- self.amp2Edit = QtGui.QLineEdit(self)
- self.amp2Edit.setMinimumWidth(100)
- self.layout.addRow("Signal 2 Amplitude:", self.amp2Edit)
- self.connect(self.amp2Edit, QtCore.SIGNAL("editingFinished()"),
- self.amp2EditText)
-
- self.quit = QtGui.QPushButton('Close', self)
- self.quit.setMinimumWidth(100)
- self.layout.addWidget(self.quit)
-
- self.connect(self.quit, QtCore.SIGNAL('clicked()'),
- QtGui.qApp, QtCore.SLOT('quit()'))
-
- def attach_signal1(self, signal):
- self.signal1 = signal
- self.freq1Edit.setText(QtCore.QString("%1").arg(self.signal1.frequency()))
- self.amp1Edit.setText(QtCore.QString("%1").arg(self.signal1.amplitude()))
-
- def attach_signal2(self, signal):
- self.signal2 = signal
- self.freq2Edit.setText(QtCore.QString("%1").arg(self.signal2.frequency()))
- self.amp2Edit.setText(QtCore.QString("%1").arg(self.signal2.amplitude()))
-
- def freq1EditText(self):
- try:
- newfreq = float(self.freq1Edit.text())
- self.signal1.set_frequency(newfreq)
- except ValueError:
- print "Bad frequency value entered"
-
- def amp1EditText(self):
- try:
- newamp = float(self.amp1Edit.text())
- self.signal1.set_amplitude(newamp)
- except ValueError:
- print "Bad amplitude value entered"
-
-
- def freq2EditText(self):
- try:
- newfreq = float(self.freq2Edit.text())
- self.signal2.set_frequency(newfreq)
- except ValueError:
- print "Bad frequency value entered"
-
- def amp2EditText(self):
- try:
- newamp = float(self.amp2Edit.text())
- self.signal2.set_amplitude(newamp)
- except ValueError:
- print "Bad amplitude value entered"
-
-
-class my_top_block(gr.top_block):
- def __init__(self):
- gr.top_block.__init__(self)
-
- Rs = 8000
- f1 = 100
- f2 = 200
-
- npts = 2048
-
- self.qapp = QtGui.QApplication(sys.argv)
-
- src1 = gr.sig_source_c(Rs, gr.GR_SIN_WAVE, f1, 0.1, 0)
- src2 = gr.sig_source_c(Rs, gr.GR_SIN_WAVE, f2, 0.1, 0)
- src = gr.add_cc()
- channel = gr.channel_model(0.01)
- thr = gr.throttle(gr.sizeof_gr_complex, 100*npts)
- self.snk1 = qtgui.time_sink_c(npts, Rs,
- "Complex Time Example", 3)
-
- self.connect(src1, (src,0))
- self.connect(src2, (src,1))
- self.connect(src, channel, thr, (self.snk1, 0))
- self.connect(src1, (self.snk1, 1))
- self.connect(src2, (self.snk1, 2))
-
- self.ctrl_win = control_box()
- self.ctrl_win.attach_signal1(src1)
- self.ctrl_win.attach_signal2(src2)
-
- # Get the reference pointer to the SpectrumDisplayForm QWidget
- pyQt = self.snk1.pyqwidget()
-
- # Wrap the pointer as a PyQt SIP object
- # This can now be manipulated as a PyQt4.QtGui.QWidget
- pyWin = sip.wrapinstance(pyQt, QtGui.QWidget)
-
- # Example of using signal/slot to set the title of a curve
- pyWin.connect(pyWin, QtCore.SIGNAL("setTitle(int, QString)"),
- pyWin, QtCore.SLOT("setTitle(int, QString)"))
- pyWin.emit(QtCore.SIGNAL("setTitle(int, QString)"), 0, "Re{sum}")
- self.snk1.set_title(1, "Im{Sum}")
- self.snk1.set_title(2, "Re{src1}")
- self.snk1.set_title(3, "Im{src1}")
- self.snk1.set_title(4, "Re{src2}")
- self.snk1.set_title(5, "Im{src2}")
-
- # Can also set the color of a curve
- #self.snk1.set_color(5, "blue")
-
- #pyWin.show()
- self.main_box = dialog_box(pyWin, self.ctrl_win)
- self.main_box.show()
-
-if __name__ == "__main__":
- tb = my_top_block();
- tb.start()
- tb.qapp.exec_()
- tb.stop()
-
diff --git a/gr-qtgui/apps/pyqt_time_f.py b/gr-qtgui/apps/pyqt_time_f.py
deleted file mode 100755
index 835b42a75..000000000
--- a/gr-qtgui/apps/pyqt_time_f.py
+++ /dev/null
@@ -1,189 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2011 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-from gnuradio import gr
-import sys
-
-try:
- from gnuradio import qtgui
- from PyQt4 import QtGui, QtCore
- import sip
-except ImportError:
- print "Error: Program requires PyQt4 and gr-qtgui."
- sys.exit(1)
-
-class dialog_box(QtGui.QWidget):
- def __init__(self, display, control):
- QtGui.QWidget.__init__(self, None)
- self.setWindowTitle('PyQt Test GUI')
-
- self.boxlayout = QtGui.QBoxLayout(QtGui.QBoxLayout.LeftToRight, self)
- self.boxlayout.addWidget(display, 1)
- self.boxlayout.addWidget(control)
-
- self.resize(800, 500)
-
-class control_box(QtGui.QWidget):
- def __init__(self, parent=None):
- QtGui.QWidget.__init__(self, parent)
- self.setWindowTitle('Control Panel')
-
- self.setToolTip('Control the signals')
- QtGui.QToolTip.setFont(QtGui.QFont('OldEnglish', 10))
-
- self.layout = QtGui.QFormLayout(self)
-
- # Control the first signal
- self.freq1Edit = QtGui.QLineEdit(self)
- self.freq1Edit.setMinimumWidth(100)
- self.layout.addRow("Signal 1 Frequency:", self.freq1Edit)
- self.connect(self.freq1Edit, QtCore.SIGNAL("editingFinished()"),
- self.freq1EditText)
-
- self.amp1Edit = QtGui.QLineEdit(self)
- self.amp1Edit.setMinimumWidth(100)
- self.layout.addRow("Signal 1 Amplitude:", self.amp1Edit)
- self.connect(self.amp1Edit, QtCore.SIGNAL("editingFinished()"),
- self.amp1EditText)
-
-
- # Control the second signal
- self.freq2Edit = QtGui.QLineEdit(self)
- self.freq2Edit.setMinimumWidth(100)
- self.layout.addRow("Signal 2 Frequency:", self.freq2Edit)
- self.connect(self.freq2Edit, QtCore.SIGNAL("editingFinished()"),
- self.freq2EditText)
-
-
- self.amp2Edit = QtGui.QLineEdit(self)
- self.amp2Edit.setMinimumWidth(100)
- self.layout.addRow("Signal 2 Amplitude:", self.amp2Edit)
- self.connect(self.amp2Edit, QtCore.SIGNAL("editingFinished()"),
- self.amp2EditText)
-
- self.quit = QtGui.QPushButton('Close', self)
- self.quit.setMinimumWidth(100)
- self.layout.addWidget(self.quit)
-
- self.connect(self.quit, QtCore.SIGNAL('clicked()'),
- QtGui.qApp, QtCore.SLOT('quit()'))
-
- def attach_signal1(self, signal):
- self.signal1 = signal
- self.freq1Edit.setText(QtCore.QString("%1").arg(self.signal1.frequency()))
- self.amp1Edit.setText(QtCore.QString("%1").arg(self.signal1.amplitude()))
-
- def attach_signal2(self, signal):
- self.signal2 = signal
- self.freq2Edit.setText(QtCore.QString("%1").arg(self.signal2.frequency()))
- self.amp2Edit.setText(QtCore.QString("%1").arg(self.signal2.amplitude()))
-
- def freq1EditText(self):
- try:
- newfreq = float(self.freq1Edit.text())
- self.signal1.set_frequency(newfreq)
- except ValueError:
- print "Bad frequency value entered"
-
- def amp1EditText(self):
- try:
- newamp = float(self.amp1Edit.text())
- self.signal1.set_amplitude(newamp)
- except ValueError:
- print "Bad amplitude value entered"
-
-
- def freq2EditText(self):
- try:
- newfreq = float(self.freq2Edit.text())
- self.signal2.set_frequency(newfreq)
- except ValueError:
- print "Bad frequency value entered"
-
- def amp2EditText(self):
- try:
- newamp = float(self.amp2Edit.text())
- self.signal2.set_amplitude(newamp)
- except ValueError:
- print "Bad amplitude value entered"
-
-
-class my_top_block(gr.top_block):
- def __init__(self):
- gr.top_block.__init__(self)
-
- Rs = 8000
- f1 = 100
- f2 = 200
-
- npts = 2048
-
- self.qapp = QtGui.QApplication(sys.argv)
-
- src1 = gr.sig_source_f(Rs, gr.GR_SIN_WAVE, f1, 0.1, 0)
- src2 = gr.sig_source_f(Rs, gr.GR_SIN_WAVE, f2, 0.1, 0)
- src = gr.add_ff()
- thr = gr.throttle(gr.sizeof_float, 100*npts)
- noise = gr.noise_source_f(gr.GR_GAUSSIAN, 0.001)
- add = gr.add_ff()
- self.snk1 = qtgui.time_sink_f(npts, Rs,
- "Complex Time Example", 3)
-
- self.connect(src1, (src,0))
- self.connect(src2, (src,1))
- self.connect(src, thr, (add,0))
- self.connect(noise, (add,1))
- self.connect(add, self.snk1)
- self.connect(src1, (self.snk1, 1))
- self.connect(src2, (self.snk1, 2))
-
- self.ctrl_win = control_box()
- self.ctrl_win.attach_signal1(src1)
- self.ctrl_win.attach_signal2(src2)
-
- # Get the reference pointer to the SpectrumDisplayForm QWidget
- pyQt = self.snk1.pyqwidget()
-
- # Wrap the pointer as a PyQt SIP object
- # This can now be manipulated as a PyQt4.QtGui.QWidget
- pyWin = sip.wrapinstance(pyQt, QtGui.QWidget)
-
- # Example of using signal/slot to set the title of a curve
- pyWin.connect(pyWin, QtCore.SIGNAL("setTitle(int, QString)"),
- pyWin, QtCore.SLOT("setTitle(int, QString)"))
- pyWin.emit(QtCore.SIGNAL("setTitle(int, QString)"), 0, "sum")
- self.snk1.set_title(1, "src1")
- self.snk1.set_title(2, "src2")
-
- # Can also set the color of a curve
- #self.snk1.set_color(5, "blue")
-
- #pyWin.show()
- self.main_box = dialog_box(pyWin, self.ctrl_win)
- self.main_box.show()
-
-if __name__ == "__main__":
- tb = my_top_block();
- tb.start()
- tb.qapp.exec_()
- tb.stop()
-
diff --git a/gr-qtgui/apps/usrp2_display.py b/gr-qtgui/apps/uhd_display.py
index 497bcc00e..806914797 100755
--- a/gr-qtgui/apps/usrp2_display.py
+++ b/gr-qtgui/apps/uhd_display.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright 2009 Free Software Foundation, Inc.
+# Copyright 2009,2011 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -21,7 +21,7 @@
#
from gnuradio import gr
-from gnuradio import usrp2
+from gnuradio import uhd
from gnuradio import eng_notation
from gnuradio.eng_option import eng_option
from gnuradio.qtgui import qtgui
@@ -163,53 +163,40 @@ class main_window(QtGui.QMainWindow):
class my_top_block(gr.top_block):
- def __init__(self):
+ def __init__(self, options):
gr.top_block.__init__(self)
- parser = OptionParser(option_class=eng_option)
- parser.add_option("-e", "--interface", type="string", default="eth0",
- help="select Ethernet interface, default is eth0")
- parser.add_option("-m", "--mac-addr", type="string", default="",
- help="select USRP by MAC address, default is auto-select")
- parser.add_option("-W", "--bw", type="eng_float", default=1e6,
- help="set bandwidth of receiver [default=%default]")
- parser.add_option("-f", "--freq", type="eng_float", default=2412e6,
- help="set frequency to FREQ", metavar="FREQ")
- parser.add_option("-g", "--gain", type="eng_float", default=None,
- help="set gain in dB (default is midpoint)")
- parser.add_option("--fft-size", type="int", default=2048,
- help="Set number of FFT bins [default=%default]")
- (options, args) = parser.parse_args()
-
- if len(args) != 0:
- parser.print_help()
- sys.exit(1)
- self.options = options
+ self.options = options
self.show_debug_info = True
self.qapp = QtGui.QApplication(sys.argv)
- self.u = usrp2.source_32fc(options.interface, options.mac_addr)
- self._adc_rate = self.u.adc_rate()
- self.set_bandwidth(options.bw)
+ self.u = uhd.usrp_source(device_addr=options.address,
+ io_type=uhd.io_type.COMPLEX_FLOAT32,
+ num_channels=1)
+ self.set_bandwidth(options.samp_rate)
if options.gain is None:
# if no gain was specified, use the mid-point in dB
- g = self.u.gain_range()
- options.gain = float(g[0]+g[1])/2
+ g = self.u.get_gain_range()
+ options.gain = float(g.start()+g.stop())/2
self.set_gain(options.gain)
if options.freq is None:
- # if no frequency was specified, use the mid-point of the subdev
- f = self.u.freq_range()
- options.freq = float(f[0]+f[1])/2
+ # if no freq was specified, use the mid-point
+ r = self.u.get_freq_range()
+ options.freq = float(r.start()+r.stop())/2
self.set_frequency(options.freq)
+ if(options.antenna):
+ self.u.set_antenna(options.antenna, 0)
+
self._fftsize = options.fft_size
- self.snk = qtgui.sink_c(options.fft_size, gr.firdes.WIN_BLACKMAN_hARRIS,
+ self.snk = qtgui.sink_c(options.fft_size,
+ gr.firdes.WIN_BLACKMAN_hARRIS,
self._freq, self._bandwidth,
- "USRP2 Display",
+ "UHD Display",
True, True, True, False)
# Set up internal amplifier
@@ -225,9 +212,9 @@ class my_top_block(gr.top_block):
self.connect(self.u, self.amp, self.snk)
if self.show_debug_info:
- print "Decimation rate: ", self._decim
- print "Bandwidth: ", self._bandwidth
- print "D'board: ", self.u.daughterboard_id()
+ print "Bandwidth: ", self.u.get_samp_rate()
+ print "Center Freq: ", self.u.get_center_freq()
+ print "Freq Range: ", self.u.get_freq_range()
# Get the reference pointer to the SpectrumDisplayForm QWidget
# Wrap the pointer as a PyQt SIP object
@@ -268,8 +255,7 @@ class my_top_block(gr.top_block):
def set_bandwidth(self, bw):
self._bandwidth = bw
- self._decim = int(self._adc_rate / self._bandwidth)
- self.u.set_decim(self._decim)
+ self.u.set_samp_rate(self._bandwidth)
try:
self.snk.set_frequency_range(self._freq, self._bandwidth)
@@ -301,7 +287,26 @@ class my_top_block(gr.top_block):
self.unlock()
def main ():
- tb = my_top_block()
+ parser = OptionParser(option_class=eng_option)
+ parser.add_option("-a", "--address", type="string", default="addr=192.168.10.2",
+ help="Address of UHD device, [default=%default]")
+ parser.add_option("-A", "--antenna", type="string", default=None,
+ help="select Rx Antenna where appropriate")
+ parser.add_option("-s", "--samp-rate", type="eng_float", default=1e6,
+ help="set sample rate (bandwidth) [default=%default]")
+ parser.add_option("-f", "--freq", type="eng_float", default=2412e6,
+ help="set frequency to FREQ", metavar="FREQ")
+ parser.add_option("-g", "--gain", type="eng_float", default=None,
+ help="set gain in dB (default is midpoint)")
+ parser.add_option("--fft-size", type="int", default=2048,
+ help="Set number of FFT bins [default=%default]")
+ (options, args) = parser.parse_args()
+
+ if len(args) != 0:
+ parser.print_help()
+ sys.exit(1)
+
+ tb = my_top_block(options)
tb.start()
tb.snk.exec_();
diff --git a/gr-qtgui/apps/usrp_display.py b/gr-qtgui/apps/usrp_display.py
deleted file mode 100755
index 888bb6338..000000000
--- a/gr-qtgui/apps/usrp_display.py
+++ /dev/null
@@ -1,299 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright 2009 Free Software Foundation, Inc.
-#
-# This file is part of GNU Radio
-#
-# GNU Radio is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3, or (at your option)
-# any later version.
-#
-# GNU Radio is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU Radio; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 51 Franklin Street,
-# Boston, MA 02110-1301, USA.
-#
-
-from gnuradio import gr
-from gnuradio import usrp
-from gnuradio import eng_notation
-from gnuradio.eng_option import eng_option
-from gnuradio.qtgui import qtgui
-from optparse import OptionParser
-import sys
-
-try:
- from gnuradio.qtgui import qtgui
- from PyQt4 import QtGui, QtCore
- import sip
-except ImportError:
- print "Error: Program requires PyQt4 and gr-qtgui."
- sys.exit(1)
-
-try:
- from usrp_display_qtgui import Ui_MainWindow
-except ImportError:
- print "Error: could not find usrp_display_qtgui.py:"
- print "\t\"pyuic4 usrp_display_qtgui.ui -o usrp_display_qtgui.py\""
- sys.exit(1)
-
-
-
-# ////////////////////////////////////////////////////////////////////
-# Define the QT Interface and Control Dialog
-# ////////////////////////////////////////////////////////////////////
-
-
-class main_window(QtGui.QMainWindow):
- def __init__(self, snk, fg, parent=None):
-
- QtGui.QWidget.__init__(self, parent)
- self.gui = Ui_MainWindow()
- self.gui.setupUi(self)
-
- self.fg = fg
-
- # Add the qtsnk widgets to the layout box
- self.gui.sinkLayout.addWidget(snk)
-
- # Connect up some signals
- self.connect(self.gui.pauseButton, QtCore.SIGNAL("clicked()"),
- self.pauseFg)
- self.connect(self.gui.frequencyEdit, QtCore.SIGNAL("editingFinished()"),
- self.frequencyEditText)
- self.connect(self.gui.gainEdit, QtCore.SIGNAL("editingFinished()"),
- self.gainEditText)
- self.connect(self.gui.bandwidthEdit, QtCore.SIGNAL("editingFinished()"),
- self.bandwidthEditText)
- self.connect(self.gui.amplifierEdit, QtCore.SIGNAL("editingFinished()"),
- self.amplifierEditText)
-
- self.connect(self.gui.actionSaveData, QtCore.SIGNAL("activated()"),
- self.saveData)
- self.gui.actionSaveData.setShortcut(QtGui.QKeySequence.Save)
-
- def pauseFg(self):
- if(self.gui.pauseButton.text() == "Pause"):
- self.fg.stop()
- self.fg.wait()
- self.gui.pauseButton.setText("Unpause")
- else:
- self.fg.start()
- self.gui.pauseButton.setText("Pause")
-
-
- # Functions to set the values in the GUI
- def set_frequency(self, freq):
- self.freq = freq
- sfreq = eng_notation.num_to_str(self.freq)
- self.gui.frequencyEdit.setText(QtCore.QString("%1").arg(sfreq))
-
- def set_gain(self, gain):
- self.gain = gain
- self.gui.gainEdit.setText(QtCore.QString("%1").arg(self.gain))
-
- def set_bandwidth(self, bw):
- self.bw = bw
- sbw = eng_notation.num_to_str(self.bw)
- self.gui.bandwidthEdit.setText(QtCore.QString("%1").arg(sbw))
-
- def set_amplifier(self, amp):
- self.amp = amp
- self.gui.amplifierEdit.setText(QtCore.QString("%1").arg(self.amp))
-
-
- # Functions called when signals are triggered in the GUI
- def frequencyEditText(self):
- try:
- freq = eng_notation.str_to_num(self.gui.frequencyEdit.text().toAscii())
- self.fg.set_frequency(freq)
- self.freq = freq
- except RuntimeError:
- pass
-
- def gainEditText(self):
- try:
- gain = float(self.gui.gainEdit.text())
- self.fg.set_gain(gain)
- self.gain = gain
- except ValueError:
- pass
-
- def bandwidthEditText(self):
- try:
- bw = eng_notation.str_to_num(self.gui.bandwidthEdit.text().toAscii())
- self.fg.set_bandwidth(bw)
- self.bw = bw
- except ValueError:
- pass
-
- def amplifierEditText(self):
- try:
- amp = float(self.gui.amplifierEdit.text())
- self.fg.set_amplifier_gain(amp)
- self.amp = amp
- except ValueError:
- pass
-
- def saveData(self):
- fileName = QtGui.QFileDialog.getSaveFileName(self, "Save data to file", ".");
- if(len(fileName)):
- self.fg.save_to_file(str(fileName))
-
-
-def pick_subdevice(u):
- """
- The user didn't specify a subdevice on the command line.
- If there's a daughterboard on A, select A.
- If there's a daughterboard on B, select B.
- Otherwise, select A.
- """
- if u.db(0, 0).dbid() >= 0: # dbid is < 0 if there's no d'board or a problem
- return (0, 0)
- if u.db(0, 0).dbid() >= 0:
- return (1, 0)
- return (0, 0)
-
-class my_top_block(gr.top_block):
- def __init__(self):
- gr.top_block.__init__(self)
-
- parser = OptionParser(option_class=eng_option)
- parser.add_option("-w", "--which", type="int", default=0,
- help="select which USRP (0, 1, ...) default is %default",
- metavar="NUM")
- parser.add_option("-R", "--rx-subdev-spec", type="subdev", default=None,
- help="select USRP Rx side A or B (default=first one with a daughterboard)")
- parser.add_option("-A", "--antenna", default=None,
- help="select Rx Antenna (only on RFX-series boards)")
- parser.add_option("-W", "--bw", type="float", default=1e6,
- help="set bandwidth of receiver [default=%default]")
- parser.add_option("-f", "--freq", type="eng_float", default=None,
- help="set frequency to FREQ", metavar="FREQ")
- parser.add_option("-g", "--gain", type="eng_float", default=None,
- help="set gain in dB [default is midpoint]")
- parser.add_option("-8", "--width-8", action="store_true", default=False,
- help="Enable 8-bit samples across USB")
- parser.add_option( "--no-hb", action="store_true", default=False,
- help="don't use halfband filter in usrp")
- parser.add_option("-S", "--oscilloscope", action="store_true", default=False,
- help="Enable oscilloscope display")
- parser.add_option("", "--avg-alpha", type="eng_float", default=1e-1,
- help="Set fftsink averaging factor, [default=%default]")
- parser.add_option("", "--ref-scale", type="eng_float", default=13490.0,
- help="Set dBFS=0dB input value, [default=%default]")
- parser.add_option("", "--fft-size", type="int", default=2048,
- help="Set FFT frame size, [default=%default]");
-
- (options, args) = parser.parse_args()
- if len(args) != 0:
- parser.print_help()
- sys.exit(1)
- self.options = options
- self.show_debug_info = True
-
- # Call this before creating the Qt sink
- self.qapp = QtGui.QApplication(sys.argv)
-
- self._fftsize = options.fft_size
-
- self.u = usrp.source_c(which=options.which)
- self._adc_rate = self.u.converter_rate()
- self.set_bandwidth(options.bw)
-
- if options.rx_subdev_spec is None:
- options.rx_subdev_spec = pick_subdevice(self.u)
- self._rx_subdev_spec = options.rx_subdev_spec
- self.u.set_mux(usrp.determine_rx_mux_value(self.u, self._rx_subdev_spec))
- self.subdev = usrp.selected_subdev(self.u, self._rx_subdev_spec)
-
- self._gain_range = self.subdev.gain_range()
- if options.gain is None:
- # if no gain was specified, use the mid-point in dB
- g = self._gain_range
- options.gain = float(g[0]+g[1])/2
- self.set_gain(options.gain)
-
- if options.freq is None:
- # if no frequency was specified, use the mid-point of the subdev
- f = self.subdev.freq_range()
- options.freq = float(f[0]+f[1])/2
- self.set_frequency(options.freq)
-
- self.snk = qtgui.sink_c(self._fftsize, gr.firdes.WIN_BLACKMAN_hARRIS,
- self._freq, self._bandwidth,
- "USRP Display",
- True, True, True, False)
-
- # Set up internal amplifier
- self.amp = gr.multiply_const_cc(0.0)
- self.set_amplifier_gain(0.001)
-
- # Connect the flow graph
- self.connect(self.u, self.amp, self.snk)
-
-
- # Get the reference pointer to the SpectrumDisplayForm QWidget
- # Wrap the pointer as a PyQt SIP object
- # This can now be manipulated as a PyQt4.QtGui.QWidget
- self.pysink = sip.wrapinstance(self.snk.pyqwidget(), QtGui.QWidget)
-
- self.main_win = main_window(self.pysink, self)
-
- self.main_win.set_frequency(self._freq)
- self.main_win.set_gain(self._gain)
- self.main_win.set_bandwidth(self._bandwidth)
- self.main_win.set_amplifier(self._amp_value)
-
- self.main_win.show()
-
- def save_to_file(self, name):
- # Pause the flow graph
- self.stop()
- self.wait()
-
- # Add file sink to save data
- self.file_sink = gr.file_sink(gr.sizeof_gr_complex, name)
- self.connect(self.amp, self.file_sink)
-
- # Restart flow graph
- self.start()
-
- def set_gain(self, gain):
- self._gain = gain
- self.subdev.set_gain(self._gain)
-
- def set_frequency(self, freq):
- self._freq = freq
- self.u.tune(0, self.subdev, self._freq)
-
- try:
- self.snk.set_frequency_range(self._freq, self._bandwidth)
- except:
- pass
-
- def set_bandwidth(self, bw):
- self._bandwidth = bw
- self._decim = int(self._adc_rate / self._bandwidth)
- self.u.set_decim_rate(self._decim)
-
- try:
- self.snk.set_frequency_range(self._freq, self._bandwidth)
- except:
- pass
-
- def set_amplifier_gain(self, amp):
- self._amp_value = amp
- self.amp.set_k(self._amp_value)
-
-
-if __name__ == "__main__":
- tb = my_top_block();
- tb.start()
- tb.qapp.exec_()