gr-wxgui: adds stripchart trigger mode to graphics sinks
[debian/gnuradio] / gr-wxgui / src / python / common.py
index a75f6810d8ce0732a7d9984ba8076ffd5566edd9..3641ae6448f7ff4f4203c82e2210ea135d8d4579 100644 (file)
@@ -25,6 +25,8 @@
 import wx
 from gnuradio import gr
 
+RUN_ALWAYS = gr.prefs().get_bool ('wxgui', 'run_always', False)
+
 class wxgui_hb(object):
        """
        The wxgui hier block helper/wrapper class:
@@ -47,7 +49,10 @@ class wxgui_hb(object):
                        assert points[0] == self or points[0][0] == self
                        copy = gr.copy(self._hb.input_signature().sizeof_stream_item(0))
                        handler = self._handler_factory(copy.set_enabled)
-                       handler(False) #initially disable the copy block
+                       if RUN_ALWAYS == False:
+                               handler(False) #initially disable the copy block
+                       else:
+                               handler(True) #initially enable the copy block
                        self._bind_to_visible_event(win=self.win, handler=handler)
                        points = list(points)
                        points.insert(1, copy) #insert the copy block into the chain
@@ -67,7 +72,10 @@ class wxgui_hb(object):
                        if cache[0] == visible: return
                        cache[0] = visible
                        #print visible, handler
-                       handler(visible)
+                       if RUN_ALWAYS == False:
+                               handler(visible)
+                       else:
+                               handler(True)
                return callback
 
        @staticmethod
@@ -216,12 +224,13 @@ def get_min_max(samples):
        @param samples the array of real values
        @return a tuple of min, max
        """
-       scale_factor = 3
+       factor = 2.0
        mean = numpy.average(samples)
-       rms = numpy.max([scale_factor*((numpy.sum((samples-mean)**2)/len(samples))**.5), .1])
-       min_val = mean - rms
-       max_val = mean + rms
-       return min_val, max_val
+       std = numpy.std(samples)
+       fft = numpy.abs(numpy.fft.fft(samples - mean))
+       envelope = 2*numpy.max(fft)/len(samples)
+       ampl = max(std, envelope) or 0.1
+       return mean - factor*ampl, mean + factor*ampl
 
 def get_min_max_fft(fft_samps):
        """