gr-fosphor: Add 'SPACE' as a 'freeze' control to pause the processing

In background samples are just discarded.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
This commit is contained in:
Sylvain Munaut 2014-05-08 10:03:34 +02:00
parent 2fa5b6cf67
commit 2140ef7bb1
6 changed files with 20 additions and 4 deletions

View File

@ -53,6 +53,7 @@ namespace gr {
ZOOM_CENTER_DOWN,
RATIO_UP,
RATIO_DOWN,
FREEZE_TOGGLE,
};
virtual void execute_ui_action(enum ui_action_t action) = 0;

View File

@ -95,6 +95,9 @@ QGLSurface::keyPressEvent(QKeyEvent *ke)
case Qt::Key_E:
this->d_block->execute_ui_action(qt_sink_c_impl::RATIO_DOWN);
break;
case Qt::Key_Space:
this->d_block->execute_ui_action(qt_sink_c_impl::FREEZE_TOGGLE);
break;
}
}

View File

@ -55,7 +55,7 @@ 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_zoom_enabled(false), d_zoom_center(0.5), d_zoom_width(0.2),
d_ratio(0.35f), d_active(false),
d_ratio(0.35f), d_frozen(false), d_active(false),
d_frequency(), d_fft_window(gr::fft::window::WIN_BLACKMAN_hARRIS)
{
/* Init FIFO */
@ -151,9 +151,11 @@ base_sink_c_impl::render(void)
if (!len)
break;
/* Send to process */
data = this->d_fifo->read_peek(len, false);
fosphor_process(this->d_fosphor, data, len);
/* Send to process (if not frozen) */
if (!this->d_frozen) {
data = this->d_fifo->read_peek(len, false);
fosphor_process(this->d_fosphor, data, len);
}
/* Discard */
this->d_fifo->read_discard(len);
@ -326,6 +328,10 @@ base_sink_c_impl::execute_ui_action(enum ui_action_t action)
if (this->d_ratio > 0.2f)
this->d_ratio -= 0.05f;
break;
case FREEZE_TOGGLE:
this->d_frozen ^= 1;
break;
}
this->settings_mark_changed(

View File

@ -46,6 +46,7 @@ namespace gr {
/* Worker thread */
gr::thread::thread d_worker;
bool d_active;
bool d_frozen;
void worker();
static void _worker(base_sink_c_impl *obj);

View File

@ -108,6 +108,10 @@ glfw_sink_c_impl::glfw_cb_key(int key, int scancode, int action, int mods)
case GLFW_KEY_E:
this->execute_ui_action(RATIO_DOWN);
break;
case GLFW_KEY_SPACE:
this->execute_ui_action(FREEZE_TOGGLE);
break;
}
}

View File

@ -76,6 +76,7 @@ class wx_sink_c(gr.hier_block2):
ord('A'): base_sink_c.ZOOM_CENTER_DOWN,
ord('Q'): base_sink_c.RATIO_UP,
ord('E'): base_sink_c.RATIO_DOWN,
wx.WXK_SPACE: base_sink_c.FREEZE_TOGGLE,
}
k = evt.GetKeyCode()