[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r9262 - in gnuradio/branches/developers/jblum/glwxgui/
From: |
jblum |
Subject: |
[Commit-gnuradio] r9262 - in gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python: . plotter |
Date: |
Tue, 12 Aug 2008 17:03:04 -0600 (MDT) |
Author: jblum
Date: 2008-08-12 17:03:03 -0600 (Tue, 12 Aug 2008)
New Revision: 9262
Modified:
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/common.py
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/const_window.py
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/constants.py
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/fft_window.py
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/number_window.py
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/plotter/channel_plotter.py
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/plotter/plotter_base.py
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/scope_window.py
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/scopesink_gl.py
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/waterfall_window.py
Log:
scope XY mode
Modified:
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/common.py
===================================================================
--- gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/common.py
2008-08-12 22:26:54 UTC (rev 9261)
+++ gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/common.py
2008-08-12 23:03:03 UTC (rev 9262)
@@ -91,13 +91,13 @@
self._incr_button.Disable()
self._decr_button.Disable()
-class RunStopButtonController(wx.Button):
- def __init__(self, parent, controller, control_key):
+class ToggleButtonController(wx.Button):
+ def __init__(self, parent, controller, control_key, true_label,
false_label):
self._controller = controller
self._control_key = control_key
wx.Button.__init__(self, parent, -1, '', style=wx.BU_EXACTFIT)
self.Bind(wx.EVT_BUTTON, self._evt_button)
- controller.subscribe(control_key, lambda x: self.SetLabel(x and
'Stop' or 'Run'))
+ controller.subscribe(control_key, lambda x: self.SetLabel(x and
true_label or false_label))
def _evt_button(self, e):
self._controller[self._control_key] = not
self._controller[self._control_key]
@@ -150,7 +150,7 @@
Drop down controller with label and chooser.
Srop down selection from a set of choices.
"""
- def __init__(self, parent, label, choices, controller, control_key):
+ def __init__(self, parent, label, choices, controller, control_key,
size=(-1, -1)):
"""!
@param parent the parent window
@param label the label for the drop down
@@ -161,7 +161,7 @@
wx.BoxSizer.__init__(self, wx.HORIZONTAL)
self._label = wx.StaticText(parent, -1, ' %s '%label)
self.Add(self._label, 1, wx.ALIGN_CENTER_VERTICAL)
- self._chooser = wx.Choice(parent, -1, choices=[c[0] for c in
choices])
+ self._chooser = wx.Choice(parent, -1, choices=[c[0] for c in
choices], size=size)
def _on_chooser_event(event):
controller[control_key] =
choices[self._chooser.GetSelection()][1]
self._chooser.Bind(wx.EVT_CHOICE, _on_chooser_event)
Modified:
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/const_window.py
===================================================================
---
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/const_window.py
2008-08-12 22:26:54 UTC (rev 9261)
+++
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/const_window.py
2008-08-12 23:03:03 UTC (rev 9262)
@@ -89,7 +89,7 @@
control_box.Add(self.gain_mu_slider, 0, wx.EXPAND)
#run/stop
control_box.AddStretchSpacer()
- self.run_button = common.RunStopButtonController(self, parent,
RUNNING_KEY)
+ self.run_button = common.ToggleButtonController(self, parent,
RUNNING_KEY, 'Stop', 'Run')
control_box.Add(self.run_button, 0, wx.EXPAND)
#set sizer
self.SetSizerAndFit(control_box)
Modified:
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/constants.py
===================================================================
--- gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/constants.py
2008-08-12 22:26:54 UTC (rev 9261)
+++ gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/constants.py
2008-08-12 23:03:03 UTC (rev 9262)
@@ -47,9 +47,15 @@
SCOPE_TRIGGER_CHANNEL_KEY = 'scope_trigger_channel'
SCOPE_TRIGGER_LEVEL_KEY = 'scope_trigger_level'
SCOPE_TRIGGER_MODE_KEY = 'scope_trigger_mode'
+SCOPE_X_CHANNEL_KEY = 'scope_x_channel'
+SCOPE_Y_CHANNEL_KEY = 'scope_y_channel'
+SCOPE_XY_MODE_KEY = 'scope_xy_mode'
TRIGGER_CHANNEL_KEY = 'trigger_channel'
TRIGGER_LEVEL_KEY = 'trigger_level'
TRIGGER_MODE_KEY = 'trigger_mode'
+T_DIVS_KEY = 't_divs'
+T_OFF_KEY = 't_off'
+T_PER_DIV_KEY = 't_per_div'
X_DIVS_KEY = 'x_divs'
X_OFF_KEY = 'x_off'
X_PER_DIV_KEY = 'x_per_div'
Modified:
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/fft_window.py
===================================================================
---
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/fft_window.py
2008-08-12 22:26:54 UTC (rev 9261)
+++
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/fft_window.py
2008-08-12 23:03:03 UTC (rev 9262)
@@ -93,7 +93,7 @@
control_box.Add(self._ref_lvl_buttons, 0, wx.ALIGN_CENTER)
#run/stop
control_box.AddStretchSpacer()
- self.run_button = common.RunStopButtonController(self, parent,
RUNNING_KEY)
+ self.run_button = common.ToggleButtonController(self, parent,
RUNNING_KEY, 'Stop', 'Run')
control_box.Add(self.run_button, 0, wx.EXPAND)
#set sizer
self.SetSizerAndFit(control_box)
Modified:
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/number_window.py
===================================================================
---
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/number_window.py
2008-08-12 22:26:54 UTC (rev 9261)
+++
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/number_window.py
2008-08-12 23:03:03 UTC (rev 9262)
@@ -72,7 +72,7 @@
control_box.Add(self.avg_alpha_slider, 0, wx.EXPAND)
#run/stop
control_box.AddStretchSpacer()
- self.run_button = common.RunStopButtonController(self, parent,
RUNNING_KEY)
+ self.run_button = common.ToggleButtonController(self, parent,
RUNNING_KEY, 'Stop', 'Run')
control_box.Add(self.run_button, 0, wx.EXPAND)
#set sizer
self.SetSizerAndFit(control_box)
Modified:
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/plotter/channel_plotter.py
===================================================================
---
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/plotter/channel_plotter.py
2008-08-12 22:26:54 UTC (rev 9261)
+++
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/plotter/channel_plotter.py
2008-08-12 23:03:03 UTC (rev 9262)
@@ -210,6 +210,8 @@
if not self.enable_legend(): return
x_off = self.width - self.padding_right - LEGEND_BOX_PADDING
for i, channel in
enumerate(reversed(sorted(self._channels.keys()))):
+ samples = self._channels[channel][0]
+ if not len(samples): continue
color_spec = self._channels[channel][1]
txt = gltext.Text(channel,
font_size=LEGEND_TEXT_FONT_SIZE)
w, h = txt.get_size()
Modified:
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/plotter/plotter_base.py
===================================================================
---
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/plotter/plotter_base.py
2008-08-12 22:26:54 UTC (rev 9261)
+++
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/plotter/plotter_base.py
2008-08-12 23:03:03 UTC (rev 9262)
@@ -268,7 +268,7 @@
exp_dif = exp - exp_mod
base = tick/10**exp_dif
if abs(exp) >= 3:
- formatter = '%%.%dg'%(2-exp_mod)
+ formatter = '%%.%df'%(2-exp_mod)
tick_str = '%se%d'%(formatter%base, exp_dif)
else: tick_str = '%g'%tick
#text
Modified:
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/scope_window.py
===================================================================
---
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/scope_window.py
2008-08-12 22:26:54 UTC (rev 9261)
+++
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/scope_window.py
2008-08-12 23:03:03 UTC (rev 9262)
@@ -72,8 +72,8 @@
@param parent the wx parent window
"""
self.parent = parent
- wx.Panel.__init__(self, parent, -1, style=wx.SUNKEN_BORDER)
- control_box = wx.BoxSizer(wx.VERTICAL)
+ wx.Panel.__init__(self, parent, style=wx.SUNKEN_BORDER)
+ self.control_box = control_box = wx.BoxSizer(wx.VERTICAL)
#trigger options
control_box.AddStretchSpacer()
control_box.Add(common.LabelText(self, 'Trigger Options'), 0,
wx.ALIGN_CENTER)
@@ -94,29 +94,78 @@
SPACING = 15
control_box.AddStretchSpacer()
control_box.Add(common.LabelText(self, 'Axes Options'), 0,
wx.ALIGN_CENTER)
+ control_box.AddSpacer(2)
+ ##################################################
+ # Scope Mode Box
+ ##################################################
+ self.scope_mode_box = wx.BoxSizer(wx.VERTICAL)
+ control_box.Add(self.scope_mode_box, 0, wx.EXPAND)
#x axis divs
hbox = wx.BoxSizer(wx.HORIZONTAL)
- control_box.Add(hbox, 0, wx.EXPAND)
+ self.scope_mode_box.Add(hbox, 0, wx.EXPAND)
hbox.Add(wx.StaticText(self, -1, ' Secs/Div '), 1,
wx.ALIGN_CENTER_VERTICAL)
- self.x_buttons = common.IncrDecrButtons(self,
self._on_incr_x_divs, self._on_decr_x_divs)
- hbox.Add(self.x_buttons, 0, wx.ALIGN_CENTER_VERTICAL)
+ x_buttons = common.IncrDecrButtons(self, self._on_incr_t_divs,
self._on_decr_t_divs)
+ hbox.Add(x_buttons, 0, wx.ALIGN_CENTER_VERTICAL)
hbox.AddSpacer(SPACING)
#y axis divs
hbox = wx.BoxSizer(wx.HORIZONTAL)
- control_box.Add(hbox, 0, wx.EXPAND)
+ self.scope_mode_box.Add(hbox, 0, wx.EXPAND)
hbox.Add(wx.StaticText(self, -1, ' Units/Div '), 1,
wx.ALIGN_CENTER_VERTICAL)
- self.y_buttons = common.IncrDecrButtons(self,
self._on_incr_y_divs, self._on_decr_y_divs)
- parent.subscribe(AUTORANGE_KEY, self.y_buttons.Disable)
- hbox.Add(self.y_buttons, 0, wx.ALIGN_CENTER_VERTICAL)
+ y_buttons = common.IncrDecrButtons(self, self._on_incr_y_divs,
self._on_decr_y_divs)
+ parent.subscribe(AUTORANGE_KEY, y_buttons.Disable)
+ hbox.Add(y_buttons, 0, wx.ALIGN_CENTER_VERTICAL)
hbox.AddSpacer(SPACING)
#y axis ref lvl
hbox = wx.BoxSizer(wx.HORIZONTAL)
- control_box.Add(hbox, 0, wx.EXPAND)
+ self.scope_mode_box.Add(hbox, 0, wx.EXPAND)
hbox.Add(wx.StaticText(self, -1, ' Y Offset '), 1,
wx.ALIGN_CENTER_VERTICAL)
- self.y_off_buttons = common.IncrDecrButtons(self,
self._on_incr_y_off, self._on_decr_y_off)
- parent.subscribe(AUTORANGE_KEY, self.y_off_buttons.Disable)
- hbox.Add(self.y_off_buttons, 0, wx.ALIGN_CENTER_VERTICAL)
+ y_off_buttons = common.IncrDecrButtons(self,
self._on_incr_y_off, self._on_decr_y_off)
+ parent.subscribe(AUTORANGE_KEY, y_off_buttons.Disable)
+ hbox.Add(y_off_buttons, 0, wx.ALIGN_CENTER_VERTICAL)
hbox.AddSpacer(SPACING)
+ ##################################################
+ # XY Mode Box
+ ##################################################
+ self.xy_mode_box = wx.BoxSizer(wx.VERTICAL)
+ control_box.Add(self.xy_mode_box, 0, wx.EXPAND)
+ #x and y channel
+ CHOOSER_WIDTH = 60
+ CENTER_SPACING = 10
+ hbox = wx.BoxSizer(wx.HORIZONTAL)
+ self.xy_mode_box.Add(hbox, 0, wx.EXPAND)
+ choices = [('Ch%d'%(i+1), i) for i in range(parent.num_inputs)]
+ self.channel_x_chooser = common.DropDownController(self, 'X
Ch', choices, parent, SCOPE_X_CHANNEL_KEY, (CHOOSER_WIDTH, -1))
+ hbox.Add(self.channel_x_chooser, 0, wx.EXPAND)
+ hbox.AddSpacer(CENTER_SPACING)
+ self.channel_y_chooser = common.DropDownController(self, 'Y
Ch', choices, parent, SCOPE_Y_CHANNEL_KEY, (CHOOSER_WIDTH, -1))
+ hbox.Add(self.channel_y_chooser, 0, wx.EXPAND)
+ #div controls
+ hbox = wx.BoxSizer(wx.HORIZONTAL)
+ self.xy_mode_box.Add(hbox, 0, wx.EXPAND)
+ hbox.Add(wx.StaticText(self, -1, ' X/Div '), 1,
wx.ALIGN_CENTER_VERTICAL)
+ x_buttons = common.IncrDecrButtons(self, self._on_incr_x_divs,
self._on_decr_x_divs)
+ parent.subscribe(AUTORANGE_KEY, x_buttons.Disable)
+ hbox.Add(x_buttons, 0, wx.ALIGN_CENTER_VERTICAL)
+ hbox.AddSpacer(CENTER_SPACING)
+ hbox.Add(wx.StaticText(self, -1, ' Y/Div '), 1,
wx.ALIGN_CENTER_VERTICAL)
+ y_buttons = common.IncrDecrButtons(self, self._on_incr_y_divs,
self._on_decr_y_divs)
+ parent.subscribe(AUTORANGE_KEY, y_buttons.Disable)
+ hbox.Add(y_buttons, 0, wx.ALIGN_CENTER_VERTICAL)
+ #offset controls
+ hbox = wx.BoxSizer(wx.HORIZONTAL)
+ self.xy_mode_box.Add(hbox, 0, wx.EXPAND)
+ hbox.Add(wx.StaticText(self, -1, ' X Off '), 1,
wx.ALIGN_CENTER_VERTICAL)
+ x_off_buttons = common.IncrDecrButtons(self,
self._on_incr_x_off, self._on_decr_x_off)
+ parent.subscribe(AUTORANGE_KEY, x_off_buttons.Disable)
+ hbox.Add(x_off_buttons, 0, wx.ALIGN_CENTER_VERTICAL)
+ hbox.AddSpacer(CENTER_SPACING)
+ hbox.Add(wx.StaticText(self, -1, ' Y Off '), 1,
wx.ALIGN_CENTER_VERTICAL)
+ y_off_buttons = common.IncrDecrButtons(self,
self._on_incr_y_off, self._on_decr_y_off)
+ parent.subscribe(AUTORANGE_KEY, y_off_buttons.Disable)
+ hbox.Add(y_off_buttons, 0, wx.ALIGN_CENTER_VERTICAL)
+ ##################################################
+ # End Special Boxes
+ ##################################################
#misc options
control_box.AddStretchSpacer()
control_box.Add(common.LabelText(self, 'Range Options'), 0,
wx.ALIGN_CENTER)
@@ -128,7 +177,11 @@
control_box.Add(self.autorange_check_box, 0, wx.ALIGN_LEFT)
#run/stop
control_box.AddStretchSpacer()
- self.run_button = common.RunStopButtonController(self, parent,
RUNNING_KEY)
+ self.scope_xy_mode_button = common.ToggleButtonController(self,
parent, SCOPE_XY_MODE_KEY, 'Scope Mode', 'X:Y Mode')
+ parent.subscribe(SCOPE_XY_MODE_KEY, self._on_scope_xy_mode)
+ control_box.Add(self.scope_xy_mode_button, 0, wx.EXPAND)
+ #run/stop
+ self.run_button = common.ToggleButtonController(self, parent,
RUNNING_KEY, 'Stop', 'Run')
control_box.Add(self.run_button, 0, wx.EXPAND)
#set sizer
self.SetSizerAndFit(control_box)
@@ -136,6 +189,17 @@
##################################################
# Event handlers
##################################################
+ def _on_scope_xy_mode(self, mode):
+ self.scope_mode_box.ShowItems(not mode)
+ self.xy_mode_box.ShowItems(mode)
+ self.control_box.Layout()
+ #incr/decr divs
+ def _on_incr_t_divs(self, event):
+ self.parent.set_t_per_div(
+ common.get_clean_incr(self.parent[T_PER_DIV_KEY]))
+ def _on_decr_t_divs(self, event):
+ self.parent.set_t_per_div(
+ common.get_clean_decr(self.parent[T_PER_DIV_KEY]))
def _on_incr_x_divs(self, event):
self.parent.set_x_per_div(
common.get_clean_incr(self.parent[X_PER_DIV_KEY]))
@@ -148,6 +212,19 @@
def _on_decr_y_divs(self, event):
self.parent.set_y_per_div(
common.get_clean_decr(self.parent[Y_PER_DIV_KEY]))
+ #incr/decr offset
+ def _on_incr_t_off(self, event):
+ self.parent.set_t_off(
+ self.parent[T_OFF_KEY] + self.parent[T_PER_DIV_KEY])
+ def _on_decr_t_off(self, event):
+ self.parent.set_t_off(
+ self.parent[T_OFF_KEY] - self.parent[T_PER_DIV_KEY])
+ def _on_incr_x_off(self, event):
+ self.parent.set_x_off(
+ self.parent[X_OFF_KEY] + self.parent[X_PER_DIV_KEY])
+ def _on_decr_x_off(self, event):
+ self.parent.set_x_off(
+ self.parent[X_OFF_KEY] - self.parent[X_PER_DIV_KEY])
def _on_incr_y_off(self, event):
self.parent.set_y_off(
self.parent[Y_OFF_KEY] + self.parent[Y_PER_DIV_KEY])
@@ -171,6 +248,7 @@
x_per_div,
y_per_div,
ac_couple,
+ xy_mode,
scope_trigger_level_key,
scope_trigger_mode_key,
scope_trigger_channel_key,
@@ -199,7 +277,7 @@
self.plotter = plotter.channel_plotter(self)
self.plotter.SetSize(wx.Size(*size))
self.plotter.set_title(title)
- self.plotter.enable_legend(self.num_inputs > 1)
+ self.plotter.enable_legend(True)
self.plotter.enable_point_label(True)
#setup the box with plot and controls
self.control_panel = control_panel(self)
@@ -210,13 +288,19 @@
#initial setup
self._register_set_prop(self, RUNNING_KEY, True)
self._register_set_prop(self, AC_COUPLE_KEY, ac_couple)
+ self._register_set_prop(self, SCOPE_XY_MODE_KEY, xy_mode)
self._register_set_prop(self, AUTORANGE_KEY, autorange)
- self._register_set_prop(self, X_PER_DIV_KEY, x_per_div)
+ self._register_set_prop(self, T_PER_DIV_KEY, x_per_div)
+ self._register_set_prop(self, X_PER_DIV_KEY, y_per_div)
self._register_set_prop(self, Y_PER_DIV_KEY, y_per_div)
+ self._register_set_prop(self, T_OFF_KEY, 0)
self._register_set_prop(self, X_OFF_KEY, 0)
self._register_set_prop(self, Y_OFF_KEY, 0)
+ self._register_set_prop(self, T_DIVS_KEY, 8)
self._register_set_prop(self, X_DIVS_KEY, 8)
self._register_set_prop(self, Y_DIVS_KEY, 8)
+ self._register_set_prop(self, SCOPE_X_CHANNEL_KEY, 0)
+ self._register_set_prop(self, SCOPE_Y_CHANNEL_KEY, 1)
self._register_set_prop(self, FRAME_RATE_KEY, frame_rate)
self._register_set_prop(self, TRIGGER_CHANNEL_KEY, 0)
self._register_set_prop(self, TRIGGER_MODE_KEY, 1)
@@ -226,9 +310,12 @@
self.ext_controller.subscribe(sample_rate_key,
self.update_decim)
self.subscribe(FRAME_RATE_KEY, self.update_decim)
for key in (
- X_PER_DIV_KEY, Y_PER_DIV_KEY,
- X_OFF_KEY, Y_OFF_KEY,
- X_DIVS_KEY, Y_DIVS_KEY,
+ T_PER_DIV_KEY, X_PER_DIV_KEY, Y_PER_DIV_KEY,
+ T_OFF_KEY, X_OFF_KEY, Y_OFF_KEY,
+ T_DIVS_KEY, X_DIVS_KEY, Y_DIVS_KEY,
+ SCOPE_XY_MODE_KEY,
+ SCOPE_X_CHANNEL_KEY,
+ SCOPE_Y_CHANNEL_KEY,
): self.subscribe(key, self.update_grid)
#initial update, dont do this here, wait for handle_msg #HACK
#self.update_grid()
@@ -245,26 +332,69 @@
#convert to floating point numbers
samples = numpy.fromstring(msg, numpy.float32)
samps_per_ch = len(samples)/self.num_inputs
- sampleses = [samples[samps_per_ch*i:samps_per_ch*(i+1)] for i
in range(self.num_inputs)]
+ self.sampleses = [samples[samps_per_ch*i:samps_per_ch*(i+1)]
for i in range(self.num_inputs)]
if not self._init: #HACK
self._init = True
self.update_grid()
self.update_decim()
if self.frame_counter == 0: #decimate
- #trigger level (must do before ac coupling)
- self.ext_controller[self.scope_trigger_channel_key] =
self[TRIGGER_CHANNEL_KEY]
- self.ext_controller[self.scope_trigger_mode_key] =
self[TRIGGER_MODE_KEY]
- trigger_level = self[TRIGGER_LEVEL_KEY]
- if trigger_level is None:
self.ext_controller[self.scope_trigger_level_key] = ''
- else:
- samples = sampleses[self[TRIGGER_CHANNEL_KEY]]
-
self.ext_controller[self.scope_trigger_level_key] = \
-
trigger_level*(numpy.max(samples)-numpy.min(samples))/2 + numpy.average(samples)
- #ac coupling
- if self[AC_COUPLE_KEY]:
- sampleses = [samples - numpy.average(samples)
for samples in sampleses]
+ self.handle_samples()
+ self.frame_counter = (self.frame_counter + 1)%self.decim
+
+ def handle_samples(self):
+ """!
+ Handle the cached samples from the scope input.
+ Perform ac coupling, triggering, and auto ranging.
+ """
+ sampleses = self.sampleses
+ #trigger level (must do before ac coupling)
+ self.ext_controller[self.scope_trigger_channel_key] =
self[TRIGGER_CHANNEL_KEY]
+ self.ext_controller[self.scope_trigger_mode_key] =
self[TRIGGER_MODE_KEY]
+ trigger_level = self[TRIGGER_LEVEL_KEY]
+ if trigger_level is None:
self.ext_controller[self.scope_trigger_level_key] = ''
+ else:
+ samples = sampleses[self[TRIGGER_CHANNEL_KEY]]
+ self.ext_controller[self.scope_trigger_level_key] = \
+ trigger_level*(numpy.max(samples)-numpy.min(samples))/2
+ numpy.average(samples)
+ #ac coupling
+ if self[AC_COUPLE_KEY]:
+ sampleses = [samples - numpy.average(samples) for
samples in sampleses]
+ if self[SCOPE_XY_MODE_KEY]:
+ x_samples = sampleses[self[SCOPE_X_CHANNEL_KEY]]
+ y_samples = sampleses[self[SCOPE_Y_CHANNEL_KEY]]
#autorange
if self[AUTORANGE_KEY] and time.time() -
self.autorange_ts > AUTORANGE_UPDATE_RATE:
+ x_min, x_max = common.get_min_max(x_samples)
+ y_min, y_max = common.get_min_max(y_samples)
+ #adjust the x per div
+ x_per_div =
common.get_clean_num((x_max-x_min)/self[X_DIVS_KEY])
+ if x_per_div != self[X_PER_DIV_KEY]:
self.set_x_per_div(x_per_div)
+ #adjust the x offset
+ x_off =
x_per_div*round((x_max+x_min)/2/x_per_div)
+ if x_off != self[X_OFF_KEY]:
self.set_x_off(x_off)
+ #adjust the y per div
+ y_per_div =
common.get_clean_num((y_max-y_min)/self[Y_DIVS_KEY])
+ if y_per_div != self[Y_PER_DIV_KEY]:
self.set_y_per_div(y_per_div)
+ #adjust the y offset
+ y_off =
y_per_div*round((y_max+y_min)/2/y_per_div)
+ if y_off != self[Y_OFF_KEY]:
self.set_y_off(y_off)
+ self.autorange_ts = time.time()
+ #plot xy channel
+ self.plotter.set_waveform(
+ channel='XY',
+ samples=(x_samples, y_samples),
+ color_spec=CHANNEL_COLOR_SPECS[0],
+ )
+ #turn off each waveform
+ for i, samples in enumerate(sampleses):
+ self.plotter.set_waveform(
+ channel='Ch%d'%(i+1),
+ samples=[],
+ color_spec=CHANNEL_COLOR_SPECS[i],
+ )
+ else:
+ #autorange
+ if self[AUTORANGE_KEY] and time.time() -
self.autorange_ts > AUTORANGE_UPDATE_RATE:
bounds = [common.get_min_max(samples) for
samples in sampleses]
y_min = numpy.min(*[bound[0] for bound in
bounds])
y_max = numpy.max(*[bound[1] for bound in
bounds])
@@ -278,9 +408,10 @@
#plot each waveform
for i, samples in enumerate(sampleses):
#number of samples to scale to the screen
- num_samps =
int(self[X_PER_DIV_KEY]*self[X_DIVS_KEY]*self.ext_controller[self.sample_rate_key])
+ num_samps =
int(self[T_PER_DIV_KEY]*self[T_DIVS_KEY]*self.ext_controller[self.sample_rate_key])
#handle num samps out of bounds
- while num_samps > len(samples): samples =
numpy.concatenate((samples, samples))
+ #bad, can take 110% CPU
+ #while num_samps > len(samples): samples =
numpy.concatenate((samples, samples))
if num_samps < 2: num_samps = 0
#plot samples
self.plotter.set_waveform(
@@ -288,9 +419,14 @@
samples=samples[:num_samps],
color_spec=CHANNEL_COLOR_SPECS[i],
)
- #update the plotter
- self.plotter.update()
- self.frame_counter = (self.frame_counter + 1)%self.decim
+ #turn XY channel off
+ self.plotter.set_waveform(
+ channel='XY',
+ samples=[],
+ color_spec=CHANNEL_COLOR_SPECS[0],
+ )
+ #update the plotter
+ self.plotter.update()
def update_decim(self, *args):
"""!
@@ -300,31 +436,54 @@
self.decim = max(1, int(decim))
def update_grid(self, *args):
+ """!
+ Update the grid to reflect the current settings:
+ xy divisions, xy offset, xy mode setting
+ """
#grid parameters
+ t_per_div = self[T_PER_DIV_KEY]
x_per_div = self[X_PER_DIV_KEY]
y_per_div = self[Y_PER_DIV_KEY]
+ t_off = self[T_OFF_KEY]
x_off = self[X_OFF_KEY]
y_off = self[Y_OFF_KEY]
+ t_divs = self[T_DIVS_KEY]
x_divs = self[X_DIVS_KEY]
y_divs = self[Y_DIVS_KEY]
- #update the x axis
- exp = common.get_exp(x_per_div)
- if exp > -2: x_units, scalar = 's', 1e0
- elif exp > -5: x_units, scalar = 'ms', 1e3
- elif exp > -8: x_units, scalar = 'us', 1e6
- else: x_units, scalar = 'ns', 1e9
- self.plotter.set_x_label('Time', x_units)
- self.plotter.set_x_grid(
- scalar*x_off,
- scalar*x_per_div*x_divs + scalar*x_off,
- scalar*x_per_div,
- )
- #update the y axis
- self.plotter.set_y_label('Voltage')
- self.plotter.set_y_grid(
- -1*y_per_div*y_divs/2.0 + y_off,
- y_per_div*y_divs/2.0 + y_off,
- y_per_div,
- )
- #update plotter
- self.plotter.update()
+ if self[SCOPE_XY_MODE_KEY]:
+ #update the x axis
+
self.plotter.set_x_label('Ch%d'%(self[SCOPE_X_CHANNEL_KEY]+1))
+ self.plotter.set_x_grid(
+ -1*x_per_div*x_divs/2.0 + x_off,
+ x_per_div*x_divs/2.0 + x_off,
+ x_per_div,
+ )
+ #update the y axis
+
self.plotter.set_y_label('Ch%d'%(self[SCOPE_Y_CHANNEL_KEY]+1))
+ self.plotter.set_y_grid(
+ -1*y_per_div*y_divs/2.0 + y_off,
+ y_per_div*y_divs/2.0 + y_off,
+ y_per_div,
+ )
+ else:
+ #update the t axis
+ exp = common.get_exp(t_per_div)
+ if exp > -2: units, scalar = 's', 1e0
+ elif exp > -5: units, scalar = 'ms', 1e3
+ elif exp > -8: units, scalar = 'us', 1e6
+ else: units, scalar = 'ns', 1e9
+ self.plotter.set_x_label('Time', units)
+ self.plotter.set_x_grid(
+ scalar*t_off,
+ scalar*t_per_div*t_divs + scalar*t_off,
+ scalar*t_per_div,
+ )
+ #update the y axis
+ self.plotter.set_y_label('Voltage')
+ self.plotter.set_y_grid(
+ -1*y_per_div*y_divs/2.0 + y_off,
+ y_per_div*y_divs/2.0 + y_off,
+ y_per_div,
+ )
+ #redraw current sample
+ self.handle_samples()
Modified:
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/scopesink_gl.py
===================================================================
---
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/scopesink_gl.py
2008-08-12 22:26:54 UTC (rev 9261)
+++
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/scopesink_gl.py
2008-08-12 23:03:03 UTC (rev 9262)
@@ -47,6 +47,7 @@
t_scale=None,
num_inputs=1,
ac_couple=False,
+ xy_mode=False,
frame_rate=scope_window.DEFAULT_FRAME_RATE,
):
if t_scale is None: t_scale = 0.001
@@ -104,6 +105,7 @@
x_per_div=t_scale,
y_per_div=v_scale,
ac_couple=ac_couple,
+ xy_mode=xy_mode,
scope_trigger_level_key=SCOPE_TRIGGER_LEVEL_KEY,
scope_trigger_mode_key=SCOPE_TRIGGER_MODE_KEY,
scope_trigger_channel_key=SCOPE_TRIGGER_CHANNEL_KEY,
@@ -147,7 +149,7 @@
if len(argv) > 3:
t_scale = float(argv[3]) # start up at this t_scale value
else:
- t_scale = None # old behavior
+ t_scale = .00003 # old behavior
print "frame decim %s v_scale %s t_scale %s" %
(frame_decim,v_scale,t_scale)
Modified:
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/waterfall_window.py
===================================================================
---
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/waterfall_window.py
2008-08-12 22:26:54 UTC (rev 9261)
+++
gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python/waterfall_window.py
2008-08-12 23:03:03 UTC (rev 9262)
@@ -109,7 +109,7 @@
self.clear_button.Bind(wx.EVT_BUTTON, self._on_clear_button)
control_box.Add(self.clear_button, 0, wx.EXPAND)
#run/stop
- self.run_button = common.RunStopButtonController(self, parent,
RUNNING_KEY)
+ self.run_button = common.ToggleButtonController(self, parent,
RUNNING_KEY, 'Stop', 'Run')
control_box.Add(self.run_button, 0, wx.EXPAND)
#set sizer
self.SetSizerAndFit(control_box)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r9262 - in gnuradio/branches/developers/jblum/glwxgui/gr-wxgui/src/python: . plotter,
jblum <=