From: drowe67 Date: Fri, 9 Nov 2012 01:56:45 +0000 (+0000) Subject: positioned squelch and snr static text correctly and stays centred X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=b80d950b4a988582e0ece25fbe373d1098fb488d;p=freetel-svn-tracking.git positioned squelch and snr static text correctly and stays centred git-svn-id: https://svn.code.sf.net/p/freetel/code@951 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/fdmdv2/src/Makefile.linux b/fdmdv2/src/Makefile.linux index 3fd0ced1..c3315f37 100644 --- a/fdmdv2/src/Makefile.linux +++ b/fdmdv2/src/Makefile.linux @@ -30,7 +30,7 @@ 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 +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 all: fdmdv2 diff --git a/fdmdv2/src/Makefile.win32 b/fdmdv2/src/Makefile.win32 index abb5b475..7cb3e668 100644 --- a/fdmdv2/src/Makefile.win32 +++ b/fdmdv2/src/Makefile.win32 @@ -30,7 +30,7 @@ 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 +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 all: fdmdv2 diff --git a/fdmdv2/src/fdmdv2_defines.h b/fdmdv2/src/fdmdv2_defines.h index 94f9a5c5..9857982d 100644 --- a/fdmdv2/src/fdmdv2_defines.h +++ b/fdmdv2/src/fdmdv2_defines.h @@ -71,6 +71,9 @@ #define BITS_PER_CODEC_FRAME (2 * FDMDV_BITS_PER_FRAME) #define BYTES_PER_CODEC_FRAME (BITS_PER_CODEC_FRAME / 8) +// Squelch +#define SQ_DEFAULT_SNR 4.0 + enum { ID_ROTATE_LEFT = wxID_HIGHEST + 1, diff --git a/fdmdv2/src/fdmdv2_main.cpp b/fdmdv2/src/fdmdv2_main.cpp index ed605938..600270dc 100644 --- a/fdmdv2/src/fdmdv2_main.cpp +++ b/fdmdv2/src/fdmdv2_main.cpp @@ -271,6 +271,14 @@ MainFrame::MainFrame(wxWindow *parent) : TopFrame(parent) // m_menuItemPlayAudioFile->Enable(false); + // default squelch position + + char sqsnr[15]; + sprintf(sqsnr, "%4.1f", SQ_DEFAULT_SNR); + wxString sqsnr_string(sqsnr); + m_sliderSQ->SetValue(SQ_DEFAULT_SNR*2); + m_textSQ->SetLabel(sqsnr_string); + #ifdef _USE_TIMER Bind(wxEVT_TIMER, &MainFrame::OnTimer, this); // ID_MY_WINDOW); m_plotTimer.SetOwner(this, ID_TIMER_WATERFALL); @@ -398,17 +406,17 @@ void MainFrame::OnTimer(wxTimerEvent &evt) // SNR text box and guage ------------------------------------------------------------ + float snr_limited = g_stats.snr_est; + + if (snr_limited < -9.0) snr_limited = -9.0; // stop text box overflow char snr[15]; - sprintf(snr, "%2.1f", g_stats.snr_est); + sprintf(snr, "%4.1f", snr_limited); wxString snr_string(snr); - //m_textSNR->ChangeValue(snr_string); m_textSNR->SetLabel(snr_string); - m_gaugeSNR->SetRange(20); // 0 to 20dB seems sensible - int snr_limited = g_stats.snr_est; - if (snr_limited < 0) snr_limited = 0; - if (snr_limited > 20) snr_limited = 20; - m_gaugeSNR->SetValue(snr_limited); + if (snr_limited < 0.0) snr_limited = 0; + if (snr_limited > 20.0) snr_limited = 20.0; + m_gaugeSNR->SetValue((int)(snr_limited+0.5)); // sync LED @@ -495,7 +503,7 @@ void MainFrame::OnPaint(wxPaintEvent& WXUNUSED(event)) void MainFrame::OnCmdSliderScroll(wxScrollEvent& event) { char sqsnr[15]; - sprintf(sqsnr, "%d", m_sliderSQ->GetValue()); + sprintf(sqsnr, "%4.1f", (float)m_sliderSQ->GetValue()/2.0); // 0.5 dB steps wxString sqsnr_string(sqsnr); m_textSQ->SetLabel(sqsnr_string); diff --git a/fdmdv2/src/topFrame.cpp b/fdmdv2/src/topFrame.cpp index 43f5e86d..7e9c31fc 100644 --- a/fdmdv2/src/topFrame.cpp +++ b/fdmdv2/src/topFrame.cpp @@ -157,7 +157,8 @@ TopFrame::TopFrame(wxWindow* parent, wxWindowID id, const wxString& title, const //------------------------------ // Box for S/N ratio (Numeric) //------------------------------ - m_textSNR = new wxStaticText(this, wxID_ANY, wxEmptyString, wxPoint(-1,-1), wxSize(35,25), wxTE_READONLY); + m_textSNR = new wxStaticText(this, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE); + //m_textSNR = new wxStaticText(this, wxID_ANY, wxEmptyString, wxPoint(-1,-1), wxSize(35,25), wxTE_READONLY); m_textSNR->SetToolTip(_("Show SNR ratio numerically.")); m_textSNR->SetMinSize(wxSize(35,25)); bSizer29->Add(m_textSNR, 0, wxALIGN_CENTER|wxALL, 1); @@ -230,46 +231,35 @@ TopFrame::TopFrame(wxWindow* parent, wxWindowID id, const wxString& title, const rightSizer = new wxBoxSizer(wxVERTICAL); //===================================================== - // Squelch Control box + // Squelch Slider Control //===================================================== wxStaticBoxSizer* sbSizer3; sbSizer3 = new wxStaticBoxSizer(new wxStaticBox(this, wxID_ANY, _("SQ")), wxVERTICAL); - m_sliderSQ = new wxSlider(this, wxID_ANY, SQ_DEFAULT_SNR, 0, 20, wxDefaultPosition, wxSize(-1,80), wxSL_AUTOTICKS|wxSL_INVERSE|wxSL_VERTICAL); + m_sliderSQ = new wxSlider(this, wxID_ANY, 0, 0, 40, wxDefaultPosition, wxSize(-1,80), wxSL_AUTOTICKS|wxSL_INVERSE|wxSL_VERTICAL); m_sliderSQ->SetToolTip(_("Set Squelch level in dB.")); - sbSizer3->Add(m_sliderSQ, 2, wxALIGN_CENTER|wxALL, 1); + sbSizer3->Add(m_sliderSQ, 1, wxALIGN_CENTER_HORIZONTAL, 0); //------------------------------ - // Squelch Toggle Checkbox + // Squelch Level static text box //------------------------------ - wxBoxSizer* bSizer131A; - bSizer131A = new wxBoxSizer(wxVERTICAL); - m_ckboxSQ = new wxCheckBox(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxCHK_2STATE); - m_ckboxSQ->SetToolTip(_("Activate/Deactivate Squelch")); + m_textSQ = new wxStaticText(this, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE); - bSizer131A->Add(m_ckboxSQ, 0, wxALIGN_CENTER|wxALL, 0); - //sbSizer3->Add(bSizer131A, 2, wxALIGN_CENTER|wxALL, 1); + sbSizer3->Add(m_textSQ, 0, wxALIGN_CENTER_HORIZONTAL, 0); //------------------------------ - // Squelch Level text box + // Squelch Toggle Checkbox //------------------------------ - wxBoxSizer* bSizer131B; - bSizer131B = new wxBoxSizer(wxVERTICAL); + m_ckboxSQ = new wxCheckBox(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxCHK_2STATE); + m_ckboxSQ->SetToolTip(_("Activate/Deactivate Squelch")); - // TODO: make this a config parameter? - char sqsnr[15]; - sprintf(sqsnr, "%2.0f", SQ_DEFAULT_SNR); - wxString sqsnr_string(sqsnr); - m_textSQ = new wxStaticText(this, wxID_ANY, sqsnr_string, wxPoint(-1,-1), wxSize(35,25)); - m_textSQ->SetMinSize(wxSize(35,25)); + sbSizer3->Add(m_ckboxSQ, 0, wxALIGN_CENTER_HORIZONTAL, 0); - bSizer131B->Add(m_textSQ, 0, wxALL, 0); - sbSizer3->Add(bSizer131B, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 1); - rightSizer->Add(sbSizer3, 2, wxALIGN_CENTER_HORIZONTAL|wxALL|wxEXPAND, 3); + rightSizer->Add(sbSizer3, 2, wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 0); //------------------------------ // Synch Indicator box diff --git a/fdmdv2/src/topFrame.h b/fdmdv2/src/topFrame.h index 3bb58856..16aca4e3 100644 --- a/fdmdv2/src/topFrame.h +++ b/fdmdv2/src/topFrame.h @@ -41,6 +41,7 @@ #include #include + /////////////////////////////////////////////////////////////////////////// #define ID_OPEN 1000 @@ -72,6 +73,7 @@ class TopFrame : public wxFrame wxTextCtrl* m_txtCtrl; wxSlider* m_sliderSQ; wxCheckBox* m_ckboxSQ; + wxStaticText* m_textSQ; wxStatusBar* m_statusBar1; wxRadioButton *m_rbSync;