#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
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
// 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)
{
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];
// 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;
}
}
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);
void OnMouseDown(wxMouseEvent& event);
private:
- float m_clickFreq;
DECLARE_EVENT_TABLE()
};
//-------------------------------------------------------------------------
void PlotWaterfall::OnMouseDown(wxMouseEvent& event)
{
- printf("PlotWaterfall::OnMouseDown\n");
m_mouseDown = true;
wxClientDC dc(this);
// 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;
}
}
public:
PlotWaterfall(wxFrame* parent);
~PlotWaterfall();
- void setClickFreq(float clickFreq) { m_clickFreq = clickFreq; }
- float getClickFreq(void) { return m_clickFreq; }
-
+
protected:
unsigned m_heatmap_lut[256];
void OnMouseDown(wxMouseEvent& event);
private:
- float m_clickFreq;
DECLARE_EVENT_TABLE()
};
+extern float g_RxFreqOffsetHz;
+
#endif //__FDMDV2_PLOT_WATERFALL__