rx click tune using globals resulted in a cleaner design although I would prefer...
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Wed, 21 Nov 2012 04:57:41 +0000 (04:57 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Wed, 21 Nov 2012 04:57:41 +0000 (04:57 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@1042 01035d8c-6547-0410-b346-abe4f91aad63

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

index 7a53eaa8e4760e2ddd2a17dd3cf1eed72d04c5f2..b74966d0c0e6f7057ab7b6d01a729a994e8d5177 100644 (file)
@@ -31,7 +31,7 @@
 #define MIN_MAG_DB        -40.0     // min of spectrogram/waterfall magnitude axis
 #define MAX_MAG_DB          0.0     // max of spectrogram/waterfall magnitude axis
 #define STEP_MAG_DB         5.0     // magnitude axis step
-#define BETA                0.1     // constant for time averageing spectrum data
+#define BETA                0.1     // constant for time averaging spectrum data
 #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
index 1c2f474168ba2108871c845ae1e4134ede468e36..7a8139f27410d1d5c26f21b1f81d0dd0e4f200e8 100644 (file)
@@ -89,6 +89,9 @@ int sc1, sc2;
 int g_outfifo2_empty;
 
 // experimental mutex to make sound card callbacks mutually exclusive
+// TODO: review code and see if we need this any more, as fifos should
+// now be thread safe
+
 wxMutex g_mutexProtectingCallbackData;
 
 // WxWidgets - initialize the application
@@ -210,14 +213,12 @@ MainFrame::MainFrame(wxWindow *parent) : TopFrame(parent)
         // Add Waterfall Plot window
         m_panelWaterfall = new PlotWaterfall((wxFrame*) m_auiNbookCtrl);
         m_auiNbookCtrl->AddPage(m_panelWaterfall, _("Waterfall"), true, wxNullBitmap);
-        m_panelWaterfall->setClickFreq(FDMDV_FCENTRE);
     }
     if(wxGetApp().m_show_spect)
     {
         // Add Spectrum Plot window
         m_panelSpectrum = new PlotSpectrum((wxFrame*) m_auiNbookCtrl);
         m_auiNbookCtrl->AddPage(m_panelSpectrum, _("Spectrum"), true, wxNullBitmap);
-        m_panelSpectrum->setClickFreq(FDMDV_FCENTRE);
     }
     if(wxGetApp().m_show_scatter)
     {
@@ -460,31 +461,6 @@ void MainFrame::OnTimer(wxTimerEvent &evt)
     m_panelScatter->add_new_samples(g_stats.rx_symbols);
     m_panelScatter->Refresh();
 
-    // This is a convenient time to update the click-tune frequency
-    // The demod is hard-wired to expect a centre frequency of
-    // FDMDV_FCENTRE.  So we want to take the signal centered on the
-    // click tune freq and re-centre it on FDMDV_FCENTRE.  For example
-    // if the click tune freq is 1500Hz, and FDMDV_CENTRE is 1200 Hz,
-    // we need to shift the input signal centred on 1500Hz down to
-    // 1200Hz, an offset of -300Hz.
-
-    // The current design has the last click freq stored in both the
-    // Waterfall and the Spectrum.  This is messy.  What would be
-    // better is the musedown event setting the global freq offset
-    // directl, or communicating via an event to this thread.
-    
-    if (m_auiNbookCtrl->GetCurrentPage() == m_panelWaterfall) {
-        g_RxFreqOffsetHz = FDMDV_FCENTRE - m_panelWaterfall->getClickFreq();
-        m_panelSpectrum->setClickFreq(m_panelWaterfall->getClickFreq());
-        //printf("Waterfall g_RxFreqOffsetHz: %f\n", g_RxFreqOffsetHz);
-    }
-        
-    if (m_auiNbookCtrl->GetCurrentPage() == m_panelSpectrum) {
-        g_RxFreqOffsetHz = FDMDV_FCENTRE - m_panelSpectrum->getClickFreq();
-        m_panelWaterfall->setClickFreq(m_panelSpectrum->getClickFreq());
-        //printf("Spectrum g_RxFreqOffsetHz: %f\n", g_RxFreqOffsetHz);
-    }
-        
     // Oscilliscope type speech plots -------------------------------------------------------
 
     short speechInPlotSamples[WAVEFORM_PLOT_BUF];
index 0a18b9b6c37e925437ed1161995ecffefb98107a..4103ba034f05b2b02609c7e36dbf3f229441f7a1 100644 (file)
@@ -217,7 +217,9 @@ void PlotSpectrum::OnMouseDown(wxMouseEvent& event)
     // valid click if inside of plot
     if ((pt.x >= 0) && (pt.x <= m_rGrid.GetWidth()) && (pt.y >=0) && (pt.y < m_rGrid.GetHeight())) {
         float freq_hz_to_px = (float)m_rGrid.GetWidth()/(MAX_F_HZ-MIN_F_HZ);
-        m_clickFreq = (float)pt.x/freq_hz_to_px;
-        printf("PlotSpectrum::OnMouseDown m_clickFreq: %f\n", m_clickFreq);
+        float clickFreq = (float)pt.x/freq_hz_to_px;
+
+        // see PlotWaterfall::OnMouseDown()
+        g_RxFreqOffsetHz = FDMDV_FCENTRE - clickFreq;
     }
 }
index b7187f706cb987965448cda3092ed29e18625914..6a037636883f5dc7ee590b0fd4ff02b689fc9c0e 100644 (file)
@@ -33,9 +33,6 @@ class PlotSpectrum : public PlotPanel
         PlotSpectrum(wxFrame* parent);
         ~PlotSpectrum();
 
-        void        setClickFreq(float clickFreq) { m_clickFreq = clickFreq; }
-        float       getClickFreq(void) { return m_clickFreq; }
-
     protected:
         void        OnPaint(wxPaintEvent& event);
         void        OnSize(wxSizeEvent& event);
@@ -45,7 +42,6 @@ class PlotSpectrum : public PlotPanel
         void        OnMouseDown(wxMouseEvent& event);
 
    private:
-        float       m_clickFreq;
 
         DECLARE_EVENT_TABLE()
 };
index 9a019da1042a44c5369028d328b4b39aa252024a..421d3778389189e8fd96e7780c7f627bc1be87c1 100644 (file)
@@ -361,7 +361,6 @@ void PlotWaterfall::plotPixelData()
 //-------------------------------------------------------------------------
 void PlotWaterfall::OnMouseDown(wxMouseEvent& event)
 {
-    printf("PlotWaterfall::OnMouseDown\n");
     m_mouseDown = true;
     wxClientDC dc(this);
 
@@ -374,7 +373,18 @@ void PlotWaterfall::OnMouseDown(wxMouseEvent& event)
     // valid click if inside of plot
     if ((pt.x >= 0) && (pt.x <= m_rGrid.GetWidth()) && (pt.y >=0) && (pt.y < m_rGrid.GetHeight())) {
         float freq_hz_to_px = (float)m_rGrid.GetWidth()/(MAX_F_HZ-MIN_F_HZ);
-        m_clickFreq = (float)pt.x/freq_hz_to_px;
-        printf("PlotWaterfall::OnMouseDown m_clickFreq: %f\n", m_clickFreq);
+        float clickFreq = (float)pt.x/freq_hz_to_px;
+
+        // The demod is hard-wired to expect a centre frequency of
+        // FDMDV_FCENTRE.  So we want to take the signal centered on the
+        // click tune freq and re-centre it on FDMDV_FCENTRE.  For example
+        // if the click tune freq is 1500Hz, and FDMDV_CENTRE is 1200 Hz,
+        // we need to shift the input signal centred on 1500Hz down to
+        // 1200Hz, an offset of -300Hz.
+
+        // modifying a global is messy but an easy way to communicate
+        // to the tx/rx thread
+
+        g_RxFreqOffsetHz = FDMDV_FCENTRE - clickFreq;
     }
 }
index b54270c6c99f8ffcb0a2e8d8edc00f59484e71a1..ad7c2614c69654ad1b0e493fc38488a5ae7623f3 100644 (file)
@@ -39,9 +39,7 @@ class PlotWaterfall : public PlotPanel
     public:
         PlotWaterfall(wxFrame* parent);
         ~PlotWaterfall();
-        void        setClickFreq(float clickFreq) { m_clickFreq = clickFreq; }
-        float       getClickFreq(void) { return m_clickFreq; }
-
     protected:
         unsigned    m_heatmap_lut[256];
 
@@ -56,9 +54,10 @@ class PlotWaterfall : public PlotPanel
         void        OnMouseDown(wxMouseEvent& event);
 
     private:
-        float       m_clickFreq;
 
         DECLARE_EVENT_TABLE()
 };
 
+extern float g_RxFreqOffsetHz;
+
 #endif //__FDMDV2_PLOT_WATERFALL__