Blame view
redpitaya/client/dds_gnuradio.py
5.35 KB
ed4b2fee6 minor fixes |
1 2 3 4 |
#!/usr/bin/env python2 # -*- coding: utf-8 -*- ################################################## # GNU Radio Python Flow Graph |
145da201a - |
5 |
# Title: Dds Gnuradio |
21598fce1 add nco HW config |
6 |
# Generated: Sat Apr 8 10:39:47 2017 |
ed4b2fee6 minor fixes |
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
################################################## if __name__ == '__main__': import ctypes import sys if sys.platform.startswith('linux'): try: x11 = ctypes.cdll.LoadLibrary('libX11.so') x11.XInitThreads() except: print "Warning: failed to XInitThreads()" from PyQt4 import Qt from gnuradio import eng_notation from gnuradio import gr from gnuradio.eng_option import eng_option from gnuradio.filter import firdes from gnuradio.qtgui import Range, RangeWidget from optparse import OptionParser import redpitaya_gnuradio import sys |
145da201a - |
28 |
class dds_gnuradio(gr.top_block, Qt.QWidget): |
ed4b2fee6 minor fixes |
29 30 |
def __init__(self): |
145da201a - |
31 |
gr.top_block.__init__(self, "Dds Gnuradio") |
ed4b2fee6 minor fixes |
32 |
Qt.QWidget.__init__(self) |
145da201a - |
33 |
self.setWindowTitle("Dds Gnuradio") |
ed4b2fee6 minor fixes |
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) |
145da201a - |
49 |
self.settings = Qt.QSettings("GNU Radio", "dds_gnuradio") |
ed4b2fee6 minor fixes |
50 51 52 53 54 |
self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## |
ed4b2fee6 minor fixes |
55 56 57 |
self.port = port = 1001 self.offset_out1 = offset_out1 = 0 self.f_dds = f_dds = 0 |
21598fce1 add nco HW config |
58 |
self.addr = addr = "192.168.0.203" |
ed4b2fee6 minor fixes |
59 60 61 62 63 |
self.a_dds = a_dds = 0 ################################################## # Blocks ################################################## |
145da201a - |
64 |
self._offset_out1_range = Range(-2**13, 2**13-1, 1, 0, 200) |
ed4b2fee6 minor fixes |
65 66 |
self._offset_out1_win = RangeWidget(self._offset_out1_range, self.set_offset_out1, 'Offset DDS', "counter_slider", int) self.top_grid_layout.addWidget(self._offset_out1_win, 2, 0) |
21598fce1 add nco HW config |
67 |
self._f_dds_range = Range(0, 60000000, 1000, 0, 200) |
145da201a - |
68 |
self._f_dds_win = RangeWidget(self._f_dds_range, self.set_f_dds, 'DDS frequency', "counter_slider", float) |
ed4b2fee6 minor fixes |
69 |
self.top_grid_layout.addWidget(self._f_dds_win, 0, 0) |
145da201a - |
70 |
self._a_dds_range = Range(0, 2**13-1, 1, 0, 200) |
ed4b2fee6 minor fixes |
71 72 73 74 75 76 77 78 79 80 |
self._a_dds_win = RangeWidget(self._a_dds_range, self.set_a_dds, 'DDS amplitude', "counter_slider", int) self.top_grid_layout.addWidget(self._a_dds_win, 1, 0) self.nco_counter_send_conf_0 = redpitaya_gnuradio.nco_counter_send_conf( addr=addr, port=port, device='/dev/dds_freq', freq_ref=125000000, freq_dds=f_dds, acc_size=32, offset=0, |
21598fce1 add nco HW config |
81 82 |
pinc_sw=1, poff_sw=1, |
ed4b2fee6 minor fixes |
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
) self.add_const_set_offset_0_0 = redpitaya_gnuradio.add_const_set_offset( addr=addr, port=port, device='/dev/dds_ampl', const=a_dds, ) self.add_const_set_offset_0 = redpitaya_gnuradio.add_const_set_offset( addr=addr, port=port, device='/dev/dds_offset', const=offset_out1, ) def closeEvent(self, event): |
145da201a - |
101 |
self.settings = Qt.QSettings("GNU Radio", "dds_gnuradio") |
ed4b2fee6 minor fixes |
102 103 |
self.settings.setValue("geometry", self.saveGeometry()) event.accept() |
ed4b2fee6 minor fixes |
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
def get_port(self): return self.port def set_port(self, port): self.port = port def get_offset_out1(self): return self.offset_out1 def set_offset_out1(self, offset_out1): self.offset_out1 = offset_out1 self.add_const_set_offset_0.set_const(device='/dev/dds_offset', const=self.offset_out1) def get_f_dds(self): return self.f_dds def set_f_dds(self, f_dds): self.f_dds = f_dds |
21598fce1 add nco HW config |
122 |
self.nco_counter_send_conf_0.set_nco(device='/dev/dds_freq', freq_ref=125000000, freq_dds=self.f_dds, acc_size=32, offset=0, pinc_sw=1, poff_sw=1) |
ed4b2fee6 minor fixes |
123 124 125 126 127 128 129 130 131 132 133 134 135 |
def get_addr(self): return self.addr def set_addr(self, addr): self.addr = addr def get_a_dds(self): return self.a_dds def set_a_dds(self, a_dds): self.a_dds = a_dds self.add_const_set_offset_0_0.set_const(device='/dev/dds_ampl', const=self.a_dds) |
145da201a - |
136 |
def main(top_block_cls=dds_gnuradio, options=None): |
ed4b2fee6 minor fixes |
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
from distutils.version import StrictVersion if StrictVersion(Qt.qVersion()) >= StrictVersion("4.5.0"): style = gr.prefs().get_string('qtgui', 'style', 'raster') Qt.QApplication.setGraphicsSystem(style) qapp = Qt.QApplication(sys.argv) tb = top_block_cls() tb.start() tb.show() def quitting(): tb.stop() tb.wait() qapp.connect(qapp, Qt.SIGNAL("aboutToQuit()"), quitting) qapp.exec_() if __name__ == '__main__': main() |