gr-fosphor: Add frequency range (center/span) awareness
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
This commit is contained in:
parent
ba6024ee5f
commit
6d9396f686
|
@ -4,7 +4,22 @@
|
|||
<key>fosphor_glfw_sink_c</key>
|
||||
<category>Instrumentation</category>
|
||||
<import>from gnuradio import fosphor</import>
|
||||
<make>fosphor.glfw_sink_c()</make>
|
||||
<make>fosphor.glfw_sink_c()
|
||||
self.$(id).set_frequency_range($freq_center, $freq_span)
|
||||
</make>
|
||||
<callback>set_frequency_range($freq_center, $freq_span)</callback>
|
||||
<param>
|
||||
<name>Center Frequency (Hz)</name>
|
||||
<key>freq_center</key>
|
||||
<value>0</value>
|
||||
<type>real</type>
|
||||
</param>
|
||||
<param>
|
||||
<name>Span (Hz)</name>
|
||||
<key>freq_span</key>
|
||||
<value>samp_rate</value>
|
||||
<type>real</type>
|
||||
</param>
|
||||
<sink>
|
||||
<name>in</name>
|
||||
<type>complex</type>
|
||||
|
|
|
@ -8,8 +8,22 @@
|
|||
<import>from gnuradio import fosphor</import>
|
||||
<make>#set $win = 'self._%s_win'%$id
|
||||
fosphor.qt_sink_c()
|
||||
self.$(id).set_frequency_range($freq_center, $freq_span)
|
||||
self._$(id)_win = sip.wrapinstance(self.$(id).pyqwidget(), Qt.QWidget)
|
||||
$(gui_hint()($win))</make>
|
||||
<callback>set_frequency_range($freq_center, $freq_span)</callback>
|
||||
<param>
|
||||
<name>Center Frequency (Hz)</name>
|
||||
<key>freq_center</key>
|
||||
<value>0</value>
|
||||
<type>real</type>
|
||||
</param>
|
||||
<param>
|
||||
<name>Span (Hz)</name>
|
||||
<key>freq_span</key>
|
||||
<value>samp_rate</value>
|
||||
<type>real</type>
|
||||
</param>
|
||||
<param>
|
||||
<name>GUI Hint</name>
|
||||
<key>gui_hint</key>
|
||||
|
|
|
@ -11,11 +11,25 @@ fosphor.wx_sink_c(
|
|||
size=$win_size,
|
||||
#end if
|
||||
)
|
||||
self.$(id).set_frequency_range($freq_center, $freq_span)
|
||||
#if not $grid_pos()
|
||||
$(parent).Add(self.$(id).win)
|
||||
#else
|
||||
$(parent).GridAdd(self.$(id).win, $(', '.join(map(str, $grid_pos()))))
|
||||
#end if</make>
|
||||
<callback>set_frequency_range($freq_center, $freq_span)</callback>
|
||||
<param>
|
||||
<name>Center Frequency (Hz)</name>
|
||||
<key>freq_center</key>
|
||||
<value>0</value>
|
||||
<type>real</type>
|
||||
</param>
|
||||
<param>
|
||||
<name>Span (Hz)</name>
|
||||
<key>freq_span</key>
|
||||
<value>samp_rate</value>
|
||||
<type>real</type>
|
||||
</param>
|
||||
<param>
|
||||
<name>Window Size</name>
|
||||
<key>win_size</key>
|
||||
|
|
|
@ -48,6 +48,11 @@ namespace gr {
|
|||
};
|
||||
|
||||
virtual void execute_ui_action(enum ui_action_t action) = 0;
|
||||
|
||||
virtual void set_frequency_range(const double center,
|
||||
const double span) = 0;
|
||||
virtual void set_frequency_center(const double center) = 0;
|
||||
virtual void set_frequency_span(const double span) = 0;
|
||||
};
|
||||
|
||||
} // namespace fosphor
|
||||
|
|
|
@ -53,7 +53,8 @@ const int base_sink_c_impl::k_db_per_div[] = {1, 2, 5, 10, 20};
|
|||
|
||||
|
||||
base_sink_c_impl::base_sink_c_impl()
|
||||
: d_db_ref(0), d_db_per_div_idx(3), d_active(false)
|
||||
: d_db_ref(0), d_db_per_div_idx(3), d_active(false),
|
||||
d_frequency()
|
||||
{
|
||||
/* Init FIFO */
|
||||
this->d_fifo = new fifo(2 * 1024 * 1024);
|
||||
|
@ -190,6 +191,13 @@ base_sink_c_impl::settings_apply(uint32_t settings)
|
|||
this->k_db_per_div[this->d_db_per_div_idx]
|
||||
);
|
||||
}
|
||||
|
||||
if (settings & SETTING_FREQUENCY_RANGE) {
|
||||
fosphor_set_frequency_range(this->d_fosphor,
|
||||
this->d_frequency.center,
|
||||
this->d_frequency.span
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -228,6 +236,28 @@ base_sink_c_impl::execute_ui_action(enum ui_action_t action)
|
|||
this->settings_mark_changed(SETTING_POWER_RANGE);
|
||||
}
|
||||
|
||||
void
|
||||
base_sink_c_impl::set_frequency_range(const double center, const double span)
|
||||
{
|
||||
this->d_frequency.center = center;
|
||||
this->d_frequency.span = span;
|
||||
this->settings_mark_changed(SETTING_FREQUENCY_RANGE);
|
||||
}
|
||||
|
||||
void
|
||||
base_sink_c_impl::set_frequency_center(const double center)
|
||||
{
|
||||
this->d_frequency.center = center;
|
||||
this->settings_mark_changed(SETTING_FREQUENCY_RANGE);
|
||||
}
|
||||
|
||||
void
|
||||
base_sink_c_impl::set_frequency_span(const double span)
|
||||
{
|
||||
this->d_frequency.span = span;
|
||||
this->settings_mark_changed(SETTING_FREQUENCY_RANGE);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
base_sink_c_impl::work(
|
||||
|
|
|
@ -60,6 +60,7 @@ namespace gr {
|
|||
enum {
|
||||
SETTING_DIMENSIONS = (1 << 0),
|
||||
SETTING_POWER_RANGE = (1 << 1),
|
||||
SETTING_FREQUENCY_RANGE = (1 << 2),
|
||||
};
|
||||
|
||||
uint32_t d_settings_changed;
|
||||
|
@ -77,6 +78,11 @@ namespace gr {
|
|||
int d_db_ref;
|
||||
int d_db_per_div_idx;
|
||||
|
||||
struct {
|
||||
double center;
|
||||
double span;
|
||||
} d_frequency;
|
||||
|
||||
protected:
|
||||
base_sink_c_impl();
|
||||
|
||||
|
@ -95,6 +101,11 @@ namespace gr {
|
|||
/* gr::fosphor::base_sink_c implementation */
|
||||
void execute_ui_action(enum ui_action_t action);
|
||||
|
||||
void set_frequency_range(const double center,
|
||||
const double span);
|
||||
void set_frequency_center(const double center);
|
||||
void set_frequency_span(const double span);
|
||||
|
||||
/* gr::sync_block implementation */
|
||||
int work (int noutput_items,
|
||||
gr_vector_const_void_star &input_items,
|
||||
|
|
|
@ -91,3 +91,9 @@ class wx_sink_c(gr.hier_block2):
|
|||
return gr.hier_block2.__getattr__(self, attr)
|
||||
except:
|
||||
return getattr(self.sink, attr)
|
||||
|
||||
def set_baseband_freq(self, bb_freq):
|
||||
self.set_frequency_center(bb_freq)
|
||||
|
||||
def set_sample_rate(self, sample_rate):
|
||||
self.set_frequency_span(sample_rate)
|
||||
|
|
Loading…
Reference in New Issue