3 # Copyright 2005 Free Software Foundation, Inc.
5 # This file is part of GNU Radio
7 # GNU Radio is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3, or (at your option)
12 # GNU Radio is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with GNU Radio; see the file COPYING. If not, write to
19 # the Free Software Foundation, Inc., 51 Franklin Street,
20 # Boston, MA 02110-1301, USA.
25 from gnuradio.wxgui import form
27 class flexrf_debug_gui(wx.Frame):
28 def __init__(self, flexrf, title="Flexrf Debug"):
29 wx.Frame.__init__(self, None, -1, title)
33 self.CreateStatusBar (1)
35 self.panel = wx.Panel(self, -1)
36 self.vbox = wx.BoxSizer(wx.VERTICAL)
37 self.panel.SetSizer(self.vbox)
38 self.panel.SetAutoLayout(True)
42 self.vbox.Fit(self.panel)
44 self.frame_vbox = wx.BoxSizer(wx.VERTICAL)
45 self.frame_vbox.Add(self.panel, 1, wx.EXPAND)
46 self.SetSizer(self.frame_vbox)
47 self.SetAutoLayout(True)
48 self.frame_vbox.Fit(self)
50 def _create_form(self):
51 self._create_set_freq()
52 self._create_write_fpga()
53 self._create_write_all()
54 self._create_write_it()
55 #self._create_set_gain()
57 # ----------------------------------------------------------------
59 def _create_set_freq(self):
62 return self.flexrf.set_freq(kv['freq'])[0]
64 sbs = wx.StaticBoxSizer(wx.StaticBox(self.panel), wx.HORIZONTAL)
65 sbs.Add((5,0), 0.1) # stretchy space
66 #sbs.Add(wx.StaticText(self.panel, -1, "set_freq "), 0, 0)
67 #sbs.Add((5,0), 0.1) # stretchy space
69 myform['freq'] = form.float_field(self.panel, sbs, "Set Frequency")
70 sbs.Add((5,0), 0.1) # stretchy space
71 sbs.Add(form.button_with_callback(self.panel, "Do It!",
72 self._generic_doit(_set_freq, myform)), 1, wx.EXPAND)
73 sbs.Add((5,0), 0.1) # stretchy space
74 self.vbox.Add(sbs, 0, wx.EXPAND)
77 def _create_write_fpga(self):
80 return self.flexrf._u._write_fpga_reg(kv['regno'], kv['value'])
82 sbs = wx.StaticBoxSizer(wx.StaticBox(self.panel), wx.HORIZONTAL)
83 sbs.Add((5,0), 0.1) # stretchy space
84 sbs.Add(wx.StaticText(self.panel, -1, "write_fpga_reg "), 0, 0)
85 sbs.Add((5,0), 0.1) # stretchy space
87 myform['regno'] = form.int_field(self.panel, sbs, "regno")
88 sbs.Add((5,0), 0.1) # stretchy space
89 myform['value'] = form.int_field(self.panel, sbs, "value")
90 sbs.Add((5,0), 0.1) # stretchy space
91 sbs.Add(form.button_with_callback(self.panel, "Do It!",
92 self._generic_doit(_write_fpga, myform)), 1, wx.EXPAND)
93 sbs.Add((5,0), 0.1) # stretchy space
94 self.vbox.Add(sbs, 0, wx.EXPAND)
97 def _create_write_all(self):
100 self.flexrf._write_all(kv['R'], kv['control'], kv['N']) # void
103 sbs = wx.StaticBoxSizer(wx.StaticBox(self.panel), wx.HORIZONTAL)
104 sbs.Add((5,0), 0.1) # stretchy space
105 sbs.Add(wx.StaticText(self.panel, -1, "write_all "), 0, 0)
106 sbs.Add((5,0), 0.1) # stretchy space
108 myform['R'] = form.int_field(self.panel, sbs, "R")
109 sbs.Add((5,0), 0.1) # stretchy space
110 myform['control'] = form.int_field(self.panel, sbs, "control")
111 sbs.Add((5,0), 0.1) # stretchy space
112 myform['N'] = form.int_field(self.panel, sbs, "N")
113 sbs.Add((5,0), 0.1) # stretchy space
114 sbs.Add(form.button_with_callback(self.panel, "Do It!",
115 self._generic_doit(_write_all, myform)), 1, wx.EXPAND)
116 sbs.Add((5,0), 0.1) # stretchy space
117 self.vbox.Add(sbs, 0, wx.EXPAND)
120 def _create_write_it(self):
123 self.flexrf._write_it(kv['v']) # void
126 sbs = wx.StaticBoxSizer(wx.StaticBox(self.panel), wx.HORIZONTAL)
127 sbs.Add((5,0), 0.1) # stretchy space
128 sbs.Add(wx.StaticText(self.panel, -1, "write_it "), 0, 0)
129 sbs.Add((5,0), 0.1) # stretchy space
131 myform['v'] = form.int_field(self.panel, sbs, "24-bit value")
132 sbs.Add((5,0), 0.1) # stretchy space
133 sbs.Add(form.button_with_callback(self.panel, "Do It!",
134 self._generic_doit(_write_it, myform)), 1, wx.EXPAND)
135 sbs.Add((5,0), 0.1) # stretchy space
136 self.vbox.Add(sbs, 0, wx.EXPAND)
139 # ----------------------------------------------------------------
141 def _set_status_msg(self, msg):
142 self.GetStatusBar().SetStatusText(msg, 0)
144 def _generic_doit(self, callback, form):
146 def button_callback():
147 errors = form.check_input_for_errors()
149 self._set_status_msg(errors[0])
150 print '\n'.join(tuple(errors))
152 kv = form.get_key_vals()
154 self._set_status_msg("OK")
156 self._set_status_msg("Failed")
158 return button_callback
162 if False and __name__ == '__main__':
164 class demo_app (wx.App):
166 wx.App.__init__(self)
169 frame = flexrf_debug_gui(None, "Debug FlexRF TX")
171 self.SetTopWindow (frame)