From 745154f614508fd25f0080191e9eaa69d654aaed Mon Sep 17 00:00:00 2001 From: drowe67 Date: Fri, 15 Jun 2012 22:23:23 +0000 Subject: [PATCH] first pass at real time spectrum display git-svn-id: https://svn.code.sf.net/p/freetel/code@552 01035d8c-6547-0410-b346-abe4f91aad63 --- codec2-dev/fltk/Makefile | 11 ++ codec2-dev/fltk/fl_fdmdv.cxx | 189 +++++++++++++++++++++++++++++++++++ 2 files changed, 200 insertions(+) create mode 100644 codec2-dev/fltk/Makefile create mode 100644 codec2-dev/fltk/fl_fdmdv.cxx diff --git a/codec2-dev/fltk/Makefile b/codec2-dev/fltk/Makefile new file mode 100644 index 00000000..0a2b7041 --- /dev/null +++ b/codec2-dev/fltk/Makefile @@ -0,0 +1,11 @@ +FLTK_CFLAGS += $(shell fltk-config --ldstaticflags) + +LC2POC_C = fl_fdmdv.cxx + +all: fl_fdmdv + +fl_fdmdv: Makefile $(LC2POC_C) + g++ $(LC2POC_C) -I../src/ -o fl_fdmdv $(FLTK_CFLAGS) ../src/.libs/libcodec2.a + +clean: + rm -f fl_fdmdv diff --git a/codec2-dev/fltk/fl_fdmdv.cxx b/codec2-dev/fltk/fl_fdmdv.cxx new file mode 100644 index 00000000..aba5fbcd --- /dev/null +++ b/codec2-dev/fltk/fl_fdmdv.cxx @@ -0,0 +1,189 @@ +/* + fl_fdmdv.cxx + Created 14 June 2012 + David Rowe + + Fltk based GUI program to prototype spectrum, waterfall, and other + FDMDV GUI displays. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "fdmdv.h" + +#define MIN_DB -40.0 +#define MAX_DB 0.0 +#define BETA 0.1 +#define MIN_HZ 0 +#define MAX_HZ 4000 + +class Spectrum; +char *fin_name = NULL; +FILE *fin = NULL; +struct FDMDV *fdmdv; +Fl_Group *agroup; +Fl_Window *window; +Spectrum *aSpectrum; + + +class Spectrum: public Fl_Box { +protected: + void draw() { + float x_px_per_point = 0.0; + float y_px_per_dB = 0.0; + int i, x1, y1, x2, y2, len; + float mag1, mag2; + char label[20]; + float px_per_hz; + + Fl_Box::draw(); + fl_color(FL_BLACK); + fl_rectf(x(),y(),w(),h()); + fl_color(FL_GREEN); + fl_line_style(FL_SOLID); + + fl_push_clip(x(),y(),w(),h()); + //printf("%d %d\n", w(), h()); + x_px_per_point = (float)w()/FDMDV_NSPEC; + y_px_per_dB = (float)h()/(MAX_DB - MIN_DB); + + // plot spectrum + + for(i=0; inew_data(rx_spec); + aSpectrum->redraw(); + usleep(20000); + } +} + +int arg_callback(int argc, char **argv, int &i) { + if (argv[i][1] == 'i') { + if ((i+1) >= argc) + return 0; + fin_name = argv[i+1]; + i += 2; + return 2; + } + return 0; +} + +int main(int argc, char **argv) { + int ret; + int i = 1; + + Fl::args(argc,argv,i,arg_callback); + + if (argc != 3) { + printf("usage: %s -i inputFdmdvRawFile\n", argv[0]); + exit(0); + } + + fin = fopen(fin_name,"rb"); + if (fin == NULL) { + fprintf(stderr, "Error opening input fdmdv raw file %s\n", argv[1]); + exit(1); + } + + window = new Fl_Window(800, 600, "fl_fmdv"); + window->size_range(400,200); + aSpectrum = new Spectrum(20, 20, 800-40, 300); + window->add_resizable(*aSpectrum); + fdmdv = fdmdv_create(); + + Fl::add_idle(idle); + + window->end(); + + window->show(argc, argv); + ret = Fl::run(); + + fdmdv_destroy(fdmdv); + fclose(fin); + + return ret; +} -- 2.25.1