/* twpsk - PSK31 for Linux with a Lesstif interface * Copyright (C) 1999 Ted Williams WA0EIR * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be * useful, but WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, * USA. * * Version: 2.1 - Aug 2002 * * Portions derived from: * Soundcard-based implementation of the PSK31 HF keyboard-to-keyboard mode * Copyright (C) 1998 Hansi Reiser, DL9RDZ */ #include "GUI.h" #include "../server/server.h" #include "twpskWids.h" #include "twpskCB.h" #include "twpskScope.h" #include "twpskDisp.h" #include "callbox.h" #include int OPTnew = 0; // TODO: rausdamit (-> filter and sync alg selection for RX) #if 0 #define DMA_BUF_BITS 6 // Audio parameters int full_duplex=0; static int audio_fd; #endif static char *sound_device="/dev/audio"; /* Globals */ int transmit=0; AppRes appRes; Position winlocs[MAX_DECODERS][2]; Wids pskwids; Scope scope; Disp disp; TwpskCB twpskCB; XtAppContext ac; /* @@@ DL9RDZ */ #include "catWids.h" #include "decoderWids.h" Cat catwids; DecoderWid decoderWids[MAX_DECODERS]; /* * main - main function for twpsk */ int main(int argc, char *argv[]) { Widget shell, temp; Widget noTwpskMessBox; int val; int height = 0, width = 0; XmString messStr; char *str = ""; Atom wm_delete_win; String fallback_resources[] = { "twpsk.noTwpskMessBox*forground: black", "twpsk.noTwpskMessBox*background: tan", "twpsk.noTwpskMessBox.messageString: Can't find the resource file, Twpsk.", NULL }; XtResource appRes_desc[] = { { XmNbuttonNames, /* Resource Name */ XmCButtonNames, /* Resource Class */ XmRString, /* Resource Data Type */ sizeof (char), /* Size of Resource */ XtOffsetOf (AppRes, buttonNames), /* Offset into Struct */ XtRString, /* Default Data Type */ (XtPointer) "Bogus Name" /* Default Value */ }, { XmNrxFreq, /* Same as above */ XmCRxFreq, XmRFloat, sizeof (float), XtOffsetOf (AppRes, rxFreq), XtRFloat, (XtPointer) 0 }, { XmNtxFreq, /* Same as above */ XmCTxFreq, XmRFloat, sizeof (float), XtOffsetOf (AppRes, txFreq), XtRFloat, (XtPointer) 0 }, { XmNafc, /* Same as above */ XmCAfc, XmRInt, sizeof (int), XtOffsetOf (AppRes, afc), XtRInt, (XtPointer) 0 }, { XmNnet, /* Same as above */ XmCNet, XmRInt, sizeof (int), XtOffsetOf (AppRes, net), XtRInt, (XtPointer) 0 }, { XmNnoMixer, /* Same as above */ XmCNoMixer, XmRInt, sizeof (int), XtOffsetOf (AppRes, noMixer), XtRInt, (XtPointer) 1 }, { XmNmainVol, /* Same as above */ XmCMainVol, XmRInt, sizeof (int), XtOffsetOf (AppRes, mainVol), XtRFloat, (XtPointer) 0 }, { XmNoutVol, /* Same as above */ XmCOutVol, XmRInt, sizeof (int), XtOffsetOf (AppRes, outVol), XtRFloat, (XtPointer) 0 }, { XmNinVol, /* Same as above */ XmCInVol, XmRInt, sizeof (int), XtOffsetOf (AppRes, inVol), XtRImmediate, (XtPointer) 0 }, { XmNcall, /* Same as above */ XmCCall, XmRString, sizeof (char), XtOffsetOf (AppRes, call), XtRImmediate, (XtPointer) " ", }, { XmNzero, /* Same as above */ XmCZero, XmRInt, sizeof (int), XtOffsetOf (AppRes, zero), XtRImmediate, (XtPointer) 0 }, { XmNptt, /* Same as above */ XmCPtt, XmRInt, sizeof (int), XtOffsetOf (AppRes, ptt), XtRImmediate, (XtPointer) 0 }, { XmNserDev, /* Same as above */ XmCSerDev, XmRString, sizeof (char), XtOffsetOf (AppRes, serDev), XtRImmediate, (XtPointer) "/dev/ttyS1", }, { XmNcallBox, /* Same as above */ XmCCallBox, XmRInt, sizeof (int), XtOffsetOf (AppRes, callBox), XtRImmediate, (XtPointer) 0 }, }; #ifdef XmVERSION_STRING extern const char _XmVersionString[]; printf ("Compiled with %s\n", XmVERSION_STRING); printf ("Running with %s\n", _XmVersionString); #endif /* * Create the shell, register a callback for the WM Close button, * catch the INT, QUIT, and TERM signals, and read the resource file * if Twpsk was found. */ shell = XtVaAppInitialize (&ac, "Twpsk", NULL, 0, &argc, argv, fallback_resources, XmNiconName, "TWPSK", NULL); wm_delete_win = XmInternAtom (XtDisplay(shell), "WM_DELETE_WINDOW", False); XmAddWMProtocolCallback (shell, wm_delete_win, quitCB, NULL); signal (SIGINT, gotSig); signal (SIGQUIT, gotSig); signal (SIGTERM, gotSig); /* * Create an error message box just in case. * If the label != "OK", then we're running on * the fallback resources. Popup the dialog * and tell them to fix Twpsk */ noTwpskMessBox = XtVaCreateManagedWidget("noTwpskMessBox", xmMessageBoxWidgetClass, shell, NULL); XtVaGetValues (noTwpskMessBox, XmNmessageString, &messStr, NULL); XmStringGetLtoR (messStr, XmFONTLIST_DEFAULT_TAG, &str); if (strcmp(str,"OK") != 0) /* didn't find Twpsk in X11's app-defaults*/ /* did you run make install_twpsk as root? */ { /* Get rid of the Cancel and Help buttons */ temp = XmMessageBoxGetChild (noTwpskMessBox, XmDIALOG_CANCEL_BUTTON); XtUnmanageChild(temp); temp = XmMessageBoxGetChild (noTwpskMessBox, XmDIALOG_HELP_BUTTON); XtUnmanageChild(temp); /* Have the OK button call the quitCB. cdata = -1 (stops 2Rx save) */ temp = XmMessageBoxGetChild (noTwpskMessBox, XmDIALOG_OK_BUTTON); XtAddCallback (temp, XmNactivateCallback, quitCB, (XtPointer) -1); /* bail out to the event loop with just the message box */ XtRealizeWidget(shell); XtAppMainLoop(ac); } /* Got Twpsk, so don't need the message box */ XtDestroyWidget (noTwpskMessBox); /* Get the app resources from the resource file */ XtGetApplicationResources (shell, &appRes, appRes_desc, XtNumber (appRes_desc), NULL, 0); /* * initialize server * psk31.cod is now installed in /usr/local/share/psk31 */ if( server_main(sound_device, appRes.ptt ? appRes.serDev : NULL, "/usr/local/share/psk31")) { fprintf(stderr,"failed to initialize psk31 server\n"); exit(1); } /* * Create widgets */ pskwids.buildWidgets (shell, &appRes); /* This creates a toplevel shell in the upper left corner and registers * an expose callback. The callback gets the x-y location and now we know * the width of the borders. Needed to position the secondary decoders. */ Widget sh, da; sh= XtVaAppCreateShell("sh", "sh",topLevelShellWidgetClass, XtDisplay(shell), NULL); da = XtVaCreateManagedWidget ("da",xmDrawingAreaWidgetClass, sh, NULL); XtAddCallback (da, XmNexposeCallback, bordersCB, NULL); XtRealizeWidget(sh); /* @@@DL9RDZ * test 2nd window */ // catwids.buildWidgets(shell, &appRes); DecoderWid::shell = shell; for(int i=0; i 0) { if (l != N) { fprintf(stderr,"FFT len mismatch: l=%d N=%d\n",l,N); } disp.getFFT (fftval, N); } #ifndef USE_PTHREAD } #endif char buf[256]; /* * handle transmit echo! We could use a different color? * Sri, Hansi. Best I can do is to underline or highlight it. * and that causes a lot of flicker */ rxecho = commGetData(COMM_ECHOCH, buf, sizeof buf); if(rxecho > 0) { for(int i=0; i 0) { for(int i=0; i .05) { sprintf (str, "%4.1f", appRes.rxFreq); XmTextFieldSetString (pskwids.getRxFreqTF(), str); /* tell the fft about it */ disp.offset(appRes.rxFreq); rxfreqOld = appRes.rxFreq; } } } else { /* scope display for each tx character put in the echo (rx) window */ if(rxecho>0) phdelta = 0; else phdelta = 128; scope.drawline(phdelta, 35, GREEN); } /* handle receive for additional receivers! */ for(int ch=0; ch0) { for(int i=0; i