Skip to content

Commit

Permalink
plotter: limit plot update rate
Browse files Browse the repository at this point in the history
Helps performance, and faster looks worse on the screen.

Signed-off-by: Jeff Long <[email protected]>
  • Loading branch information
willcode committed Jun 18, 2023
1 parent 09a8de5 commit 5e6855f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/applications/gqrx/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1796,8 +1796,8 @@ void MainWindow::setIqFftRate(int fps)
ui->plotter->setRunningState(true);
}

// Limit to 250 fps
if (interval > 3 && iq_fft_timer->isActive())
// Limit to 500 fps
if (interval > 1 && iq_fft_timer->isActive())
iq_fft_timer->setInterval(interval);

uiDockFft->setWfResolution(ui->plotter->getWfTimeRes());
Expand Down
5 changes: 5 additions & 0 deletions src/qtgui/dockfft.ui
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,11 @@
<property name="currentIndex">
<number>0</number>
</property>
<item>
<property name="text">
<string>500 fps</string>
</property>
</item>
<item>
<property name="text">
<string>250 fps</string>
Expand Down
6 changes: 5 additions & 1 deletion src/qtgui/plotter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ CPlotter::CPlotter(QWidget *parent) : QFrame(parent)

// always update waterfall
tlast_wf_ms = 0;
tlast_plot_drawn_ms = 0;
tlast_wf_drawn_ms = 0;
wf_valid_since_ms = 0;
msec_per_wfline = 0;
Expand Down Expand Up @@ -1246,7 +1247,8 @@ void CPlotter::draw(bool newData)
const double frameTime = 1.0 / (double)fft_rate;

// Redraw the plot if it is visible.
const bool doPlotter = !m_2DPixmap.isNull();
const bool doPlotter = (!m_2DPixmap.isNull()
&& tnow_ms >= tlast_plot_drawn_ms + PLOTTER_UPDATE_LIMIT_MS);

// Do not waste time with histogram calculations unless in this mode.
const bool doHistogram = m_PlotMode == PLOT_MODE_HISTOGRAM;
Expand Down Expand Up @@ -1523,6 +1525,8 @@ void CPlotter::draw(bool newData)
// get/draw the 2D spectrum
if (doPlotter)
{
tlast_plot_drawn_ms = tnow_ms;

m_2DPixmap.fill(PLOTTER_BGD_COLOR);
QPainter painter2(&m_2DPixmap);

Expand Down
2 changes: 2 additions & 0 deletions src/qtgui/plotter.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#define PEAK_CLICK_MAX_V_DISTANCE 20 //Maximum vertical distance of clicked point from peak
#define PEAK_WINDOW_HALF_WIDTH 10
#define PEAK_UPDATE_PERIOD 100 // msec
#define PLOTTER_UPDATE_LIMIT_MS 32 // 32ms = 31.25 Hz

#define MARKER_OFF std::numeric_limits<qint64>::min()

Expand Down Expand Up @@ -330,6 +331,7 @@ public slots:

// Waterfall averaging
quint64 tlast_wf_ms; // last time waterfall has been updated
quint64 tlast_plot_drawn_ms;// last time the plot was drawn
quint64 tlast_wf_drawn_ms; // last time waterfall was drawn
quint64 wf_valid_since_ms; // last time before action that invalidates time line
double msec_per_wfline{}; // milliseconds between waterfall updates
Expand Down

0 comments on commit 5e6855f

Please sign in to comment.