From c878d80e28cd7f666eb861966dd841a225d28a38 Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Mon, 5 Aug 2013 17:06:22 -0700 Subject: [PATCH] Change gain on the fly. --- apps/modes_gui | 6 +++++- python/radio.py | 18 +++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/apps/modes_gui b/apps/modes_gui index b36ea96..e03f38d 100755 --- a/apps/modes_gui +++ b/apps/modes_gui @@ -139,7 +139,7 @@ class mainwindow(QtGui.QMainWindow): #hook up parameter-changed signals so we can change gain, rate, etc. while running self.ui.combo_rate.currentIndexChanged['QString'].connect(self.update_sample_rate) -# self.ui. + self.ui.line_gain.editingFinished.connect(self.update_gain) #hook up live data text box update signal self.live_data_changed_signal.connect(self.on_append_live_data) @@ -153,6 +153,10 @@ class mainwindow(QtGui.QMainWindow): if self.running: self._radio.set_rate(int(float(rate)*1e6)) + def update_gain(self): + if self.running: + self._radio.set_gain(float(self.ui.line_gain.text())) + ############ widget update functions for non-mapped widgets ############ def update_heading_widget(self, index): if index.model() is not None: diff --git a/python/radio.py b/python/radio.py index da0c6b0..d0d5f66 100644 --- a/python/radio.py +++ b/python/radio.py @@ -110,13 +110,17 @@ class modes_radio (gr.top_block, pubsub): parser.add_option_group(group) def live_source(self): - return self._options.source is 'uhd' or self._options.source is 'osmocom' + return self._options.source=="uhd" or self._options.source=="osmocom" def set_freq(self, freq): return self._u.set_center_freq(freq, 0) if self.live_source() else 0 def set_gain(self, gain): - return self._u.set_gain(gain) if self.live_source() else 0 + if self.live_source(): + self._u.set_gain(gain) + print "Gain is %f" % self.get_gain() + + return self.get_gain() def set_rate(self, rate): self._rx_path.set_rate(rate) @@ -126,13 +130,13 @@ class modes_radio (gr.top_block, pubsub): self._rx_path.set_threshold(threshold) def get_freq(self, freq): - return self._u.get_center_freq(freq, 0) if live_source() else 1090e6 + return self._u.get_center_freq(freq, 0) if self.live_source() else 1090e6 - def get_gain(self, gain): - return self._u.get_gain() if live_source() else 0 + def get_gain(self): + return self._u.get_gain() if self.live_source() else 0 - def get_rate(self, rate): - return self._u.get_rate() if live_source() else self._rate + def get_rate(self): + return self._u.get_rate() if self.live_source() else self._rate def _setup_source(self, options): if options.source == "uhd":