fixed axis labels on waterfall and tweaked those on spectrum
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Wed, 24 Oct 2012 00:20:06 +0000 (00:20 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Wed, 24 Oct 2012 00:20:06 +0000 (00:20 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@801 01035d8c-6547-0410-b346-abe4f91aad63

fdmdv2/src/fdmdv2_defines.h
fdmdv2/src/fdmdv2_plot_spectrum.cpp
fdmdv2/src/fdmdv2_plot_waterfall_linux.cpp

index 637bd890b978ca13317a44b61003a548a2710bec..96bc9c4120eeb6a41f7ff0d5f31edda95ccfdbb1 100644 (file)
 
 #define FDMDV_NSPEC         512
 
-#define MIN_DB             -40.0    // minimum of spectram/waterfall DB axis
-#define MAX_DB              0.0
-#define STEP_DB             10.0
+#define MIN_AMP_DB         -40.0    // min of spectrogram/waterfall amplitude axis
+#define MAX_AMP_DB          0.0     // max of spectrogram/waterfall amplitude axis
+#define STEP_AMP_DB         5.0     // amplitude axis step
 #define BETA                0.1     // constant for time averageing spectrum data
-#define MIN_HZ              0       // min freq on Waterfall and Spectrum
-#define MAX_HZ              4000    // max freq on Waterfall and Spectrum
-#define STEP_HZ             500     // freq step on Waterfall and Spectrum graticule
+#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 DT                  0.1     // time between Waterfall updates
 #define FS                  8000    // FDMDV modem sample rate
index 2f278681982aa0f8330a8d2dd4c7cb228c8cca07..263f869716a198137397f3f89ef894575462419c 100644 (file)
@@ -69,7 +69,6 @@ PlotSpectrum::~PlotSpectrum()
 // OnSize()
 //----------------------------------------------------------------
 void PlotSpectrum::OnSize(wxSizeEvent& event) {
-    printf("PlotSpectrum::OnSize\n");
 }
 
 //----------------------------------------------------------------
@@ -77,7 +76,6 @@ void PlotSpectrum::OnSize(wxSizeEvent& event) {
 //----------------------------------------------------------------
 void PlotSpectrum::OnPaint(wxPaintEvent& event)
 {
-    printf("PlotSpectrum::OnPaint\n");
     wxAutoBufferedPaintDC dc(this);
     draw(dc);
 }
@@ -179,7 +177,7 @@ void PlotSpectrum::drawGraticule(wxAutoBufferedPaintDC&  dc)
     int      x, y, text_w, text_h;
     char     buf[15];
     wxString s;
-    float    f, dB, freq_hz_to_px, ampl_dB_to_px;
+    float    f, amplitude, freq_hz_to_px, ampl_dB_to_py;
 
     wxBrush ltGraphBkgBrush;
     ltGraphBkgBrush.SetStyle(wxBRUSHSTYLE_TRANSPARENT);
@@ -187,8 +185,8 @@ void PlotSpectrum::drawGraticule(wxAutoBufferedPaintDC&  dc)
     dc.SetBrush(ltGraphBkgBrush);
     dc.SetPen(wxPen(BLACK_COLOR, 1));
 
-    freq_hz_to_px = (float)m_rGrid.GetWidth()/(MAX_HZ-MIN_HZ);
-    ampl_dB_to_px = (float)m_rGrid.GetHeight()/(MAX_DB-MIN_DB);
+    freq_hz_to_px = (float)m_rGrid.GetWidth()/(MAX_F_HZ-MIN_F_HZ);
+    ampl_dB_to_py = (float)m_rGrid.GetHeight()/(MAX_AMP_DB-MIN_AMP_DB);
 
     // upper LH coords of plot area are (PLOT_BORDER + XLEFT_OFFSET, PLOT_BORDER)
     // lower RH coords of plot area are (PLOT_BORDER + XLEFT_OFFSET + m_rGrid.GetWidth(), 
@@ -198,7 +196,7 @@ void PlotSpectrum::drawGraticule(wxAutoBufferedPaintDC&  dc)
 
     dc.SetPen(m_penShortDash);
 
-    for(f=STEP_HZ; f<MAX_HZ; f+=STEP_HZ) {
+    for(f=STEP_F_HZ; f<MAX_F_HZ; f+=STEP_F_HZ) {
        x = f*freq_hz_to_px;
        x += PLOT_BORDER + XLEFT_OFFSET;
         dc.DrawLine(x, m_rGrid.GetHeight() + PLOT_BORDER, x, PLOT_BORDER);
@@ -209,12 +207,12 @@ void PlotSpectrum::drawGraticule(wxAutoBufferedPaintDC&  dc)
 
     // Horizontal gridlines
 
-    for(dB=MIN_DB; dB<MAX_DB; dB+=STEP_DB) {
-       y = m_rGrid.GetHeight() + dB*ampl_dB_to_px;
+    for(amplitude=MIN_AMP_DB; amplitude<=MAX_AMP_DB; amplitude+=STEP_AMP_DB) {
+       y = -amplitude*ampl_dB_to_py;
        y += PLOT_BORDER;
        dc.DrawLine(PLOT_BORDER + XLEFT_OFFSET, y, 
                    (m_rGrid.GetWidth() + PLOT_BORDER + XLEFT_OFFSET), y);
-        sprintf(buf, "%3.0fdB", dB);
+        sprintf(buf, "%3.0fdB", amplitude);
        GetTextExtent(buf, &text_w, &text_h);
         dc.DrawText(buf, PLOT_BORDER + XLEFT_OFFSET - text_w - XLEFT_TEXT_OFFSET, y-text_h/2);
    }
index bd14c932eb9fca76bc7576bcf014ff46697efba8..0705d292e808cced4c95713dca0177247429bfb7 100644 (file)
@@ -208,10 +208,10 @@ void PlotWaterfall::draw(wxAutoBufferedPaintDC& dc)
 //-------------------------------------------------------------------------
 void PlotWaterfall::drawGraticule(wxAutoBufferedPaintDC& dc)
 {
-    int p;
-    char buf[15];
-
+    int      x, y, text_w, text_h;
+    char     buf[15];
     wxString s;
+    float    f, time, freq_hz_to_px, time_s_to_py;
 
     wxBrush ltGraphBkgBrush;
     ltGraphBkgBrush.SetStyle(wxBRUSHSTYLE_TRANSPARENT);
@@ -219,6 +219,39 @@ void PlotWaterfall::drawGraticule(wxAutoBufferedPaintDC& dc)
     dc.SetBrush(ltGraphBkgBrush);
     dc.SetPen(wxPen(BLACK_COLOR, 1));
 
+    freq_hz_to_px = (float)m_rGrid.GetWidth()/(MAX_F_HZ-MIN_F_HZ);
+    time_s_to_py = (float)m_rGrid.GetHeight()/WATERFALL_SECS_Y;
+
+    // upper LH coords of plot area are (PLOT_BORDER + XLEFT_OFFSET, PLOT_BORDER)
+    // lower RH coords of plot area are (PLOT_BORDER + XLEFT_OFFSET + m_rGrid.GetWidth(), 
+    //                                   PLOT_BORDER + m_rGrid.GetHeight())
+
+    // Vertical gridlines
+
+    dc.SetPen(m_penShortDash);
+
+    for(f=STEP_F_HZ; f<MAX_F_HZ; f+=STEP_F_HZ) {
+       x = f*freq_hz_to_px;
+       x += PLOT_BORDER + XLEFT_OFFSET;
+        dc.DrawLine(x, m_rGrid.GetHeight() + PLOT_BORDER, x, PLOT_BORDER);
+        sprintf(buf, "%4.0fHz", f);
+       GetTextExtent(buf, &text_w, &text_h);
+        dc.DrawText(buf, x - text_w/2, m_rGrid.GetHeight() + PLOT_BORDER + YBOTTOM_TEXT_OFFSET);
+    }
+
+    // Horizontal gridlines
+
+    for(time=0; time<=WATERFALL_SECS_Y; time++) {
+       y = m_rGrid.GetHeight() - time*time_s_to_py;
+       y += PLOT_BORDER;
+       dc.DrawLine(PLOT_BORDER + XLEFT_OFFSET, y, 
+                   (m_rGrid.GetWidth() + PLOT_BORDER + XLEFT_OFFSET), y);
+        sprintf(buf, "%3.0fs", time);
+       GetTextExtent(buf, &text_w, &text_h);
+        dc.DrawText(buf, PLOT_BORDER + XLEFT_OFFSET - text_w - XLEFT_TEXT_OFFSET, y-text_h/2);
+   }
+
+#ifdef OLD
     // Vertical gridlines
     dc.SetPen(m_penShortDash);
     for(p = (PLOT_BORDER + XLEFT_OFFSET + GRID_INCREMENT); p < ((m_rGrid.GetWidth() - XLEFT_OFFSET) + GRID_INCREMENT); p += GRID_INCREMENT)
@@ -244,6 +277,7 @@ void PlotWaterfall::drawGraticule(wxAutoBufferedPaintDC& dc)
         sprintf(buf, "%1.0f", (double)((m_rGrid.GetHeight() - p) * 10));
         dc.DrawText(buf, XLEFT_TEXT_OFFSET, p);
     }
+#endif
 }
 
 //-------------------------------------------------------------------------
@@ -280,7 +314,7 @@ void PlotWaterfall::plotPixelData()
     // number of dy high blocks in spectrogram
     dy_blocks = m_rGrid.GetHeight()/ dy;
 
-    intensity_per_dB  = (float)256 /(MAX_DB - MIN_DB);
+    intensity_per_dB  = (float)256 /(MAX_AMP_DB - MIN_AMP_DB);
     spec_index_per_px = (float)FDMDV_NSPEC / (float) m_rGrid.GetWidth();
     
     /*
@@ -338,7 +372,7 @@ void PlotWaterfall::plotPixelData()
            index = px * spec_index_per_px;
            assert(index < FDMDV_NSPEC);
 
-           intensity = intensity_per_dB * (g_avmag[index] - MIN_DB);
+           intensity = intensity_per_dB * (g_avmag[index] - MIN_AMP_DB);
            if(intensity > 255) intensity = 255;
            if (intensity < 0) intensity = 0;
            //printf("%d %f %d \n", index, g_avmag[index], intensity);