]> git.rkrishnan.org Git - pihpsdr.git/commitdiff
Fixed CW TX problem at hiigher speeds. Changed Attenuation to be for the ADC.
authorJohn Melton - G0ORX <john.d.melton@googlemail.c>
Fri, 1 Dec 2017 09:14:57 +0000 (09:14 +0000)
committerJohn Melton - G0ORX <john.d.melton@googlemail.c>
Fri, 1 Dec 2017 09:14:57 +0000 (09:14 +0000)
16 files changed:
Makefile
freqent_menu.c
gpio.c
meter.c
meter.h
new_protocol.c
old_protocol.c
radio.c
radio.h
receiver.c
receiver.h
rigctl.c
rx_panadapter.c
sliders.c
vfo_menu.c
waterfall.c

index 93917ec179b2e3515e3a9e065dcc7b13b8ed07dc..d0b4fcd01f1ab00908aaf1cef59904eb82ce604d 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -422,5 +422,5 @@ install: $(PROGRAM)
 release: $(PROGRAM)
        cp $(PROGRAM) release/pihpsdr
        cd release; tar cvf pihpsdr.tar pihpsdr
-       cd release; tar cvf pihpsdr-v1.2.tar pihpsdr
+       cd release; tar cvf pihpsdr-$(GIT_VERSION).tar pihpsdr
 
index 004d984827410e8feeb598b532ea5f1b4194c7bb..d47578ae5d2900e67bbe2eed2acd8716b2551dbf 100644 (file)
@@ -41,7 +41,7 @@ static GtkWidget *label;
 static char *btn_labels[] = {"1","2","3","4",
                              "5","6","7","8",
                              "9","0",".","BS",
-                             "HZ","KZ","MZ","CR"
+                             "Hz","kHz","MHz","CR"
                             };
 
 static void cleanup() {
diff --git a/gpio.c b/gpio.c
index ffed31e6f38440110c5c9a433c0fe256fe64fc1d..640f61b45c2b501821c99e6a4cf84b213b168921 100644 (file)
--- a/gpio.c
+++ b/gpio.c
@@ -921,7 +921,7 @@ static encoder_changed(int action,int pos) {
       set_agc_gain(value);
       break;
     case ENCODER_ATTENUATION:
-      value=active_receiver->attenuation;
+      value=adc_attenuation[active_receiver->adc];
       value+=pos;
       if(value<0) {
         value=0;
diff --git a/meter.c b/meter.c
index cd6c9cb8390d63c206f9f2bde7ba64e613558612..358c851620e74d620815dbd433d559aab6f883f3 100644 (file)
--- a/meter.c
+++ b/meter.c
@@ -24,6 +24,7 @@
 #include <unistd.h>
 #include <math.h>
 
+#include "receiver.h"
 #include "meter.h"
 #include "wdsp.h"
 #include "radio.h"
@@ -212,7 +213,7 @@ fprintf(stderr,"meter_init: width=%d height=%d\n",width,height);
 }
 
 
-void meter_update(int meter_type,double value,double reverse,double exciter,double alc) {
+void meter_update(RECEIVER *rx,int meter_type,double value,double reverse,double exciter,double alc) {
   
   char text[128];
   char sf[32];
@@ -230,7 +231,7 @@ if(analog_meter) {
   switch(meter_type) {
     case SMETER:
       {
-      double level=value+(double)get_attenuation();
+      double level=value+(double)adc_attenuation[rx->adc];
       offset=210.0;
 
       int i;
@@ -527,7 +528,7 @@ if(analog_meter) {
       // value is dBm
       text_location=10;
       offset=5.0;
-      double level=value+(double)get_attenuation();
+      double level=value+(double)adc_attenuation[rx->adc];
       if(meter_width>=114) {
         //int db=meter_width/114; // S9+60 (9*6)+60
         //if(db>2) db=2;
diff --git a/meter.h b/meter.h
index aa98deb82c0c5321e68d179a6ebfb5a53faf8a83..720a49a5dcb3ff2b4162ff59a95e2b16efa3f930 100644 (file)
--- a/meter.h
+++ b/meter.h
@@ -30,6 +30,6 @@
 
 
 extern GtkWidget* meter_init(int width,int height,GtkWidget *parent);
-extern void meter_update(int meter_type,double value,double reverse,double exciter,double alc);
+extern void meter_update(RECEIVER *rx,int meter_type,double value,double reverse,double exciter,double alc);
 
 #endif
index e573ae034fc9636c188a9464c731fe83740cf668..33e45d49444394570cf00ac9f64cd580c0c8bc53 100644 (file)
@@ -854,10 +854,8 @@ static void new_protocol_high_priority() {
     if(isTransmitting()) {
       high_priority_buffer_to_radio[1443]=transmitter->attenuation;
     } else {
-      for(r=0;r<receivers;r++) {
-        i=r;
-        high_priority_buffer_to_radio[1443-i]=receiver[r]->attenuation;
-      }
+      high_priority_buffer_to_radio[1443]=adc_attenuation[0];
+      high_priority_buffer_to_radio[1442]=adc_attenuation[1];
     }
 
     int rc;
index 4dbbb3655d2bd7e027660b978bf743f59689b86e..80bd4692b7ee19fda7fae3ce19dcc52496c78f72 100644 (file)
@@ -144,6 +144,8 @@ static int psk_samples=0;
 static int psk_divisor=6;
 #endif
 
+static int local_ptt=0;
+
 static double micinputbuffer[MAX_BUFFER_SIZE*2];
 
 static int left_rx_sample;
@@ -489,43 +491,23 @@ static void process_ozy_input_buffer(char  *buffer) {
     control_in[3]=buffer[b++];
     control_in[4]=buffer[b++];
 
-    previous_ptt=ptt;
+    previous_ptt=local_ptt;
+    //previous_ptt=ptt;
     previous_dot=dot;
     previous_dash=dash;
     ptt=(control_in[0]&0x01)==0x01;
     dash=(control_in[0]&0x02)==0x02;
     dot=(control_in[0]&0x04)==0x04;
 
-/*
-if(ptt!=previous_ptt) {
-  fprintf(stderr,"ptt=%d\n",ptt);
-}
-if(dot!=previous_dot) {
-  fprintf(stderr,"dot=%d\n",dot);
-}
-if(dash!=previous_dash) {
-  fprintf(stderr,"dash=%d\n",dash);
-}
-    if(previous_ptt!=ptt && vfo[tx_vfo].mode!=modeCWU && vfo[tx_vfo].mode!=modeCWL) {
-      g_idle_add(ext_ptt_update,(gpointer)(long)(ptt));
-    } else if(previous_dot!=dot && (vfo[tx_vfo].mode==modeCWU || vfo[tx_vfo].mode==modeCWL)) {
-      g_idle_add(ext_ptt_update,(gpointer)(long)(dot));
-    } else if(previous_dash!=dash && (vfo[tx_vfo].mode==modeCWU || vfo[tx_vfo].mode==modeCWL)) {
-      g_idle_add(ext_ptt_update,(gpointer)(long)(dash));
-    }
-*/
-
+    local_ptt=dot;
     if(vfo[tx_vfo].mode==modeCWL || vfo[tx_vfo].mode==modeCWU) {
-      if(dot==0 && dash==0) {
-        ptt=0;
-      }
+      local_ptt=ptt|dot|dash;
     }
-
-    if(previous_ptt!=ptt) {
-//fprintf(stderr,"ptt=%d previous_ptt=%d dot=%d dash=%d vfo=%d mode=%d\n",ptt,previous_ptt,dot,dash,tx_vfo,vfo[tx_vfo].mode);
+    if(previous_ptt!=local_ptt) {
       g_idle_add(ext_ptt_update,(gpointer)(long)(ptt));
     }
 
+
     switch((control_in[0]>>3)&0x1F) {
       case 0:
         adc_overload=control_in[1]&0x01;
@@ -1038,7 +1020,7 @@ void ozy_send_buffer() {
         output_buffer[C3]=0x00;
   
         if(radio->device==DEVICE_HERMES || radio->device==DEVICE_ANGELIA || radio->device==DEVICE_ORION || radio->device==DEVICE_ORION2) {
-          output_buffer[C4]=0x20|receiver[0]->attenuation;
+          output_buffer[C4]=0x20|adc_attenuation[receiver[0]->adc];
         } else {
           output_buffer[C4]=0x00;
         }
@@ -1049,7 +1031,7 @@ void ozy_send_buffer() {
         output_buffer[C1]=0x00;
         if(receivers==2) {
           if(radio->device==DEVICE_HERMES || radio->device==DEVICE_ANGELIA || radio->device==DEVICE_ORION || radio->device==DEVICE_ORION2) {
-            output_buffer[C1]=0x20|receiver[1]->attenuation;
+            output_buffer[C1]=0x20|adc_attenuation[receiver[1]->adc];
           }
         }
         output_buffer[C2]=0x00;
diff --git a/radio.c b/radio.c
index 18f7fcb15c8253a94f1ffa7754ff3246fd08ffd9..35f4bedd05b4d1b12b118c29469ef6dbbd4edbcb 100644 (file)
--- a/radio.c
+++ b/radio.c
@@ -466,6 +466,9 @@ fprintf(stderr,"title: length=%d\n", (int)strlen(text));
   }
  
 
+  adc_attenuation[0]=0;
+  adc_attenuation[1]=0;
+
 //fprintf(stderr,"meter_calibration=%f display_calibration=%f\n", meter_calibration, display_calibration);
   radioRestoreState();
 
@@ -1035,10 +1038,6 @@ void set_attenuation(int value) {
     }
 }
 
-int get_attenuation() {
-    return active_receiver->attenuation;
-}
-
 void set_alex_rx_antenna(int v) {
     if(active_receiver->id==0) {
       active_receiver->alex_antenna=v;
@@ -1265,6 +1264,11 @@ fprintf(stderr,"radioRestoreState: %s\n",property_path);
     value=getProperty("rigctl_port_base");
     if(value) rigctl_port_base=atoi(value);
 
+    value=getProperty("adc_0_attenuation");
+    if(value) adc_attenuation[0]=atoi(value);
+    value=getProperty("adc_1_attenuation");
+    if(value) adc_attenuation[1]=atoi(value);
+
     sem_post(&property_sem);
 }
 
@@ -1427,6 +1431,10 @@ void radioSaveState() {
     setProperty("e3_encoder_action",value);
 #endif
 
+    sprintf(value,"%d",adc_attenuation[0]);
+    setProperty("adc_0_attenuation",value);
+    sprintf(value,"%d",adc_attenuation[1]);
+    setProperty("adc_1_attenuation",value);
 
     vfo_save_state();
     sprintf(value,"%d",receivers);
diff --git a/radio.h b/radio.h
index 5ca4ca02c88b623100eeeab8915f92c5a79eb912..9130f0e9e7b831dc3443cf39f1686fafa5ff4e0f 100644 (file)
--- a/radio.h
+++ b/radio.h
@@ -142,6 +142,7 @@ extern int mic_ptt_tip_bias_ring;
 int receivers;
 
 int adc[2];
+int adc_attenuation[2];
 
 int locked;
 
@@ -268,7 +269,6 @@ extern void calcTuneDriveLevel();
 extern void setSquelch(RECEIVER *rx);
 
 extern void set_attenuation(int value);
-extern int get_attenuation();
 extern void set_alex_rx_antenna(int v);
 extern void set_alex_tx_antenna(int v);
 extern void set_alex_attenuation(int v);
index 197252c0f65230533b04602b30ba908c90738a68..af09dd253163e4c757c55a0e6af29a333f961c8e 100644 (file)
@@ -221,9 +221,6 @@ void receiver_save_state(RECEIVER *rx) {
   sprintf(name,"receiver.%d.agc_hang_threshold",rx->id);
   sprintf(value,"%f",rx->agc_hang_threshold);
   setProperty(name,value);
-  sprintf(name,"receiver.%d.attenuation",rx->id);
-  sprintf(value,"%d",rx->attenuation);
-  setProperty(name,value);
 
   sprintf(name,"receiver.%d.dither",rx->id);
   sprintf(value,"%d",rx->dither);
@@ -380,9 +377,6 @@ fprintf(stderr,"receiver_restore_state: id=%d\n",rx->id);
   sprintf(name,"receiver.%d.agc_hang_threshold",rx->id);
   value=getProperty(name);
   if(value) rx->agc_hang_threshold=atof(value);
-  sprintf(name,"receiver.%d.attenuation",rx->id);
-  value=getProperty(name);
-  if(value) rx->attenuation=atoi(value);
 
   sprintf(name,"receiver.%d.dither",rx->id);
   value=getProperty(name);
@@ -775,7 +769,6 @@ fprintf(stderr,"create_pure_signal_receiver: id=%d buffer_size=%d\n",id,buffer_s
   rx->panadapter_low=-140;
 
   rx->volume=0.0;
-  rx->attenuation=0;
 
   rx->dither=0;
   rx->random=0;
@@ -911,7 +904,6 @@ fprintf(stderr,"create_receiver: id=%d default ddc=%d adc=%d\n",rx->id, rx->ddc,
   rx->waterfall_automatic=1;
 
   rx->volume=0.1;
-  rx->attenuation=0;
 
   rx->dither=0;
   rx->random=0;
index 58546af924ed947cb01d6f9059afcd33a971458c..90e6f7da6a39a8623059955e5a4b0b058ff5dd72 100644 (file)
@@ -82,7 +82,7 @@ typedef struct _receiver {
   int nr2_ae;
 
 
-  int attenuation;
+  //int attenuation;
   int alex_antenna;
   int alex_attenuation;
 
index adb52a4c7874feaac470bbb57e405f25aecad444..7ff3703c9724568e3809c654c68c07abeb77819b 100644 (file)
--- a/rigctl.c
+++ b/rigctl.c
@@ -2800,7 +2800,7 @@ void parse_cmd ( char * cmd_input,int len,int client_sock) {
                                             float calc_atten;
                                              if(len <=2) {
                                                //send_resp(client_sock,"RA0000;"); 
-                                               calc_atten = round((float)active_receiver->attenuation*99.0/30.0);
+                                               calc_atten = round((float)adc_attenuation[active_receiver->adc]*99.0/30.0);
                                                if(calc_atten > 99.0) {
                                                   calc_atten = 99.0;
                                                } 
@@ -3064,20 +3064,19 @@ void parse_cmd ( char * cmd_input,int len,int client_sock) {
                                             //  PowerSDR returns S9=0015 code. 
                                             //  Let's make S9 half scale or a value of 70.  
                                             double level=0.0;
+                                            int r=0;
 
                                             if(cmd_input[2] == '0') { 
-                                              level = GetRXAMeter(receiver[0]->id, smeter); 
+                                              r=0;
                                             } else if(cmd_input[2] == '1') { 
-                                              if(receivers==2) {
-                                                level = GetRXAMeter(receiver[1]->id, smeter); 
-                                              }
+                                              r=1;
                                             }
+                                            level = GetRXAMeter(receiver[r]->id, smeter); 
 
 
-                                            level = GetRXAMeter(active_receiver->id, smeter); 
                                             // Determine how high above 127 we are..making a range of 114 from S0 to S9+60db
                                             // 5 is a fugdge factor that shouldn't be there - but seems to get us to S9=SM015
-                                            level =  abs(127+(level + (double) get_attenuation()))+5;
+                                            level =  abs(127+(level + (double)adc_attenuation[receiver[r]->adc]))+5;
                                          
                                             // Clip the value just in case
                                             if(cmd_input[2] == '0') { 
index 4e82d193062b25e81ee873fd0788f4bd71a5a545..7b91d92a1aabc52a22bc4e3ff4e65a475750cbf2 100644 (file)
@@ -293,12 +293,12 @@ void rx_panadapter_update(RECEIVER *rx) {
     GetRXAAGCHangLevel(rx->id, &hang);
     GetRXAAGCThresh(rx->id, &thresh, 4096.0, (double)rx->sample_rate);
 
-    double knee_y=thresh+(double)get_attenuation();
+    double knee_y=thresh+(double)adc_attenuation[rx->adc];
     knee_y = floor((rx->panadapter_high - knee_y)
                         * (double) display_height
                         / (rx->panadapter_high - rx->panadapter_low));
 
-    double hang_y=hang+(double)get_attenuation();
+    double hang_y=hang+(double)adc_attenuation[rx->adc];
     hang_y = floor((rx->panadapter_high - hang_y)
                         * (double) display_height
                         / (rx->panadapter_high - rx->panadapter_low));
@@ -352,13 +352,13 @@ void rx_panadapter_update(RECEIVER *rx) {
   samples[0]=-200.0;
   samples[display_width-1]=-200.0;
 
-  s1=(double)samples[0]+(double)get_attenuation();
+  s1=(double)samples[0]+(double)adc_attenuation[rx->adc];
   s1 = floor((rx->panadapter_high - s1)
                         * (double) display_height
                         / (rx->panadapter_high - rx->panadapter_low));
   cairo_move_to(cr, 0.0, s1);
   for(i=1;i<display_width;i++) {
-    s2=(double)samples[i]+(double)get_attenuation();
+    s2=(double)samples[i]+(double)adc_attenuation[rx->adc];
     s2 = floor((rx->panadapter_high - s2)
                             * (double) display_height
                             / (rx->panadapter_high - rx->panadapter_low));
index b91cb498e77af7882621a5a538c7b39021982660..7588a36d2606d11341c2ef777d9e9705f2030436 100644 (file)
--- a/sliders.c
+++ b/sliders.c
@@ -100,7 +100,11 @@ int sliders_active_receiver_changed(void *data) {
   if(display_sliders) {
     gtk_range_set_value(GTK_RANGE(af_gain_scale),active_receiver->volume*100.0);
     gtk_range_set_value (GTK_RANGE(agc_scale),active_receiver->agc_gain);
-    gtk_range_set_value (GTK_RANGE(attenuation_scale),active_receiver->attenuation);
+    gtk_range_set_value (GTK_RANGE(attenuation_scale),adc_attenuation[active_receiver->adc]);
+
+    char title[64];
+    sprintf(title,"ATT (dB)"/*,active_receiver->adc*/);
+    gtk_label_set_text(GTK_LABEL(attenuation_label),title);
     sliders_update();
   }
   return FALSE;
@@ -113,14 +117,14 @@ int scale_timeout_cb(gpointer data) {
 }
 
 static void attenuation_value_changed_cb(GtkWidget *widget, gpointer data) {
-  active_receiver->attenuation=(int)gtk_range_get_value(GTK_RANGE(attenuation_scale));
-  set_attenuation(active_receiver->attenuation);
+  adc_attenuation[active_receiver->adc]=(int)gtk_range_get_value(GTK_RANGE(attenuation_scale));
+  set_attenuation(adc_attenuation[active_receiver->adc]);
 }
 
 void set_attenuation_value(double value) {
-  active_receiver->attenuation=(int)value;
+  adc_attenuation[active_receiver->adc]=(int)value;
   if(display_sliders) {
-    gtk_range_set_value (GTK_RANGE(attenuation_scale),active_receiver->attenuation);
+    gtk_range_set_value (GTK_RANGE(attenuation_scale),adc_attenuation[active_receiver->adc]);
   } else {
     if(scale_status!=ATTENUATION) {
       if(scale_status!=NONE) {
@@ -130,12 +134,14 @@ void set_attenuation_value(double value) {
       }
     }
     if(scale_status==NONE) {
+      char title[64];
+      sprintf(title,"Attenuation - ADC-%d (dB)",active_receiver->adc);
       scale_status=ATTENUATION;
-      scale_dialog=gtk_dialog_new_with_buttons("Attenuation (dB)",GTK_WINDOW(top_window),GTK_DIALOG_DESTROY_WITH_PARENT,NULL,NULL);
+      scale_dialog=gtk_dialog_new_with_buttons(title,GTK_WINDOW(top_window),GTK_DIALOG_DESTROY_WITH_PARENT,NULL,NULL);
       GtkWidget *content=gtk_dialog_get_content_area(GTK_DIALOG(scale_dialog));
       attenuation_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,0.0, 31.0, 1.00);
       gtk_widget_set_size_request (attenuation_scale, 400, 30);
-      gtk_range_set_value (GTK_RANGE(attenuation_scale),active_receiver->attenuation);
+      gtk_range_set_value (GTK_RANGE(attenuation_scale),adc_attenuation[active_receiver->adc]);
       gtk_widget_show(attenuation_scale);
       gtk_container_add(GTK_CONTAINER(content),attenuation_scale);
       scale_timer=g_timeout_add(2000,scale_timeout_cb,NULL);
@@ -143,11 +149,11 @@ void set_attenuation_value(double value) {
       int result=gtk_dialog_run(GTK_DIALOG(scale_dialog));
     } else {
       g_source_remove(scale_timer);
-      gtk_range_set_value (GTK_RANGE(attenuation_scale),active_receiver->attenuation);
+      gtk_range_set_value (GTK_RANGE(attenuation_scale),adc_attenuation[active_receiver->adc]);
       scale_timer=g_timeout_add(2000,scale_timeout_cb,NULL);
     }
   }
-  set_attenuation(active_receiver->attenuation);
+  set_attenuation(adc_attenuation[active_receiver->adc]);
 }
 
 static void agcgain_value_changed_cb(GtkWidget *widget, gpointer data) {
@@ -481,12 +487,14 @@ fprintf(stderr,"sliders_init: width=%d height=%d\n", width,height);
   gtk_grid_attach(GTK_GRID(sliders),agc_scale,4,0,2,1);
   g_signal_connect(G_OBJECT(agc_scale),"value_changed",G_CALLBACK(agcgain_value_changed_cb),NULL);
 
-  attenuation_label=gtk_label_new("ATT (dB):");
+  char title[64];
+  sprintf(title,"ATT (dB)"/*,active_receiver->adc*/);
+  attenuation_label=gtk_label_new(title);
   gtk_widget_show(attenuation_label);
   gtk_grid_attach(GTK_GRID(sliders),attenuation_label,6,0,1,1);
 
   attenuation_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,0.0, 31.0, 1.0);
-  gtk_range_set_value (GTK_RANGE(attenuation_scale),active_receiver->attenuation);
+  gtk_range_set_value (GTK_RANGE(attenuation_scale),adc_attenuation[active_receiver->adc]);
   gtk_widget_show(attenuation_scale);
   gtk_grid_attach(GTK_GRID(sliders),attenuation_scale,7,0,2,1);
   g_signal_connect(G_OBJECT(attenuation_scale),"value_changed",G_CALLBACK(attenuation_value_changed_cb),NULL);
index 5afcdc57bbe054761684b22a5579f61bcc468681..ad20013f387d73df35847cda00deb1261e008ac2 100644 (file)
@@ -48,7 +48,7 @@ static char *btn_labels[] = {"1","2","3",
                "4","5","6",
                "7","8","9",
                ".","0","BS",
-               "HZ","KZ","MZ"
+               "Hz","kHz","MHz"
                ,"CL"
               };
 
index 4f750274a09aff542295f7cfc78d00fd287a647e..b673f8026b1a3496ca80cf043c81e4f5869e2f6e 100644 (file)
@@ -173,7 +173,7 @@ void waterfall_update(RECEIVER *rx) {
     p=pixels;
     samples=rx->pixel_samples;
     for(i=0;i<width;i++) {
-            sample=samples[i]+get_attenuation();
+            sample=samples[i]+adc_attenuation[rx->adc];
             average+=(int)sample;
             if(sample<(float)rx->waterfall_low) {
                 *p++=colorLowR;