1 // ---------------------------------------------------------------------------- 2 // Copyright (C) 2014 3 // David Freese, W1HKJ 4 // 5 // This file is part of flrig. 6 // 7 // flrig is free software; you can redistribute it and/or modify 8 // it under the terms of the GNU General Public License as published by 9 // the Free Software Foundation; either version 3 of the License, or 10 // (at your option) any later version. 11 // 12 // flrig is distributed in the hope that it will be useful, 13 // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 // GNU General Public License for more details. 16 // 17 // You should have received a copy of the GNU General Public License 18 // along with this program. If not, see <http://www.gnu.org/licenses/>. 19 // ---------------------------------------------------------------------------- 20 21 #include <stdlib.h> 22 #include <iostream> 23 #include <fstream> 24 #include <vector> 25 #include <sys/types.h> 26 #include <sys/stat.h> 27 #include <stdlib.h> 28 #include <stdio.h> 29 #include <fcntl.h> 30 31 #include "threads.h" 32 #include "ptt.h" 33 #include "debug.h" 34 #include "rig_io.h" 35 #include "rig.h" 36 #include "support.h" 37 38 #include "gpio_ptt.h" 39 40 using namespace std; 41 42 // used for transceivers with a single vfo, called only by rigPTT 43 static XCVR_STATE fake_vfo; 44 showfreq(void *)45static void showfreq(void *) 46 { 47 FreqDispA->value(vfoA.freq); 48 } 49 fake_split(int on)50static void fake_split(int on) 51 { 52 if (on) { 53 fake_vfo = vfoA; 54 vfoA.freq = vfoB.freq; 55 selrig->set_vfoA(vfoA.freq); 56 Fl::awake(showfreq); 57 } else { 58 vfoA = fake_vfo; 59 selrig->set_vfoA(vfoA.freq); 60 Fl::awake(showfreq); 61 } 62 } 63 64 // add fake rit to this function and to set_vfoA ?? 65 rigPTT(bool on)66void rigPTT(bool on) 67 { 68 if (!on && progStatus.split && !selrig->can_split()) 69 fake_split(on); 70 71 std::string smode = ""; 72 if (selrig->modes_) smode = selrig->modes_[vfo->imode]; 73 if ((smode.find("CW") != std::string::npos) && progStatus.disable_CW_ptt) { 74 return; 75 } 76 77 // PTT priority: CAT; serial; separate serial; GPIO 78 79 if (progStatus.comm_catptt) { 80 selrig->set_PTT_control(on); 81 } else if (progStatus.comm_dtrptt || progStatus.comm_rtsptt) { 82 RigSerial->SetPTT(on); 83 } else if (SepSerial->IsOpen() && (progStatus.sep_dtrptt || progStatus.sep_rtsptt) ) { 84 SepSerial->SetPTT(on); 85 } else if (progStatus.gpio_ptt) { 86 set_gpio(on); 87 } else { 88 LOG_DEBUG("No PTT i/o connected"); 89 } 90 } 91