Frame rate limiter

This commit is contained in:
Charles J. Cliffe
2014-11-16 23:20:48 -05:00
parent 3614c2ad9f
commit a7d7ec0d93
9 changed files with 412 additions and 6 deletions
+8 -2
View File
@@ -22,7 +22,7 @@ wxEND_EVENT_TABLE()
WaterfallCanvas::WaterfallCanvas(wxWindow *parent, int *attribList) :
wxGLCanvas(parent, wxID_ANY, attribList, wxDefaultPosition, wxDefaultSize,
wxFULL_REPAINT_ON_RESIZE), parent(parent) {
wxFULL_REPAINT_ON_RESIZE), parent(parent), frameTimer(0) {
int in_block_size = BUF_SIZE / 2;
int out_block_size = FFT_SIZE;
@@ -35,6 +35,7 @@ WaterfallCanvas::WaterfallCanvas(wxWindow *parent, int *attribList) :
fft_floor_ma = fft_floor_maa = 0.0;
glContext = new WaterfallContext(this, &wxGetApp().GetContext(this));
timer.start();
}
WaterfallCanvas::~WaterfallCanvas() {
@@ -150,5 +151,10 @@ void WaterfallCanvas::setData(std::vector<signed char> *data) {
}
void WaterfallCanvas::OnIdle(wxIdleEvent &event) {
Refresh(false);
timer.update();
frameTimer += timer.lastUpdateSeconds();
if (frameTimer > 1.0/30.0) {
Refresh(false);
frameTimer = 0;
}
}