From: drowe67 Date: Mon, 25 Jun 2012 11:24:20 +0000 (+0000) Subject: added a few more plots, but need code for zoom and graticules X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=5e24d6536f8d5f6fab7ed168f8e8c97bfcc4cc09;p=freetel-svn-tracking.git added a few more plots, but need code for zoom and graticules git-svn-id: https://svn.code.sf.net/p/freetel/code@578 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/codec2-dev/fltk/fl_fdmdv.cxx b/codec2-dev/fltk/fl_fdmdv.cxx index bfd8c4a4..7ef14bcd 100644 --- a/codec2-dev/fltk/fl_fdmdv.cxx +++ b/codec2-dev/fltk/fl_fdmdv.cxx @@ -41,6 +41,7 @@ class Spectrum; class Waterfall; class Scatter; +class Scalar; char *fin_name = NULL; FILE *fin = NULL; @@ -50,6 +51,9 @@ Fl_Window *window; Spectrum *aSpectrum; Waterfall *aWaterfall; Scatter *aScatter; +Scalar *aTimingEst; +Scalar *aFreqEst; +Scalar *aSNR; float av_mag[FDMDV_NSPEC]; // shared between a few classes @@ -277,7 +281,6 @@ public: class Scatter: public Fl_Box { protected: - int first; COMP mem[SCATTER_MEM]; COMP new_samples[FDMDV_NSYM]; int prev_w, prev_h; @@ -355,6 +358,88 @@ public: }; + +// general purpose way of plotting scalar values that are +// updated once per frame + +class Scalar: public Fl_Box { +protected: + int x_max, y_max; + float *mem; /* array of x_max samples */ + float new_sample; + int index; + int prev_w, prev_h; + + void draw() { + float x_scale; + float y_scale; + int i, j, x1, y1; + + Fl_Box::draw(); + + /* detect resizing of window */ + + if ((h() != prev_h) || (w() != prev_w)) { + fl_color(FL_BLACK); + fl_rectf(x(),y(),w(),h()); + prev_h = h(); prev_w = w(); + } + + fl_push_clip(x(),y(),w(),h()); + + x_scale = (float)w()/x_max; + y_scale = (float)h()/(2.0*y_max); + + // erase last sample + + fl_color(FL_BLACK); + x1 = x_scale * index + x(); + y1 = -y_scale * mem[index] + y() + h()/2; + fl_point(x1, y1); + + // draw new sample + + fl_color(FL_GREEN); + x1 = x_scale * index + x(); + y1 = -y_scale * new_sample + y() + h()/2; + fl_point(x1, y1); + mem[index] = new_sample; + fl_pop_clip(); + + index++; + if (index >= x_max) + index = 0; + } + +public: + Scalar(int x, int y, int w, int h, int x_max_, int y_max_, char name[]): Fl_Box(x, y, w, h, name) + { + int i; + + align(FL_ALIGN_TOP); + labelsize(10); + + x_max = x_max_; y_max = y_max_; + mem = new float[x_max]; + for(i=0; iadd_new_samples(stats.rx_symbols); + aTimingEst->add_new_sample(stats.rx_timing); + aFreqEst->add_new_sample(stats.foff); + aSNR->add_new_sample(stats.snr_est); // update plots every DT @@ -402,6 +490,9 @@ void idle(void*) { aSpectrum->redraw(); aWaterfall->redraw(); aScatter->redraw(); + aTimingEst->redraw(); + aFreqEst->redraw(); + aSNR->redraw(); } } usleep(20000); @@ -447,9 +538,12 @@ int main(int argc, char **argv) { window = new Fl_Window(W, SP+H2+SP+SP+H2+SP, "fl_fmdv"); window->size_range(100, 100); window->resizable(); - aSpectrum = new Spectrum(SP, SP, 2*W3-2*SP, H2); - aWaterfall = new Waterfall(SP, SP+H2+SP+SP, 2*W3-2*SP, H2); - aScatter = new Scatter(2*W3, SP, W3, H2); + aSpectrum = new Spectrum(SP, SP, W3-2*SP, H2); + aWaterfall = new Waterfall(SP, SP+H2+SP+SP, W3-2*SP, H2); + aScatter = new Scatter(W3+SP, SP, W3-2*SP, H2); + aTimingEst = new Scalar(W3+SP, SP+H2+SP+SP, W3-2*SP, H2, 100, 80, "Timing Est"); + aFreqEst = new Scalar(2*W3+SP, SP, W3-2*SP, H2, 100, 100, "Frequency Est"); + aSNR = new Scalar(2*W3+SP, SP+H2+SP+SP, W3-2*SP, H2, 100, 40, "SNR"); fdmdv = fdmdv_create(); Fl::add_idle(idle);