X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=gr-wxgui%2Fsrc%2Fpython%2Fwaterfall_window.py;h=6536ada10100287b3348c8e8b6bea7e0227a9c14;hb=2924c0e740bbb9106bfed602345daaee5606d62a;hp=77819b7339589e72b4ef13e43f3f1b03c93c2289;hpb=51af4269d3eebd3d611be918f8c799c96c650496;p=debian%2Fgnuradio diff --git a/gr-wxgui/src/python/waterfall_window.py b/gr-wxgui/src/python/waterfall_window.py index 77819b73..6536ada1 100644 --- a/gr-wxgui/src/python/waterfall_window.py +++ b/gr-wxgui/src/python/waterfall_window.py @@ -38,9 +38,11 @@ import forms SLIDER_STEPS = 100 AVG_ALPHA_MIN_EXP, AVG_ALPHA_MAX_EXP = -3, 0 DEFAULT_FRAME_RATE = gr.prefs().get_long('wxgui', 'waterfall_rate', 30) +DEFAULT_COLOR_MODE = gr.prefs().get_string('wxgui', 'waterfall_color', 'rgb1') DEFAULT_WIN_SIZE = (600, 300) DIV_LEVELS = (1, 2, 5, 10, 20) MIN_DYNAMIC_RANGE, MAX_DYNAMIC_RANGE = 10, 200 +DYNAMIC_RANGE_STEP = 10. COLOR_MODES = ( ('RGB1', 'rgb1'), ('RGB2', 'rgb2'), @@ -63,6 +65,8 @@ class control_panel(wx.Panel): """ self.parent = parent wx.Panel.__init__(self, parent, style=wx.SUNKEN_BORDER) + parent[SHOW_CONTROL_PANEL_KEY] = True + parent.subscribe(SHOW_CONTROL_PANEL_KEY, self.Show) control_box = wx.BoxSizer(wx.VERTICAL) control_box.AddStretchSpacer() options_box = forms.static_box_sizer( @@ -143,16 +147,19 @@ class control_panel(wx.Panel): def _on_clear_button(self, event): self.parent[NUM_LINES_KEY] = self.parent[NUM_LINES_KEY] def _on_incr_dynamic_range(self, event): - self.parent[DYNAMIC_RANGE_KEY] = min(self.parent[DYNAMIC_RANGE_KEY] + 10, MAX_DYNAMIC_RANGE) + self.parent[DYNAMIC_RANGE_KEY] = min(MAX_DYNAMIC_RANGE, common.get_clean_incr(self.parent[DYNAMIC_RANGE_KEY])) def _on_decr_dynamic_range(self, event): - self.parent[DYNAMIC_RANGE_KEY] = max(self.parent[DYNAMIC_RANGE_KEY] - 10, MIN_DYNAMIC_RANGE) + self.parent[DYNAMIC_RANGE_KEY] = max(MIN_DYNAMIC_RANGE, common.get_clean_decr(self.parent[DYNAMIC_RANGE_KEY])) def _on_incr_ref_level(self, event): - self.parent[REF_LEVEL_KEY] = self.parent[REF_LEVEL_KEY] + self.parent[DYNAMIC_RANGE_KEY]*.1 + self.parent[REF_LEVEL_KEY] = self.parent[REF_LEVEL_KEY] + self.parent[DYNAMIC_RANGE_KEY]/DYNAMIC_RANGE_STEP def _on_decr_ref_level(self, event): - self.parent[REF_LEVEL_KEY] = self.parent[REF_LEVEL_KEY] - self.parent[DYNAMIC_RANGE_KEY]*.1 + self.parent[REF_LEVEL_KEY] = self.parent[REF_LEVEL_KEY] - self.parent[DYNAMIC_RANGE_KEY]/DYNAMIC_RANGE_STEP def _on_incr_time_scale(self, event): old_rate = self.parent[FRAME_RATE_KEY] self.parent[FRAME_RATE_KEY] *= 0.75 + if self.parent[FRAME_RATE_KEY] < 1.0: + self.parent[FRAME_RATE_KEY] = 1.0 + if self.parent[FRAME_RATE_KEY] == old_rate: self.parent[DECIMATION_KEY] += 1 def _on_decr_time_scale(self, event): @@ -214,6 +221,7 @@ class waterfall_window(wx.Panel, pubsub.pubsub): self[REF_LEVEL_KEY] = ref_level self[BASEBAND_FREQ_KEY] = baseband_freq self[COLOR_MODE_KEY] = COLOR_MODES[0][1] + self[COLOR_MODE_KEY] = DEFAULT_COLOR_MODE self[RUNNING_KEY] = True #setup the box with plot and controls self.control_panel = control_panel(self) @@ -237,16 +245,10 @@ class waterfall_window(wx.Panel, pubsub.pubsub): Does not affect the current data in the waterfall. """ if not len(self.samples): return - #get the peak level (max of the samples) - peak_level = numpy.max(self.samples) - #get the noise floor (averge the smallest samples) - noise_floor = numpy.average(numpy.sort(self.samples)[:len(self.samples)/4]) - #padding - noise_floor -= abs(noise_floor)*.5 - peak_level += abs(peak_level)*.1 + min_level, max_level = common.get_min_max_fft(self.samples) #set the range and level - self[REF_LEVEL_KEY] = peak_level - self[DYNAMIC_RANGE_KEY] = peak_level - noise_floor + self[DYNAMIC_RANGE_KEY] = common.get_clean_num(max_level - min_level) + self[REF_LEVEL_KEY] = DYNAMIC_RANGE_STEP*round(.5+max_level/DYNAMIC_RANGE_STEP) def handle_msg(self, msg): """ @@ -261,8 +263,8 @@ class waterfall_window(wx.Panel, pubsub.pubsub): self.samples = samples = numpy.fromstring(msg, numpy.float32)[:self.fft_size] #only take first frame num_samps = len(samples) #reorder fft - if self.real: samples = samples[:num_samps/2] - else: samples = numpy.concatenate((samples[num_samps/2:], samples[:num_samps/2])) + if self.real: samples = samples[:(num_samps+1)/2] + else: samples = numpy.concatenate((samples[num_samps/2+1:], samples[:(num_samps+1)/2])) #plot the fft self.plotter.set_samples( samples=samples, @@ -283,6 +285,8 @@ class waterfall_window(wx.Panel, pubsub.pubsub): #grid parameters sample_rate = self[SAMPLE_RATE_KEY] frame_rate = self[FRAME_RATE_KEY] + if frame_rate < 1.0 : + frame_rate = 1.0 baseband_freq = self[BASEBAND_FREQ_KEY] num_lines = self[NUM_LINES_KEY] y_divs = self[Y_DIVS_KEY]