diff options
author | Johnathan Corgan | 2009-11-13 11:28:58 -0800 |
---|---|---|
committer | Johnathan Corgan | 2009-11-13 11:28:58 -0800 |
commit | baac64c9f1ff5fd5eaf9c24159d56567fd4c6fca (patch) | |
tree | 33ed69583ffd3b1b0ec630d3383ca0935719857f /gr-howto-write-a-block/apps/howto_square.py | |
parent | 5787a2c4f9dbaca94f7b2e7d43f677a64209e5f7 (diff) | |
parent | df8b099a4b96ad41369a750d48a8576b95ecf454 (diff) | |
download | gnuradio-baac64c9f1ff5fd5eaf9c24159d56567fd4c6fca.tar.gz gnuradio-baac64c9f1ff5fd5eaf9c24159d56567fd4c6fca.tar.bz2 gnuradio-baac64c9f1ff5fd5eaf9c24159d56567fd4c6fca.zip |
Merge branch 'wip/howto' of git@gnuradio.org:jcorgan
* 'wip/howto' of git@gnuradio.org:jcorgan:
howto: cleanup for merge
howto: add README.hacking
howto: added howto application
howto: add GRC wrappers to squaring blocks
howto: move limbo'd docs into toplevel doc dir for preservation
howto: create howto_swig.*, use constructed Python namespace
howto: adds C++ QA code
Diffstat (limited to 'gr-howto-write-a-block/apps/howto_square.py')
-rwxr-xr-x | gr-howto-write-a-block/apps/howto_square.py | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/gr-howto-write-a-block/apps/howto_square.py b/gr-howto-write-a-block/apps/howto_square.py new file mode 100755 index 000000000..8d3d870d8 --- /dev/null +++ b/gr-howto-write-a-block/apps/howto_square.py @@ -0,0 +1,77 @@ +#!/usr/bin/env python +################################################## +# Gnuradio Python Flow Graph +# Title: Howto Square +# Generated: Thu Nov 12 11:26:07 2009 +################################################## + +from gnuradio import eng_notation +from gnuradio import gr +from gnuradio import howto +from gnuradio.eng_option import eng_option +from gnuradio.gr import firdes +from gnuradio.wxgui import scopesink2 +from grc_gnuradio import wxgui as grc_wxgui +from optparse import OptionParser +import wx + +class howto_square(grc_wxgui.top_block_gui): + + def __init__(self): + grc_wxgui.top_block_gui.__init__(self, title="Howto Square") + + ################################################## + # Variables + ################################################## + self.samp_rate = samp_rate = 10e3 + + ################################################## + # Blocks + ################################################## + self.sink = scopesink2.scope_sink_f( + self.GetWin(), + title="Input", + sample_rate=samp_rate, + v_scale=20, + v_offset=0, + t_scale=0.002, + ac_couple=False, + xy_mode=False, + num_inputs=1, + ) + self.Add(self.sink.win) + self.sink2 = scopesink2.scope_sink_f( + self.GetWin(), + title="Output", + sample_rate=samp_rate, + v_scale=0, + v_offset=0, + t_scale=0.002, + ac_couple=False, + xy_mode=False, + num_inputs=1, + ) + self.Add(self.sink2.win) + self.sqr = howto.square_ff() + self.src = gr.vector_source_f(([float(n)-50 for n in range(100)]), True, 1) + self.thr = gr.throttle(gr.sizeof_float*1, samp_rate) + + ################################################## + # Connections + ################################################## + self.connect((self.thr, 0), (self.sqr, 0)) + self.connect((self.src, 0), (self.thr, 0)) + self.connect((self.thr, 0), (self.sink, 0)) + self.connect((self.sqr, 0), (self.sink2, 0)) + + def set_samp_rate(self, samp_rate): + self.samp_rate = samp_rate + self.sink.set_sample_rate(self.samp_rate) + self.sink2.set_sample_rate(self.samp_rate) + +if __name__ == '__main__': + parser = OptionParser(option_class=eng_option, usage="%prog: [options]") + (options, args) = parser.parse_args() + tb = howto_square() + tb.Run(True) + |