]> git.rkrishnan.org Git - pihpsdr.git/commitdiff
Fixed New Protocol CW. Updated header files so only included once.
authorJohn Melton - G0ORX/N6LYT <john.d.melton@googlemail.com>
Thu, 25 Aug 2016 08:49:15 +0000 (08:49 +0000)
committerJohn Melton - G0ORX/N6LYT <john.d.melton@googlemail.com>
Thu, 25 Aug 2016 08:49:15 +0000 (08:49 +0000)
43 files changed:
agc.h
alex.h
audio.h
band.h
bandstack.h
channel.h
configure.h
discovered.h
filter.h
freedv.h
frequency.h
gpio.h
lime_discovery.h
lime_protocol.h
main.c
main.h
menu.h
meter.h
mode.h
new_discovery.h
new_protocol.c
new_protocol.h
old_discovery.h
old_protocol.h
panadapter.h
pihpsdr
property.h
psk.c
psk.h
psk_waterfall.h
radio.h
release/pihpsdr.tar
release/pihpsdr/pihpsdr
signal.h
sliders.h
splash.h
toolbar.c
toolbar.h
version.h
vfo.h
waterfall.h
wdsp_init.h
xvtr.h

diff --git a/agc.h b/agc.h
index c64de97765f03541bfca3e119d5366fbc050af1c..2fcb04f9e857a32d4bfa1c30c96ed69cfc016936 100644 (file)
--- a/agc.h
+++ b/agc.h
 *
 */
 
+#ifndef _AGC_H
+#define _AGC_H
+
 #define AGC_OFF 0
 #define AGC_LONG 1
 #define AGC_SLOW 2
 #define AGC_MEDIUM 3
 #define AGC_FAST 4
 
+#endif
diff --git a/alex.h b/alex.h
index a9178cb68b5f8de4d5a70a9645711e4f96cb9af4..ee1ce6682ae4e158f41487af0ab7f0b6baf46ebf 100644 (file)
--- a/alex.h
+++ b/alex.h
@@ -17,6 +17,9 @@
 *
 */
 
+#ifndef _ALEX_H
+#define _ALEX_H
+
 #define ALEX_RX_ANTENNA_NONE   0x00000000
 #define ALEX_RX_ANTENNA_XVTR   0x00000900
 #define ALEX_RX_ANTENNA_EXT1   0x00000A00
@@ -48,3 +51,5 @@
 #define ALEX_BYPASS_HPF        0x00000800
 
 #define ALEX_6M_PREAMP         0x00000008
+
+#endif
diff --git a/audio.h b/audio.h
index cedea093821ac75ecbd20957e74b77234417b121..89e90d89f84b52665361a4a31b553fe1e7c74479 100644 (file)
--- a/audio.h
+++ b/audio.h
@@ -17,6 +17,9 @@
 *
 */
 
+#ifndef _AUDIO_H
+#define _AUDIO_H
+
 extern int audio;
 extern int audio_buffer_size;
 
@@ -26,3 +29,5 @@ void audio_write(short left_sample,short right_sample);
 /*
 void audio_write(double *buffer,int samples);
 */
+
+#endif
diff --git a/band.h b/band.h
index 4c35de6d70e7f91f6a1979f64b77f4af0c61bc13..7a21b106f38fa94ec3697abdedc442a9ac77f02d 100644 (file)
--- a/band.h
+++ b/band.h
@@ -17,6 +17,9 @@
 *
 */
 
+#ifndef _BAND_H
+#define _BAND_H
+
 #include <gtk/gtk.h>
 #include "bandstack.h"
 
@@ -99,3 +102,4 @@ BAND_LIMITS* getBandLimits(long long minDisplay,long long maxDisplay);
 XVTR_ENTRY* getXvtrEntry(int i);
 */
 
+#endif
index c40a09edf765efa484450ec3fd56e9fdda309dad..4506c5f52ce086ab1bfe046d28c2202687f9012e 100644 (file)
@@ -17,8 +17,9 @@
 *
 */
 
-#ifndef BANDSTACK_H
-#define BANDSTACK_H
+#ifndef _BANDSTACK_H
+#define _BANDSTACK_H
+
 /* --------------------------------------------------------------------------*/
 /**
 * @brief Bandstack definition
index f4c0c5792490de271b30cb612ae36cafdddbd465..48da4d03f87d628111e257026968ca3a1303587c 100644 (file)
--- a/channel.h
+++ b/channel.h
@@ -17,6 +17,9 @@
 *
 */
 
+#ifndef _CHANNEL_H
+#define _CHANNEL_H
+
 #define CHANNEL_RX0 0
 #define CHANNEL_RX1 1
 #define CHANNEL_RX2 2
@@ -32,3 +35,5 @@
 #define CHANNEL_PSK 11
 #endif
 
+#endif
+
index 3750463ac773116264d8a1365bb1a251b968bbf1..5f3f84aff7afdebee11a7ee9e0ce9b2ad9b05e41 100644 (file)
 */
 
 
+#ifndef _CONFIGURE_H
+#define _CONFIGURE_H
+
 #ifdef INCLUDE_GPIO
 void configure_gpio(GtkWidget *parent);
 #endif
+
+#endif
index 5b76d87d9d85f9a11cb86ea983d5e1a48fb3782e..28b41e0eb0cce507016af72132ca43c3c5b24a7a 100644 (file)
@@ -17,6 +17,9 @@
 *
 */
 
+#ifndef _DISCOVERED_H
+#define _DISCOVERED_H
+
 #include <netinet/in.h>
 #ifdef LIMESDR
 #include <SoapySDR/Device.h>
@@ -82,3 +85,4 @@ extern int selected_device;
 extern int devices;
 extern DISCOVERED discovered[MAX_DEVICES];
 
+#endif
index e0cbe07e5f5dde4ee56d68f074b7b252818222e8..8c91cfe8ada18384855b1df50ed42c68ebcf7051 100644 (file)
--- a/filter.h
+++ b/filter.h
@@ -17,6 +17,9 @@
 *
 */
 
+#ifndef _FILTER_H
+#define _FILTER_H
+
 #include "mode.h"
 
 // disable Var1 and Var2 (change to 12 to enable)
@@ -61,3 +64,4 @@ int filterVar2High;
 
 FILTER *filters[MODES];
 
+#endif
index 0b4c817ad9c571219f0e6caa3b07325713099166..36bdd2b3cb092964f2df21d0d05044fc923bb8fe 100644 (file)
--- a/freedv.h
+++ b/freedv.h
@@ -1,3 +1,25 @@
+/* Copyright (C)
+* 2016 - John Melton, G0ORX/N6LYT
+*
+* 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+*
+*/
+
+#ifndef _FREEDV_H
+#define _FREEDV_H
+
 extern int n_speech_samples;
 extern int n_max_modem_samples;
 extern short *demod_in;
@@ -16,3 +38,4 @@ int demod_sample_freedv(short sample);
 int mod_sample_freedv(short sample);
 void reset_freedv_tx_text_index();
 
+#endif
index 2aa1007c3595361158064754acc494535057a207..9c9199f008d7fdb2002c8baeb26bcc83b06bdfc6 100644 (file)
@@ -24,9 +24,8 @@
 * 
 */
 
-//
-// frequency.h
-//
+#ifndef _FREQUENCY_H
+#define _FREQUENCY_H
 
 /* --------------------------------------------------------------------------*/
 /** 
@@ -44,3 +43,5 @@ struct frequency_info {
 char* getFrequencyInfo(long long frequency);
 int getBand(long long frequency);
 int canTransmit();
+
+#endif
diff --git a/gpio.h b/gpio.h
index d94de81d5f1bda63fb90a86bd8b780231368c623..4ed7155d569852d2f4a8252f30b3d727221e658d 100644 (file)
--- a/gpio.h
+++ b/gpio.h
@@ -17,6 +17,9 @@
 *
 */
 
+#ifndef _GPIO_H
+#define _GPIO_H
+
 extern int ENABLE_VFO_ENCODER;
 extern int ENABLE_VFO_PULLUP;
 extern int VFO_ENCODER_A;
@@ -67,3 +70,5 @@ int mode_get_state();
 int filter_get_state();
 int noise_get_state();
 int mox_get_state();
+
+#endif
index 999944e8f31c97268fdc45ea275d38843fbdbf7e..6c73d7361d451a0a9e9d40f40388bf60432657e7 100644 (file)
@@ -1 +1,25 @@
+/* Copyright (C)
+* 2015 - John Melton, G0ORX/N6LYT
+*
+* 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+*
+*/
+
+#ifndef _LIME_DISCOVERY_H
+#define _LIME_DISCOVERY_H
+
 void lime_discovery();
+
+#endif
index aa349d39d1edb8bb2ddcdcb4a7120f19af293963..ec2fd96e1b23c778d849fa41eff125e8f7e2d769 100644 (file)
@@ -1,3 +1,25 @@
+/* Copyright (C)
+* 2015 - John Melton, G0ORX/N6LYT
+*
+* 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+*
+*/
+
+#ifndef _LIME_PROTOCOL_H
+#define _LIME_PROTOCOL_H
+
 #define BUFFER_SIZE 1024
 
 void lime_protocol_init(int rx,int pixels);
@@ -5,3 +27,5 @@ void lime_protocol_stop();
 void lime_protocol_set_frequency(long long f);
 void lime_protocol_set_antenna(int ant);
 void lime_protocol_set_attenuation(int attenuation);
+
+#endif
diff --git a/main.c b/main.c
index 4142cc11cd6793200bd441a0da5ae06521fc22bd..771a9f1f5e4827f6a56a9524390265a0121529de 100644 (file)
--- a/main.c
+++ b/main.c
@@ -166,16 +166,21 @@ gint update(gpointer data) {
         DISCOVERED *d=&discovered[selected_device];
 
         double constant1=3.3;
-        double constant2=0.09;
+        double constant2=0.095;
 
         if(d->protocol==ORIGINAL_PROTOCOL) {
             switch(d->device) {
                 case DEVICE_METIS:
+                    constant1=3.3;
+                    constant2=0.09;
                     break;
                 case DEVICE_HERMES:
-                    //constant2=0.095; HERMES 2
+                    constant1=3.3;
+                    constant2=0.095;
                     break;
                 case DEVICE_ANGELIA:
+                    constant1=3.3;
+                    constant2=0.095;
                     break;
                 case DEVICE_ORION:
                     constant1=5.0;
@@ -256,9 +261,11 @@ gint update(gpointer data) {
             }
         }
 
-//fprintf(stderr,"drive=%d tune_drive=%d alex_forward_power=%d alex_reverse_power=%d exciter_power=%d fwd=%f rev=%f exciter=%f\n",
-//               drive, tune_drive, alex_forward_power, alex_reverse_power, exciter_power, fwd, rev, exciter);
+/*
+fprintf(stderr,"alex_forward_power=%d alex_reverse_power=%d exciter_power=%d fwd=%f rev=%f exciter=%f\n",
+               alex_forward_power, alex_reverse_power, exciter_power, fwd, rev, exciter);
         meter_update(POWER,fwd,rev,exciter,alc);
+*/
     }
 
     return TRUE;
diff --git a/main.h b/main.h
index 125036220b885469a241fb39f6ca1ce1f38f2c81..ba49d5ba98a33351b1de2e5fb2ab97797daacb6a 100644 (file)
--- a/main.h
+++ b/main.h
@@ -17,6 +17,9 @@
 *
 */
 
+#ifndef _MAIN_H
+#define _MAIN_H
+
 #include <sys/utsname.h>
 extern struct utsname unameData;
 void reconfigure_display();
@@ -25,3 +28,4 @@ void show_psk();
 void show_waterfall();
 #endif
 
+#endif
diff --git a/menu.h b/menu.h
index 90f6b2d61ec3d6c0ccccd0d924a650cf6d618297..52c3e6fadc21ef55f8134469cc4e8610d7297a84 100644 (file)
--- a/menu.h
+++ b/menu.h
@@ -18,4 +18,9 @@
 */
 
 
+#ifndef _MENU_H
+#define _MENU_H
+
 GtkWidget* menu_init(int width,int height,GtkWidget *parent);
+
+#endif
diff --git a/meter.h b/meter.h
index d02adcf1dd262007dea9ad484e86a529a8d2dce6..44df10149562001e8fbde7467585e247e768040b 100644 (file)
--- a/meter.h
+++ b/meter.h
@@ -17,6 +17,9 @@
 *
 */
 
+#ifndef _METER_H
+#define _METER_H
+
 #define SMETER 0
 #define POWER 1
 #ifdef PSK
@@ -26,3 +29,5 @@
 
 GtkWidget* meter_init(int width,int height,GtkWidget *parent);
 void meter_update(int meter_type,double value,double reverse,double exciter,double alc);
+
+#endif
diff --git a/mode.h b/mode.h
index aa1d4fd823df489cd0af12bc996bae7e582dacad..e2839d27e78e1ff49dbbeddae1940706bfa63df2 100644 (file)
--- a/mode.h
+++ b/mode.h
@@ -17,6 +17,9 @@
 *
 */
 
+#ifndef _MODE_H
+#define _MODE_H
+
 #define modeLSB 0
 #define modeUSB 1
 #define modeDSB 2
@@ -51,3 +54,4 @@ int mode;
 
 char *mode_string[MODES];
 
+#endif
index 84b98dca50e63d2e1080cd95766035b10150a39a..9851f22c87058c541d98c7d59fe5becd4083e1fe 100644 (file)
@@ -17,5 +17,9 @@
 *
 */
 
+#ifndef _NEW_DISCOVERY_H
+#define _NEW_DISCOVERY_H
 
 void new_discovery(void);
+
+#endif
index ea7ee55c1af972836d6635b37a9946ecf9c0fa74..316dc456686baed52c95f933a835f463bad981f4 100644 (file)
@@ -149,7 +149,7 @@ static int psk_samples=0;
 static int psk_resample=6;  // convert from 48000 to 8000
 #endif
 
-static void new_protocol_high_priority(int run,int tx,double drive);
+static void new_protocol_high_priority(int run);
 static void* new_protocol_thread(void* arg);
 static void* new_protocol_timer_thread(void* arg);
 static void  process_iq_data(unsigned char *buffer);
@@ -242,11 +242,11 @@ void new_protocol_init(int rx,int pixels) {
 }
 
 void new_protocol_new_sample_rate(int rate) {
-  new_protocol_high_priority(0,0,0);
+  new_protocol_high_priority(0);
   sample_rate=rate;
   new_protocol_calc_buffers();
   wdsp_new_sample_rate(rate);
-  new_protocol_high_priority(1,0,drive);
+  new_protocol_high_priority(1);
 }
 
 static void new_protocol_general() {
@@ -264,11 +264,11 @@ fprintf(stderr,"new_protocol_general: receiver=%d\n", receiver);
     // use defaults apart from
     buffer[37]=0x08;  //  phase word (not frequency)
     buffer[38]=0x01;  //  enable hardware timer
-    //buffer[58]=pa;  // enable PA 0x01
+
     buffer[58]=0x01;  // enable PA 0x01
-    //if((filter_board==APOLLO) && tune) {
+
     if(filter_board==APOLLO) {
-        buffer[58]|=0x02;
+        buffer[58]|=0x02; // enable APOLLO tuner
     }
 
     if(filter_board==ALEX) {
@@ -283,11 +283,11 @@ fprintf(stderr,"new_protocol_general: receiver=%d\n", receiver);
     general_sequence++;
 }
 
-static void new_protocol_high_priority(int run,int tx,double drive) {
+static void new_protocol_high_priority(int run) {
     unsigned char buffer[1444];
     BAND *band=band_get_current_band();
 
-//fprintf(stderr,"new_protocol_high_priority: run=%d tx=%d drive=%f\n", run, tx, drive);
+fprintf(stderr,"new_protocol_high_priority: run=%d\n", run);
     memset(buffer, 0, sizeof(buffer));
 
     buffer[0]=high_priority_sequence>>24;
@@ -295,7 +295,16 @@ static void new_protocol_high_priority(int run,int tx,double drive) {
     buffer[2]=high_priority_sequence>>8;
     buffer[3]=high_priority_sequence;
 
-    buffer[4]=run|(tx<<1);
+    buffer[4]=run;
+    if(mode==modeCWU || mode==modeCWL) {
+      if(tune) {
+        buffer[4]|=0x02;
+      }
+    } else {
+      if(isTransmitting()) {
+        buffer[4]|=0x02;
+      }
+    }
 
     long rxFrequency=ddsFrequency;
     if(mode==modeCWU) {
@@ -320,11 +329,15 @@ static void new_protocol_high_priority(int run,int tx,double drive) {
     buffer[331]=phase>>8;
     buffer[332]=phase;
 
-
-    double d=drive*((double)band->pa_calibration/100.0);
+    double d=drive;
+    if(tune) {
+      d=tune_drive;
+    }
+    d=d*((double)band->pa_calibration/100.0);
     int power=(int)(d*255.0);
     buffer[345]=power&0xFF;
 
+fprintf(stderr,"power=%d\n",power);
 
     if(isTransmitting()) {
       buffer[1401]=band->OCtx;
@@ -461,17 +474,11 @@ else LPF <= 7'b0001000;             // < 2.4MHz so use 160m LPF^M
 
     //filters|=alex_attenuation;
 
-    if(tx) {
+    //if(isTransmitting() || mode==modeCWU || mode==modeCWL) {
+    if(isTransmitting()) {
         filters|=0x08000000;
     }
 
-/*
-    buffer[1420]=filters>>24;
-    buffer[1421]=filters>>16;
-    buffer[1422]=filters>>8;
-    buffer[1423]=filters;
-*/
-
     buffer[1432]=filters>>24;
     buffer[1433]=filters>>16;
     buffer[1434]=filters>>8;
@@ -503,7 +510,7 @@ static void new_protocol_transmit_specific() {
 
     buffer[4]=1; // 1 DAC
     buffer[5]=0; //  default no CW
-    if(cw_keyer_internal) {
+    if(cw_keyer_internal && (mode==modeCWU || mode==modeCWL)) {
         buffer[5]|=0x02;
     }
     if(cw_keys_reversed) {
@@ -549,7 +556,6 @@ static void new_protocol_transmit_specific() {
     }
     buffer[51]=0x7F; // Line in gain
 
-
     if(sendto(data_socket,buffer,sizeof(buffer),0,(struct sockaddr*)&transmitter_addr,transmitter_addr_length)<0) {
         fprintf(stderr,"sendto socket failed for tx specific\n");
         exit(1);
@@ -616,7 +622,7 @@ static void new_protocol_start() {
 }
 
 void new_protocol_stop() {
-    new_protocol_high_priority(0,0,0);
+    new_protocol_high_priority(0);
     running=0;
     sleep(1);
 }
@@ -694,7 +700,7 @@ fprintf(stderr,"outputsamples=%d\n", outputsamples);
 
     new_protocol_general();
     new_protocol_start();
-    new_protocol_high_priority(1,0,drive);
+    new_protocol_high_priority(1);
 
     while(running) {
         bytesread=recvfrom(data_socket,buffer,sizeof(buffer),0,(struct sockaddr*)&addr,&length);
@@ -734,7 +740,7 @@ fprintf(stderr,"outputsamples=%d\n", outputsamples);
 
            sem_wait(&send_high_priority_sem);
            if(send_high_priority==1) {
-               new_protocol_high_priority(1,isTransmitting(),tune==0?drive:tune_drive);
+               new_protocol_high_priority(1);
                send_high_priority=0;
            }
            sem_post(&send_high_priority_sem);
@@ -764,7 +770,7 @@ static void process_iq_data(unsigned char *buffer) {
 
 //fprintf(stderr,"samples per frame %d\n",samplesperframe);
 
-    if(!isTransmitting()) {
+    //if(!isTransmitting()) {
         b=16;
         int i;
         for(i=0;i<samplesperframe;i++) {
@@ -787,7 +793,7 @@ static void process_iq_data(unsigned char *buffer) {
                 samples=0;
             }
        }
-   }
+  //}
 }
 
 static void process_command_response(unsigned char *buffer) {
@@ -823,6 +829,8 @@ if(dash!=previous_dash) {
   fprintf(stderr,"dash=%d\n",dash);
 }
     pll_locked=(buffer[4]>>3)&0x01;
+
+
     adc_overload=buffer[5]&0x01;
     exciter_power=((buffer[6]&0xFF)<<8)|(buffer[7]&0xFF);
     alex_forward_power=((buffer[14]&0xFF)<<8)|(buffer[15]&0xFF);
@@ -830,8 +838,6 @@ if(dash!=previous_dash) {
     supply_volts=((buffer[49]&0xFF)<<8)|(buffer[50]&0xFF);
 
     if(previous_ptt!=ptt) {
-        //send_high_priority=1;
-        previous_ptt=ptt;
         g_idle_add(ptt_update,(gpointer)ptt);
     }
 
@@ -905,42 +911,48 @@ static void process_freedv_rx_buffer() {
   int j;
   int demod_samples;
   for(j=0;j<outputsamples;j++) {
-    leftaudiosample=(short)(audiooutputbuffer[j*2]*32767.0*volume);
-    rightaudiosample=(short)(audiooutputbuffer[(j*2)+1]*32767.0*volume);
-    demod_samples=demod_sample_freedv(leftaudiosample);
-    if(demod_samples!=0) {
-      int s;
-      int t;
-      for(s=0;s<demod_samples;s++) {
-        if(freedv_sync) {
-          leftaudiosample=rightaudiosample=(short)((double)speech_out[s]*volume);
-        } else {
-          leftaudiosample=rightaudiosample=0;
-        }
-        for(t=0;t<6;t++) { // 8k to 48k
-          if(local_audio) {
-            audio_write(leftaudiosample,rightaudiosample);
+    if(freedv_samples==0) {
+      leftaudiosample=(short)(audiooutputbuffer[j*2]*32767.0*volume);
+      rightaudiosample=(short)(audiooutputbuffer[(j*2)+1]*32767.0*volume);
+      demod_samples=demod_sample_freedv(leftaudiosample);
+      if(demod_samples!=0) {
+        int s;
+        int t;
+        for(s=0;s<demod_samples;s++) {
+          if(freedv_sync) {
+            leftaudiosample=rightaudiosample=(short)((double)speech_out[s]*volume);
+          } else {
+            leftaudiosample=rightaudiosample=0;
           }
-          audiobuffer[audioindex++]=leftaudiosample>>8;
-          audiobuffer[audioindex++]=leftaudiosample;
-          audiobuffer[audioindex++]=rightaudiosample>>8;
-          audiobuffer[audioindex++]=rightaudiosample;
-          if(audioindex>=sizeof(audiobuffer)) {
-            // insert the sequence
-            audiobuffer[0]=audiosequence>>24;
-            audiobuffer[1]=audiosequence>>16;
-            audiobuffer[2]=audiosequence>>8;
-            audiobuffer[3]=audiosequence;
-            // send the buffer
-            if(sendto(data_socket,audiobuffer,sizeof(audiobuffer),0,(struct sockaddr*)&audio_addr,audio_addr_length)<0) {
-              fprintf(stderr,"sendto socket failed for audio\n");
-              exit(1);
+          for(t=0;t<6;t++) { // 8k to 48k
+            if(local_audio) {
+                audio_write(leftaudiosample,rightaudiosample);
+            }
+            audiobuffer[audioindex++]=leftaudiosample>>8;
+            audiobuffer[audioindex++]=leftaudiosample;
+            audiobuffer[audioindex++]=rightaudiosample>>8;
+            audiobuffer[audioindex++]=rightaudiosample;
+            if(audioindex>=sizeof(audiobuffer)) {
+                // insert the sequence
+              audiobuffer[0]=audiosequence>>24;
+              audiobuffer[1]=audiosequence>>16;
+              audiobuffer[2]=audiosequence>>8;
+              audiobuffer[3]=audiosequence;
+              // send the buffer
+              if(sendto(data_socket,audiobuffer,sizeof(audiobuffer),0,(struct sockaddr*)&audio_addr,audio_addr_length)<0) {
+                fprintf(stderr,"sendto socket failed for audio\n");
+                exit(1);
+              }
+              audioindex=4;
+              audiosequence++;
             }
-            audioindex=4;
-            audiosequence++;
           }
         }
       }
+      freedv_samples++;
+      if(freedv_samples==freedv_resample) {
+        freedv_samples=0;
+      }
     }
   }
 }
@@ -994,21 +1006,26 @@ static void full_rx_buffer() {
   int error;
 
   fexchange0(CHANNEL_RX0, iqinputbuffer, audiooutputbuffer, &error);
+  switch(mode) {
 #ifdef PSK
-  if(mode!=modePSK) {
+    case modePSK:
+      break;
 #endif
-    Spectrum0(1, CHANNEL_RX0, 0, 0, iqinputbuffer);
-#ifdef PSK
+    default:
+      Spectrum0(1, CHANNEL_RX0, 0, 0, iqinputbuffer);
+      break;
   }
-#endif
 
+  switch(mode) {
 #ifdef FREEDV
-  if(mode==modeFREEDV) {
-    process_freedv_rx_buffer();
-    return;
-  }
+    case modeFREEDV:
+      process_freedv_rx_buffer();
+      break;
 #endif
-  process_rx_buffer();
+    default:
+      process_rx_buffer();
+      break;
+  }
 }
 
 static void full_tx_buffer() {
index 8c11804cf8e4eb6ae41279afd5fcca1c8fa4f19d..a5c5f1055ac36dc51ccdb1b933f43fec7bd2b03b 100644 (file)
@@ -17,6 +17,8 @@
 *
 */
 
+#ifndef _NEW_PROTOCOL_H
+#define _NEW_PROTOCOL_H
 
 // port definitions from host
 #define GENERAL_REGISTERS_FROM_HOST_PORT 1024
@@ -70,3 +72,4 @@ void setTune(int state);
 int getTune();
 int isTransmitting();
 
+#endif
index 89fddbe9d9485330154761e7e8f5737d731af8e7..fb3a2f54208e77f4223fe47b4143b421c95a724c 100644 (file)
@@ -17,4 +17,9 @@
 *
 */
 
+#ifndef _OLD_DISCOVERY_H
+#define _OLD_DISCOVERY_H
+
 void old_discovery(void);
+
+#endif
index a4f3ac6e7ab5da9b18c5a5b6e68e240be4ddf0c4..e77e7d65ec327f2395f27fec87ee5193d9aa8abd 100644 (file)
 *
 */
 
+#ifndef _OLD_PROTOCOL_H
+#define _OLD_PROTOCOL_H
+
 #define BUFFER_SIZE 1024
 void old_protocol_stop();
 void old_protocol_init(int rx,int pixels);
 void old_protocol_new_sample_rate(int rate);
 void schedule_frequency_changed();
+
+#endif
index 278f5049664b6dcaa002e8b414222eeca1369095..61717d08d95c3b85d4cb81732cbb5126af68ba65 100644 (file)
 *
 */
 
+#ifndef _PANADAPTER_H
+#define _PANADAPTER_H
+
 void panadapter_update(float* data,int tx);
 
 GtkWidget* panadapter_init(int width,int height);
+
+
+#endif
diff --git a/pihpsdr b/pihpsdr
index fa264bb1d18374436b3d5ba6e471865e97d788e9..e248f91577b5e747980a4a7c3fa32f6f43f8026b 100755 (executable)
Binary files a/pihpsdr and b/pihpsdr differ
index 5056c6e582a6f9452899822059f6b6f6f7cde536..7cccaeaa884550f6d7c23a447ea47c46663cf7b5 100644 (file)
@@ -17,6 +17,9 @@
 *
 */
 
+#ifndef _PROPERTY_H
+#define _PROPERTY_H
+
 typedef struct _PROPERTY PROPERTY;
 
 /* --------------------------------------------------------------------------*/
@@ -33,3 +36,4 @@ void loadProperties(char* filename);
 char* getProperty(char* name);
 void setProperty(char* name,char* value);
 
+#endif
diff --git a/psk.c b/psk.c
index 557d268761a38210a0faeb318cfff96635e0d03c..7d8c326c16bb52f337643c7e8c3f2da800dad7d8 100644 (file)
--- a/psk.c
+++ b/psk.c
@@ -101,7 +101,9 @@ GtkWidget *init_psk() {
   gtk_label_set_width_chars (GTK_LABEL(psk_label), 80);
   gtk_label_set_lines (GTK_LABEL(psk_label), TEXT_LINES);
   gtk_label_set_line_wrap (GTK_LABEL(psk_label), TRUE);
-  gtk_misc_set_alignment (GTK_MISC(psk_label), 0, 0);
+  //gtk_misc_set_alignment (GTK_MISC(psk_label), 0, 0);
+  gtk_widget_set_halign(psk_label,GTK_ALIGN_START);
+  gtk_widget_set_valign(psk_label,GTK_ALIGN_START);
   
   return psk_label;
 }
diff --git a/psk.h b/psk.h
index 8e22e2f3c8c63a3ca024162cec5e13b3edbdc3cf..eba9555934703a96a2b6ac1822824e16a7843be2 100644 (file)
--- a/psk.h
+++ b/psk.h
@@ -1,3 +1,25 @@
+/* Copyright (C)
+* 2016 - John Melton, G0ORX/N6LYT
+*
+* 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+*
+*/
+
+#ifndef _PSK_H
+#define _PSK_H
+
 #define PSK_BUFFER_SIZE 1024
 
 #define PSK_RX_TEXT_SIZE 2048
@@ -9,3 +31,5 @@ extern void psk_set_frequency(int f);
 extern int psk_get_frequency();
 extern int psk_get_signal_level();
 extern int psk_demod(double sample);
+
+#endif
index 0209c1a75857842e4a9ca2ad32a967750370432c..abdf8aea4b07bb804dc2f8de32446583bb47a67b 100644 (file)
 *
 */
 
+#ifndef _PSK_WATERFALL_H
+#define _PSK_WATERFALL_H
 
 void psk_waterfall_update(float *data);
 GtkWidget* psk_waterfall_init(int width,int height);
+
+#endif
diff --git a/radio.h b/radio.h
index 4d30174f44f1dd1e2ad3d690420c7cf7c65e10c0..bfc7d6a980a7570efe76ea595b28b1d569d2badc 100644 (file)
--- a/radio.h
+++ b/radio.h
 *
 */
 
+#ifndef _RADIO_H
+#define _RADIO_H
+
+#include "discovered.h"
 
 #define NEW_MIC_IN 0x00
 #define NEW_LINE_IN 0x01
@@ -236,3 +240,5 @@ extern void radioRestoreState();
 extern void radioSaveState();
 
 extern void calculate_display_average();
+
+#endif
index 270d5f921705ca74d39e19d7384eccd849a97f6c..de7c497096406406b80a1ea539ba55b354baeb80 100644 (file)
Binary files a/release/pihpsdr.tar and b/release/pihpsdr.tar differ
index fa264bb1d18374436b3d5ba6e471865e97d788e9..e248f91577b5e747980a4a7c3fa32f6f43f8026b 100755 (executable)
Binary files a/release/pihpsdr/pihpsdr and b/release/pihpsdr/pihpsdr differ
index 85f781cf7bf89cbaabbcaa3789567a977cfb75fb..6c76f24ae7c2c8618c1fe2cbcaa3441cb11a416e 100644 (file)
--- a/signal.h
+++ b/signal.h
 *
 */
 
+#ifndef _SIGNAL_H
+#define _SIGNAL_H
+
 double sineWave(double* buf, int samples, double sinphase, double freq);
 double cosineWave(double* buf, int samples, double cosphase, double freq);
+
+#endif
index be25b58758a6e5ac216aaa19727626485f2cd902..a469077a603303acf7c6196f7bdc1543a9547ea9 100644 (file)
--- a/sliders.h
+++ b/sliders.h
@@ -17,6 +17,9 @@
 *
 */
 
+#ifndef _SLIDERS_H
+#define _SLIDERS_H
+
 void set_agc_gain(double value);
 void set_af_gain(double value);
 void set_mic_gain(double value);
@@ -24,3 +27,5 @@ void set_drive(double drive);
 void set_tune(double tune);
 void set_attenuation_value(double attenuation);
 GtkWidget *sliders_init(int my_width, int my_height, GtkWidget* parent);
+
+#endif
index b3663057d78bbd7f12665e267d024fae13a7889b..a6be1fc3396cffa04cfa9c572d98b8aa803b14b2 100644 (file)
--- a/splash.h
+++ b/splash.h
 */
 
 
+#ifndef _SPLASH_H
+#define _SPLASH_H
+
 extern GtkWidget* splash_window;
 
 void splash_close(void);
 void splash_show(char *image_name,int time,int width,int height);
 void splash_status(char *text);
+
+#endif
index 7bfe95c0f06b188c5427d10c0bc2586e804d9c43..af550753f76accb03a17a0728632918f2eedbe05 100644 (file)
--- a/toolbar.c
+++ b/toolbar.c
@@ -67,6 +67,17 @@ static GtkWidget *last_filter;
 static GdkRGBA white;
 static GdkRGBA gray;
 
+static void set_button_text_color(GtkWidget *widget,char *color) {
+  GtkStyleContext *style_context;
+  GtkCssProvider *provider = gtk_css_provider_new ();
+  gchar tmp[64];
+  style_context = gtk_widget_get_style_context(widget);
+  gtk_style_context_add_provider(style_context, GTK_STYLE_PROVIDER(provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+  g_snprintf(tmp, sizeof tmp, "GtkButton, GtkLabel { color: %s; }", color);
+  gtk_css_provider_load_from_data(GTK_CSS_PROVIDER(provider), tmp, -1, NULL);
+  g_object_unref (provider);
+}
+
 void update_toolbar_labels() {
   if(toolbar_dialog_buttons) {
       gtk_button_set_label(GTK_BUTTON(sim_band),"Band");
@@ -115,9 +126,9 @@ static void band_select_cb(GtkWidget *widget, gpointer data) {
   } else {
     BAND* band=band_set_current(b);
     entry=bandstack_entry_get_current();
-    gtk_widget_override_background_color(last_band, GTK_STATE_NORMAL, &white);
+    set_button_text_color(last_band,"black");
     last_band=widget;
-    gtk_widget_override_background_color(last_band, GTK_STATE_NORMAL, &gray);
+    set_button_text_color(last_band,"orange");
   }
   setMode(entry->mode);
   FILTER* band_filters=filters[entry->mode];
@@ -162,10 +173,10 @@ void band_cb(GtkWidget *widget, gpointer data) {
 #endif
       BAND* band=band_get_band(i);
       GtkWidget *b=gtk_button_new_with_label(band->title);
-      gtk_widget_override_background_color(b, GTK_STATE_NORMAL, &white);
+      set_button_text_color(b,"black");
       //gtk_widget_override_font(b, pango_font_description_from_string("Arial 20"));
       if(i==band_get_current()) {
-        gtk_widget_override_background_color(b, GTK_STATE_NORMAL, &gray);
+        set_button_text_color(b,"orange");
         last_band=b;
       }
       gtk_widget_show(b);
@@ -198,9 +209,9 @@ static void bandstack_select_cb(GtkWidget *widget, gpointer data) {
 
   bandstack->current_entry=b;
 
-  gtk_widget_override_background_color(last_bandstack, GTK_STATE_NORMAL, &white);
+  set_button_text_color(last_bandstack,"black");
   last_bandstack=widget;
-  gtk_widget_override_background_color(last_bandstack, GTK_STATE_NORMAL, &gray);
+  set_button_text_color(last_bandstack,"orange");
 
   BANDSTACK_ENTRY *entry;
   entry=&(bandstack->entry[b]);
@@ -247,10 +258,10 @@ void bandstack_cb(GtkWidget *widget, gpointer data) {
       BANDSTACK_ENTRY *entry=&bandstack->entry[i];
       sprintf(label,"%lld %s",entry->frequencyA,mode_string[entry->mode]);
       GtkWidget *b=gtk_button_new_with_label(label);
-      gtk_widget_override_background_color(b, GTK_STATE_NORMAL, &white);
+      set_button_text_color(b,"black");
       //gtk_widget_override_font(b, pango_font_description_from_string("Arial 20"));
       if(i==bandstack->current_entry) {
-        gtk_widget_override_background_color(b, GTK_STATE_NORMAL, &gray);
+        set_button_text_color(b,"orange");
         last_bandstack=b;
       }
       gtk_widget_show(b);
@@ -293,9 +304,9 @@ static void mode_select_cb(GtkWidget *widget, gpointer data) {
   FILTER* band_filters=filters[entry->mode];
   FILTER* band_filter=&band_filters[entry->filter];
   setFilter(band_filter->low,band_filter->high);
-  gtk_widget_override_background_color(last_mode, GTK_STATE_NORMAL, &white);
+  set_button_text_color(last_mode,"black");
   last_mode=widget;
-  gtk_widget_override_background_color(last_mode, GTK_STATE_NORMAL, &gray);
+  set_button_text_color(last_mode,"orange");
   vfo_update(NULL);
 }
 
@@ -321,10 +332,10 @@ void mode_cb(GtkWidget *widget, gpointer data) {
     for(i=0;i<MODES;i++) {
       GtkWidget *b=gtk_button_new_with_label(mode_string[i]);
       if(i==entry->mode) {
-        gtk_widget_override_background_color(b, GTK_STATE_NORMAL, &gray);
+        set_button_text_color(b,"orange");
         last_mode=b;
       } else {
-        gtk_widget_override_background_color(b, GTK_STATE_NORMAL, &white);
+        set_button_text_color(b,"black");
       }
       //gtk_widget_override_font(b, pango_font_description_from_string("Arial 20"));
       gtk_widget_show(b);
@@ -357,9 +368,9 @@ static void filter_select_cb(GtkWidget *widget, gpointer data) {
   FILTER* band_filters=filters[entry->mode];
   FILTER* band_filter=&band_filters[entry->filter];
   setFilter(band_filter->low,band_filter->high);
-  gtk_widget_override_background_color(last_filter, GTK_STATE_NORMAL, &white);
+  set_button_text_color(last_filter,"black");
   last_filter=widget;
-  gtk_widget_override_background_color(last_filter, GTK_STATE_NORMAL, &gray);
+  set_button_text_color(last_filter,"orange");
   vfo_update(NULL);
 }
 
@@ -388,10 +399,10 @@ void filter_cb(GtkWidget *widget, gpointer data) {
       GtkWidget *b=gtk_button_new_with_label(band_filters[i].title);
       //gtk_widget_override_font(b, pango_font_description_from_string("Arial 20"));
       if(i==entry->filter) {
-        gtk_widget_override_background_color(b, GTK_STATE_NORMAL, &gray);
+        set_button_text_color(b,"orange");
         last_filter=b;
       } else {
-        gtk_widget_override_background_color(b, GTK_STATE_NORMAL, &white);
+        set_button_text_color(b,"black");
       }
       gtk_widget_show(b);
       gtk_grid_attach(GTK_GRID(grid),b,i%5,i/5,1,1);
@@ -997,7 +1008,7 @@ fprintf(stderr,"mox_cb: mox now %d\n",mox);
 
 int ptt_update(void *data) {
 fprintf(stderr,"ptt_update\n");
-  if(mode!=modeCWU && mode!=modeCWL) {
+  if(protocol==NEW_PROTOCOL || (mode!=modeCWU && mode!=modeCWL)) {
     mox_cb(NULL,NULL);
   }
 fprintf(stderr,"ptt_update: mox=%d ptt=%d tune=%d\n",mox,ptt,tune);
index e717e806657356b4cfd9a26c0c866ded1abf2590..8ade0a43b572f4d9d0c8f65bc98c9cbe7918eeb1 100644 (file)
--- a/toolbar.h
+++ b/toolbar.h
@@ -17,6 +17,9 @@
 *
 */
 
+#ifndef _TOOLBAR_H
+#define _TOOLBAR_H
+
 extern int function;
 
 void update_toolbar_labels();
@@ -34,3 +37,5 @@ void sim_agc_cb(GtkWidget *widget, gpointer data);
 void sim_function_cb(GtkWidget *widget, gpointer data);
 
 GtkWidget *toolbar_init(int my_width, int my_height, GtkWidget* parent);
+
+#endif
index 650786731e5829e989fa57d2e4ad470b233f0052..694d25db00a7fd6cdea562d97b013201ec3a141e 100644 (file)
--- a/version.h
+++ b/version.h
 *
 */
 
+#ifndef _VERSION_H
+#define _VERSION_H
+
 extern char build_version[];
 extern char build_date[];
 
+#endif
diff --git a/vfo.h b/vfo.h
index 008e8e056177aa397fa567d8dd8ba96e8beb18d3..e967d3bc288de19cc193b945823e1f958f4304fe 100644 (file)
--- a/vfo.h
+++ b/vfo.h
 *
 */
 
+#ifndef _VFO_H
+#define _VFO_H
 
 GtkWidget* vfo_init(int width,int height,GtkWidget *parent);
 void vfo_step(int steps);
 void vfo_move(int hz);
 int vfo_update(void*);
+
+#endif
index c656298d04f99f311320d5b0d131fac3792c2198..6278c38d3517ec3b038a90d6fcc273f63d0fc729 100644 (file)
 *
 */
 
+#ifndef _WATERFALL_H
+#define _WATERFALL_H
 
 void waterfall_update(float *data);
 GtkWidget* waterfall_init(int width,int height);
+
+#endif
index 72e89a9d6c82a8bab0b11780d245c0a8ea647114..eb49fd2670864d67cf56571536fb39e2eb80b102 100644 (file)
@@ -17,6 +17,9 @@
 *
 */
 
+#ifndef _WDSP_INIT_H
+#define _WDSP_INIT_H
+
 extern void wdsp_set_input_rate(double rate);
 extern void wdsp_set_offset(long long offset);
 extern void setMode(int m);
@@ -27,3 +30,5 @@ extern int getFilterHigh();
 extern void wdsp_init(int rx,int pixels,int protocol);
 extern void wdsp_new_sample_rate(int rate);
 extern void wdsp_set_agc(int rx, int agc);
+
+#endif
diff --git a/xvtr.h b/xvtr.h
index 4c8f4482c1b75ed1428078070b969f585b949cf6..697b1c21bbf3f09fd551ea744f3d91d944a8238b 100644 (file)
--- a/xvtr.h
+++ b/xvtr.h
@@ -17,6 +17,9 @@
 *
 */
 
+#ifndef _XVTR_H
+#define _XVTR_H
+
 /* --------------------------------------------------------------------------*/
 /**
 * @brief XVTR definition
@@ -47,3 +50,4 @@ struct _XVTR_ENTRY {
 
 typedef struct _XVTR_ENTRY XVTR_ENTRY;
 
+#endif