From 639e14e2a563215eae3f0e5608091d816bfb6f9c Mon Sep 17 00:00:00 2001 From: Philip Balister Date: Fri, 29 Apr 2011 14:51:07 -0400 Subject: qtqui-sink : Do not run the FFT unless updating the display. Signed-off-by: Philip Balister --- gr-qtgui/include/qtgui_sink_c.h | 3 +++ gr-qtgui/lib/qtgui_sink_c.cc | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/gr-qtgui/include/qtgui_sink_c.h b/gr-qtgui/include/qtgui_sink_c.h index b04706b14..28c0f1372 100644 --- a/gr-qtgui/include/qtgui_sink_c.h +++ b/gr-qtgui/include/qtgui_sink_c.h @@ -29,6 +29,7 @@ #include #include #include +#include #include "SpectrumGUIClass.h" class qtgui_sink_c; @@ -78,6 +79,8 @@ private: double d_center_freq; double d_bandwidth; std::string d_name; + gruel::high_res_timer_type d_last_update; + bool d_update_active; bool d_shift; gri_fft_complex *d_fft; diff --git a/gr-qtgui/lib/qtgui_sink_c.cc b/gr-qtgui/lib/qtgui_sink_c.cc index 965be0773..625ddbdf6 100644 --- a/gr-qtgui/lib/qtgui_sink_c.cc +++ b/gr-qtgui/lib/qtgui_sink_c.cc @@ -125,6 +125,9 @@ qtgui_sink_c::initialize() // initialize update time to 10 times a second set_update_time(0.1); + + d_last_update = gruel::high_res_timer_now(); + d_update_active = false; } @@ -270,6 +273,14 @@ qtgui_sink_c::general_work (int noutput_items, unsigned int datasize = noutput_items - i; unsigned int resid = d_fftsize-d_index; + if (!d_update_active && (gruel::high_res_timer_now() - d_last_update) < d_update_time) { + consume_each(noutput_items); + return noutput_items; + } else { + d_last_update = gruel::high_res_timer_now(); + d_update_active = true; + } + // If we have enough input for one full FFT, do it if(datasize >= resid) { const gruel::high_res_timer_type currentTime = gruel::high_res_timer_now(); @@ -284,6 +295,7 @@ qtgui_sink_c::general_work (int noutput_items, d_main_gui->UpdateWindow(true, d_fft->get_outbuf(), d_fftsize, NULL, 0, (float*)d_residbuf, d_fftsize, currentTime, true); + d_update_active = false; } // Otherwise, copy what we received into the residbuf for next time else { -- cgit