voice keyer doing the right things, haven't tested sync detection state yet
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Mon, 14 Sep 2015 08:08:37 +0000 (08:08 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Mon, 14 Sep 2015 08:08:37 +0000 (08:08 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@2325 01035d8c-6547-0410-b346-abe4f91aad63

freedv-dev/src/dlg_ptt.cpp
freedv-dev/src/fdmdv2_main.cpp
freedv-dev/src/fdmdv2_main.h
freedv-dev/src/topFrame.cpp

index 8964587ae8fd0d1fbe93b9fca0e04f87e1f968b6..f9a88ce67d192c161e75c6a279af7c9a8eafc2bb 100644 (file)
@@ -62,19 +62,19 @@ ComPortsDlg::ComPortsDlg(wxWindow* parent, wxWindowID id, const wxString& title,
 
     wxStaticText *m_staticText28b = new wxStaticText(this, wxID_ANY, _("Wave File: "), wxDefaultPosition, wxDefaultSize, 0);
     staticBoxSizer28a->Add(m_staticText28b, 0, wxALIGN_CENTER_VERTICAL, 5);    
-    m_txtCtrlVoiceKeyerWaveFile = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(200,-1), 0);
+    m_txtCtrlVoiceKeyerWaveFile = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(400,-1), 0);
     m_txtCtrlVoiceKeyerWaveFile->SetToolTip(_("Wave file to play for Voice Keyer"));
     staticBoxSizer28a->Add(m_txtCtrlVoiceKeyerWaveFile, 0, 0, 5);
 
     wxStaticText *m_staticText28c = new wxStaticText(this, wxID_ANY, _("   Rx Pause: "), wxDefaultPosition, wxDefaultSize, 0);
     staticBoxSizer28a->Add(m_staticText28c, 0, wxALIGN_CENTER_VERTICAL , 5);
-    m_txtCtrlVoiceKeyerRxPause = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);
+    m_txtCtrlVoiceKeyerRxPause = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(40,-1), 0);
     m_txtCtrlVoiceKeyerRxPause->SetToolTip(_("How long to wait in Rx mode before repeat"));
     staticBoxSizer28a->Add(m_txtCtrlVoiceKeyerRxPause, 0, 0, 5);
 
     wxStaticText *m_staticText28d = new wxStaticText(this, wxID_ANY, _("   Repeats: "), wxDefaultPosition, wxDefaultSize, 0);
     staticBoxSizer28a->Add(m_staticText28d, 0, wxALIGN_CENTER_VERTICAL, 5);
-    m_txtCtrlVoiceKeyerRepeats = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);
+    m_txtCtrlVoiceKeyerRepeats = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(40,-1), 0);
     m_txtCtrlVoiceKeyerRepeats->SetToolTip(_("How long to wait in Rx mode before repeat"));
     staticBoxSizer28a->Add(m_txtCtrlVoiceKeyerRepeats, 0, 0, 5);
 
index 3dc38c907b97690965688c0a9f34831e71c839db..515f6127adea4004950f2037d09f17d993859c4f 100644 (file)
@@ -446,6 +446,7 @@ MainFrame::MainFrame(wxWindow *parent) : TopFrame(parent)
     //m_togTxID->Disable();
     m_togBtnAnalog->Disable();
     m_btnTogPTT->Disable();
+    m_togBtnVoiceKeyer->Disable();
     //m_togBtnALC->Disable();
 
     // squelch settings
@@ -1386,6 +1387,7 @@ int MainApp::FilterEvent(wxEvent& event)
                     frame->m_btnTogPTT->SetValue(true);
 
                 frame->togglePTT();
+                frame->VoiceKeyerProcessEvent(VK_SPACE_BAR);
 
                 return true; // absorb space so we don't toggle control with focus (e.g. Start)
 
@@ -1477,7 +1479,7 @@ void MainFrame::togglePTT(void) {
    + space bar turns keyer off
    + 5 secs of valid sync turns it off
 
-   [ ] complete state machine and builds OK
+   [X] complete state machine and builds OK
    [ ] file select dialog
    [ ] test all states
    [ ] restore size
@@ -1485,7 +1487,7 @@ void MainFrame::togglePTT(void) {
 
 void MainFrame::OnTogBtnVoiceKeyerClick (wxCommandEvent& event)
 {
-    VoiceKeyerStartTx();
+    VoiceKeyerProcessEvent(VK_START);
     event.Skip();
 }
 
@@ -1502,7 +1504,7 @@ int MainFrame::VoiceKeyerStartTx(void)
     g_sfPlayFile = sf_open(wxGetApp().m_txtVoiceKeyerWaveFile, SFM_READ, &sfInfo);
     if(g_sfPlayFile == NULL) {
         wxString strErr = sf_strerror(NULL);
-        wxMessageBox(strErr, wxT("Couldn't open voice keyer wave file"), wxOK);
+        wxMessageBox(strErr, wxT("Couldn't open:") + wxGetApp().m_txtVoiceKeyerWaveFile, wxOK);
         m_togBtnVoiceKeyer->SetValue(false);
         next_state = VK_IDLE;
     }
@@ -1522,20 +1524,21 @@ int MainFrame::VoiceKeyerStartTx(void)
 void MainFrame::VoiceKeyerProcessEvent(int vk_event) {
     int next_state = vk_state;
 
-   switch(vk_state) {
+    switch(vk_state) {
 
-   case VK_IDLE:
+    case VK_IDLE:
         if (vk_event == VK_START) {
             // sample these puppies at start just in case they are changed while VK running
             vk_rx_pause = wxGetApp().m_intVoiceKeyerRxPause;
             vk_repeats = wxGetApp().m_intVoiceKeyerRepeats;
+            fprintf(stderr, "vk_rx_pause: %d vk_repeats: %d\n", vk_rx_pause, vk_repeats);
 
             vk_repeat_counter = 0;
             next_state = VoiceKeyerStartTx();
         }
         break;
         
-    case VK_TX:
+     case VK_TX:
 
         // In this state we are transmitting and playing a wave file
         // to Mic In
@@ -1554,13 +1557,15 @@ void MainFrame::VoiceKeyerProcessEvent(int vk_event) {
                 m_togBtnVoiceKeyer->SetValue(false);
                 next_state = VK_IDLE;
             }
-            vk_rx_time = 0.0;
-            next_state = VK_RX;
+            else {
+                vk_rx_time = 0.0;
+                next_state = VK_RX;
+            }
         }
 
         break;
 
-    case VK_RX:
+     case VK_RX:
 
         // in this state we are receiving and waiting for
         // delay timer or valid sync
@@ -1583,7 +1588,7 @@ void MainFrame::VoiceKeyerProcessEvent(int vk_event) {
         }
         break;
 
-    case VK_SYNC_WAIT:
+     case VK_SYNC_WAIT:
 
         // In this state we wait for valid sync to last
         // VK_SYNC_WAIT_TIME seconds
@@ -1618,9 +1623,10 @@ void MainFrame::VoiceKeyerProcessEvent(int vk_event) {
         m_btnTogPTT->SetValue(false); togglePTT();
         m_togBtnVoiceKeyer->SetValue(false);
         next_state = VK_IDLE;
-    }
+   }
 
-    fprintf(stderr, "VoiceKeyerProcessEvent: vk_state: %d vk_event: %d next_state: %d\n", vk_state, vk_event, next_state);
+    if ((vk_event != VK_DT) || (vk_state != next_state))
+        fprintf(stderr, "VoiceKeyerProcessEvent: vk_state: %d vk_event: %d next_state: %d  vk_repeat_counter: %d\n", vk_state, vk_event, next_state, vk_repeat_counter);
     vk_state = next_state;
 }
 
@@ -2271,6 +2277,7 @@ void MainFrame::OnTogBtnOnOff(wxCommandEvent& event)
         m_togBtnAnalog->Enable();
         m_togBtnOnOff->SetLabel(wxT("Stop"));
         m_btnTogPTT->Enable();
+        m_togBtnVoiceKeyer->Enable();
 
         m_rb1600->Disable();
         m_rb700b->Disable();
@@ -2412,6 +2419,7 @@ void MainFrame::OnTogBtnOnOff(wxCommandEvent& event)
         //m_togTxID->Disable();
         m_togBtnAnalog->Disable();
         m_btnTogPTT->Disable();
+        m_togBtnVoiceKeyer->Disable();
         m_togBtnOnOff->SetLabel(wxT("Start"));
         m_rb1600->Enable();
         m_rb700b->Enable();
@@ -3768,6 +3776,18 @@ int MainFrame::PollUDP(void)
                 }  
                 sprintf(reply,"ok\n");
             }
+            if (bufstr.StartsWith(_("ptton"), &itemToSet)) {
+                // note: if options dialog is open this will get overwritten
+                m_btnTogPTT->SetValue(true);
+                togglePTT();
+                sprintf(reply,"ok\n");
+            }
+            if (bufstr.StartsWith(_("pttoff"), &itemToSet)) {
+                // note: if options dialog is open this will get overwritten
+                m_btnTogPTT->SetValue(false);
+                togglePTT();
+                sprintf(reply,"ok\n");
+            }
                 
         }
         else {
index 34773f8a1c177e6bd8ae3d949687a5a3034d7905..d5910b270a3eb9d2442a9e7629ddb08745073a5b 100644 (file)
@@ -451,6 +451,8 @@ class MainFrame : public TopFrame
     int                     PollUDP();
     bool                    m_schedule_restore;
 
+    void VoiceKeyerProcessEvent(int vk_event);
+
     protected:
 
 #ifdef _WIN32
@@ -530,7 +532,6 @@ class MainFrame : public TopFrame
         void OnIdle(wxIdleEvent &evt);
 #endif
 
-        void VoiceKeyerProcessEvent(int vk_event);
         int VoiceKeyerStartTx(void);
 
     private:
index 9a1298b78851f9b669e1db36075fac2dc50b629d..1bd7d4e814e61ff71473891aee2527e465429b91 100644 (file)
@@ -499,7 +499,7 @@ TopFrame::TopFrame(wxWindow* parent, wxWindowID id, const wxString& title, const
     m_togBtnOnOff->Connect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(TopFrame::OnTogBtnOnOff), NULL, this);
     m_togBtnSplit->Connect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(TopFrame::OnTogBtnSplitClick), NULL, this);
     m_togBtnAnalog->Connect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(TopFrame::OnTogBtnAnalogClick), NULL, this);
-    m_togBtnAnalog->Connect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(TopFrame::OnTogBtnVoiceKeyerClick), NULL, this);
+    m_togBtnVoiceKeyer->Connect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(TopFrame::OnTogBtnVoiceKeyerClick), NULL, this);
 #ifdef ALC
     m_togBtnALC->Connect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(TopFrame::OnTogBtnALCClick), NULL, this);
 #endif
@@ -554,7 +554,7 @@ TopFrame::~TopFrame()
     m_togBtnOnOff->Disconnect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(TopFrame::OnTogBtnOnOff), NULL, this);
     m_togBtnSplit->Disconnect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(TopFrame::OnTogBtnSplitClick), NULL, this);
     m_togBtnAnalog->Disconnect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(TopFrame::OnTogBtnAnalogClick), NULL, this);
-    m_togBtnAnalog->Disconnect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(TopFrame::OnTogBtnVoiceKeyerClick), NULL, this);
+    m_togBtnVoiceKeyer->Disconnect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(TopFrame::OnTogBtnVoiceKeyerClick), NULL, this);
 #ifdef ALC
     m_togBtnALC->Disconnect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(TopFrame::OnTogBtnALCClick), NULL, this);
 #endif