Allow use of the mouse wheel to adjust RX frequency.

ms-show-rx-offset-waterfall
Mooneer Salem 2024-06-15 01:32:28 -07:00
parent 06c2bc13d8
commit 29f724f0d2
5 changed files with 55 additions and 1 deletions

View File

@ -116,7 +116,7 @@ class PlotPanel : public wxPanel
virtual void OnMouseLeftDown(wxMouseEvent& event);
void OnMouseLeftUp(wxMouseEvent& event);
virtual void OnMouseRightDown(wxMouseEvent& event);
void OnMouseWheelMoved(wxMouseEvent& event);
virtual void OnMouseWheelMoved(wxMouseEvent& event);
void OnClose(wxCloseEvent& event ){ event.Skip(); }
virtual void OnSize( wxSizeEvent& event ) = 0;
void OnErase(wxEraseEvent& event);

View File

@ -22,8 +22,10 @@
#include <wx/wx.h>
#include "plot_spectrum.h"
#include "codec2_fdmdv.h" // for FDMDV_FCENTRE
void clickTune(float frequency); // callback to pass new click freq
extern float g_RxFreqOffsetHz;
BEGIN_EVENT_TABLE(PlotSpectrum, PlotPanel)
EVT_MOTION (PlotSpectrum::OnMouseMove)
@ -328,3 +330,27 @@ void PlotSpectrum::OnMouseRightDoubleClick(wxMouseEvent& event)
{
OnDoubleClickCommon(event);
}
//-------------------------------------------------------------------------
// OnMouseWheelMoved()
//-------------------------------------------------------------------------
void PlotSpectrum::OnMouseWheelMoved(wxMouseEvent& event)
{
float currRxFreq = FDMDV_FCENTRE - g_RxFreqOffsetHz;
float direction = 1.0;
if (event.GetWheelRotation() < 0)
{
direction = -1.0;
}
currRxFreq += direction * (event.GetLinesPerAction() * 10);
if (currRxFreq < MIN_F_HZ)
{
currRxFreq = MIN_F_HZ;
}
else if (currRxFreq > MAX_F_HZ)
{
currRxFreq = MAX_F_HZ;
}
clickTune(currRxFreq);
}

View File

@ -47,6 +47,7 @@ class PlotSpectrum : public PlotPanel
void draw(wxGraphicsContext* ctx);
void OnMouseLeftDoubleClick(wxMouseEvent& event);
void OnMouseRightDoubleClick(wxMouseEvent& event);
void OnMouseWheelMoved(wxMouseEvent& event);
private:
float m_rxFreq;

View File

@ -25,11 +25,13 @@
#include "os/os_interface.h"
#include "plot_waterfall.h"
#include "codec2_fdmdv.h" // for FDMDV_FCENTRE
// Tweak accordingly
#define Y_PER_SECOND (30)
extern float g_avmag[]; // av mag spec passed in to draw()
extern float g_RxFreqOffsetHz;
void clickTune(float frequency); // callback to pass new click freq
BEGIN_EVENT_TABLE(PlotWaterfall, PlotPanel)
@ -459,6 +461,30 @@ void PlotWaterfall::OnDoubleClickCommon(wxMouseEvent& event)
}
}
//-------------------------------------------------------------------------
// OnMouseWheelMoved()
//-------------------------------------------------------------------------
void PlotWaterfall::OnMouseWheelMoved(wxMouseEvent& event)
{
float currRxFreq = FDMDV_FCENTRE - g_RxFreqOffsetHz;
float direction = 1.0;
if (event.GetWheelRotation() < 0)
{
direction = -1.0;
}
currRxFreq += direction * (event.GetLinesPerAction() * 10);
if (currRxFreq < MIN_F_HZ)
{
currRxFreq = MIN_F_HZ;
}
else if (currRxFreq > MAX_F_HZ)
{
currRxFreq = MAX_F_HZ;
}
clickTune(currRxFreq);
}
//-------------------------------------------------------------------------
// OnMouseLeftDown()
//-------------------------------------------------------------------------

View File

@ -59,6 +59,7 @@ class PlotWaterfall : public PlotPanel
void plotPixelData();
void OnMouseLeftDoubleClick(wxMouseEvent& event);
void OnMouseRightDoubleClick(wxMouseEvent& event);
void OnMouseWheelMoved(wxMouseEvent& event);
private:
float m_dT;