From 7213ac987a9cb6f1dcff79242696f8c8f56a9daa Mon Sep 17 00:00:00 2001 From: drowe67 Date: Fri, 23 Nov 2012 19:51:46 +0000 Subject: [PATCH] modified Makefiles for DW cleanup, modified waterfall to handle slow waterfall updates where DT nmaps to less than one vertical pixel. Waterfall now covers 30 seconds. Works OK on Linux git-svn-id: https://svn.code.sf.net/p/freetel/code@1052 01035d8c-6547-0410-b346-abe4f91aad63 --- fdmdv2/src/Makefile.linux | 6 ++--- fdmdv2/src/Makefile.win32 | 3 +-- fdmdv2/src/fdmdv2_defines.h | 2 +- fdmdv2/src/fdmdv2_main.cpp | 6 +++-- fdmdv2/src/fdmdv2_plot_waterfall_linux.cpp | 27 ++++++++++++++++++++-- fdmdv2/src/fdmdv2_plot_waterfall_linux.h | 4 +++- 6 files changed, 36 insertions(+), 12 deletions(-) diff --git a/fdmdv2/src/Makefile.linux b/fdmdv2/src/Makefile.linux index bde04f04..058d8072 100644 --- a/fdmdv2/src/Makefile.linux +++ b/fdmdv2/src/Makefile.linux @@ -26,12 +26,10 @@ fdmdv2_plot_scatter.o \ fdmdv2_plot_spectrum.o \ fdmdv2_plot_waterfall_linux.o \ fdmdv2_pa_wrapper.o \ -dlg_about.o \ dlg_audiooptions.o \ -dlg_comports.o \ -dlg_options.o +dlg_comports.o -HDRS = fdmdv2_main.h fdmdv2_defines.h fdmdv2_plot.h fdmdv2_plot_scalar.h fdmdv2_plot_waterfall_linux.h fdmdv2_plot_scatter.h fdmdv2_plot_spectrum.h fdmdv2_pa_wrapper.h topFrame.h dlg_audiooptions.h +HDRS = dlg_audiooptions.h dlg_comports.h fdmdv2_main.h fdmdv2_defines.h fdmdv2_plot.h fdmdv2_plot_scalar.h fdmdv2_plot_waterfall_linux.h fdmdv2_plot_scatter.h fdmdv2_plot_spectrum.h fdmdv2_pa_wrapper.h all: freedv diff --git a/fdmdv2/src/Makefile.win32 b/fdmdv2/src/Makefile.win32 index 69260510..f536fe8f 100644 --- a/fdmdv2/src/Makefile.win32 +++ b/fdmdv2/src/Makefile.win32 @@ -26,12 +26,11 @@ fdmdv2_plot_scatter.o \ fdmdv2_plot_spectrum.o \ fdmdv2_plot_waterfall_linux.o \ fdmdv2_pa_wrapper.o \ -dlg_about.o \ dlg_audiooptions.o \ dlg_comports.o \ dlg_options.o -HDRS = fdmdv2_main.h fdmdv2_defines.h fdmdv2_plot.h fdmdv2_plot_scalar.h fdmdv2_plot_waterfall_linux.h fdmdv2_plot_scatter.h fdmdv2_plot_spectrum.h fdmdv2_pa_wrapper.h topFrame.h dlg_audiooptions.h +HDRS = dlg_audiooptions.h dlg_comports.h fdmdv2_main.h fdmdv2_defines.h fdmdv2_plot.h fdmdv2_plot_scalar.h fdmdv2_plot_waterfall_linux.h fdmdv2_plot_scatter.h fdmdv2_plot_spectrum.h fdmdv2_pa_wrapper.h topFrame.h dlg_audiooptions.h all: freedv diff --git a/fdmdv2/src/fdmdv2_defines.h b/fdmdv2/src/fdmdv2_defines.h index 576a7b8f..f71154d1 100644 --- a/fdmdv2/src/fdmdv2_defines.h +++ b/fdmdv2/src/fdmdv2_defines.h @@ -35,7 +35,7 @@ #define MIN_F_HZ 0 // min freq on Waterfall and Spectrum #define MAX_F_HZ 4000 // max freq on Waterfall and Spectrum #define STEP_F_HZ 500 // freq step on Waterfall and Spectrum graticule -#define WATERFALL_SECS_Y 5 // number of seconds respresented by y axis of waterfall +#define WATERFALL_SECS_Y 30 // number of seconds respresented by y axis of waterfall #define WATERFALL_SECS_STEP 5 // graticule y axis steps of waterfall #define DT 0.1 // time between real time graphing updates #define FS 8000 // FDMDV modem sample rate diff --git a/fdmdv2/src/fdmdv2_main.cpp b/fdmdv2/src/fdmdv2_main.cpp index a8602723..f6ed9c65 100644 --- a/fdmdv2/src/fdmdv2_main.cpp +++ b/fdmdv2/src/fdmdv2_main.cpp @@ -475,8 +475,10 @@ MainFrame::~MainFrame() void MainFrame::OnTimer(wxTimerEvent &evt) { - m_panelWaterfall->m_newdata = true; - m_panelWaterfall->Refresh(); + if (m_panelWaterfall->checkDT()) { + m_panelWaterfall->m_newdata = true; + m_panelWaterfall->Refresh(); + } m_panelSpectrum->m_newdata = true; m_panelSpectrum->Refresh(); diff --git a/fdmdv2/src/fdmdv2_plot_waterfall_linux.cpp b/fdmdv2/src/fdmdv2_plot_waterfall_linux.cpp index da8135c0..15c88eac 100644 --- a/fdmdv2/src/fdmdv2_plot_waterfall_linux.cpp +++ b/fdmdv2/src/fdmdv2_plot_waterfall_linux.cpp @@ -81,6 +81,8 @@ void PlotWaterfall::OnSize(wxSizeEvent& event) // we want a bit map the size of m_rGrid m_pBmp = new wxBitmap(m_rGrid.GetWidth(), m_rGrid.GetHeight(), 24); + + m_dT = DT; } //---------------------------------------------------------------- @@ -152,11 +154,30 @@ unsigned PlotWaterfall::heatmap(float val, float min, float max) return (b << 16) + (g << 8) + r; } +bool PlotWaterfall::checkDT(void) +{ + // Check dY is > 1 pixel before proceeding. For small screens + // and large WATERFALL_SECS_Y we might have less than one + // block per pixel. In this case increase m_dT and perform draw + // less often + + float px_per_sec = (float)m_rGrid.GetHeight() / WATERFALL_SECS_Y; + float dy = m_dT * px_per_sec; + + if (dy < 1.0) { + m_dT += DT; + return false; + } + else + return true; +} + //---------------------------------------------------------------- // draw() //---------------------------------------------------------------- void PlotWaterfall::draw(wxAutoBufferedPaintDC& dc) { + m_rCtrl = GetClientRect(); // m_rGrid is coords of inner window we actually plot to. We deflate it a bit @@ -178,6 +199,7 @@ void PlotWaterfall::draw(wxAutoBufferedPaintDC& dc) m_newdata = false; plotPixelData(); dc.DrawBitmap(*m_pBmp, PLOT_BORDER + XLEFT_OFFSET, PLOT_BORDER); + m_dT = DT; } else { @@ -254,7 +276,7 @@ void PlotWaterfall::plotPixelData() float intensity_per_dB; float px_per_sec; int index; - int dy; + float dy; int dy_blocks; int b; int px; @@ -274,7 +296,7 @@ void PlotWaterfall::plotPixelData() // determine dy, the height of one "block" px_per_sec = (float)m_rGrid.GetHeight() / WATERFALL_SECS_Y; - dy = DT * px_per_sec; + dy = m_dT * px_per_sec; // number of dy high blocks in spectrogram dy_blocks = m_rGrid.GetHeight()/ dy; @@ -349,6 +371,7 @@ void PlotWaterfall::plotPixelData() p = rowStart; p.OffsetY(data, 1); } + } //------------------------------------------------------------------------- diff --git a/fdmdv2/src/fdmdv2_plot_waterfall_linux.h b/fdmdv2/src/fdmdv2_plot_waterfall_linux.h index 3efbf3f0..4a1d2aed 100644 --- a/fdmdv2/src/fdmdv2_plot_waterfall_linux.h +++ b/fdmdv2/src/fdmdv2_plot_waterfall_linux.h @@ -39,7 +39,8 @@ class PlotWaterfall : public PlotPanel public: PlotWaterfall(wxFrame* parent); ~PlotWaterfall(); - + bool checkDT(void); + protected: unsigned m_heatmap_lut[256]; @@ -54,6 +55,7 @@ class PlotWaterfall : public PlotPanel void OnMouseDown(wxMouseEvent& event); private: + float m_dT; DECLARE_EVENT_TABLE() }; -- 2.25.1