apps/osmocom_fft: use reasonable defaults for gain & center frequency

This commit is contained in:
Dimitri Stolnikov 2013-10-26 14:51:05 +02:00
parent 71d8d02793
commit b7e2dd013b
1 changed files with 19 additions and 11 deletions

View File

@ -113,18 +113,26 @@ class app_top_block(stdgui2.std_top_block, pubsub):
options.samp_rate = self.src.get_sample_rates().start() options.samp_rate = self.src.get_sample_rates().start()
if options.gain is None: if options.gain is None:
# if no gain was specified, use the mid-point in dB gain = self.src.get_gain()
r = self.src.get_gain_range() if gain is None:
try: # empty gain range returned in file= mode # if no gain was specified, use the mid-point in dB
options.gain = float(r.start()+r.stop())/2 r = self.src.get_gain_range()
except RuntimeError: try: # empty gain range returned in file= mode
options.gain = 0 options.gain = float(r.start()+r.stop())/2
pass except RuntimeError:
options.gain = 0
pass
else:
options.gain = gain
if options.center_freq is None: if options.center_freq is None:
# if no freq was specified, use the mid-point in Hz freq = self.src.get_center_freq()
r = self.src.get_freq_range() if freq != 0:
options.center_freq = float(r.start()+r.stop())/2 options.center_freq = freq
else:
# if no freq was specified, use the mid-point in Hz
r = self.src.get_freq_range()
options.center_freq = float(r.start()+r.stop())/2
input_rate = self.src.set_sample_rate(options.samp_rate) input_rate = self.src.set_sample_rate(options.samp_rate)
self.src.set_bandwidth(input_rate) self.src.set_bandwidth(input_rate)
@ -260,7 +268,7 @@ class app_top_block(stdgui2.std_top_block, pubsub):
key=CENTER_FREQ_KEY, key=CENTER_FREQ_KEY,
minimum=self[FREQ_RANGE_KEY].start(), minimum=self[FREQ_RANGE_KEY].start(),
maximum=self[FREQ_RANGE_KEY].stop(), maximum=self[FREQ_RANGE_KEY].stop(),
num_steps=101, num_steps=1000,
) )
freq_hbox.AddSpacer(3) freq_hbox.AddSpacer(3)