]> git.rkrishnan.org Git - pihpsdr.git/commitdiff
rx gain slider
authorpa3gsb <pa3gsb@gmail.com>
Sun, 20 May 2018 15:47:15 +0000 (17:47 +0200)
committerpa3gsb <pa3gsb@gmail.com>
Sun, 20 May 2018 15:47:15 +0000 (17:47 +0200)
encoder_menu.c
gpio.c
radioberry.c
sliders.c

index 1fb47244d4d2e9a6be3e7e77e9f69ef91a4124ef..e3d5af093023b9fff84043fbc18ff352a31577b1 100644 (file)
@@ -251,8 +251,11 @@ void encoder_menu(GtkWidget *parent,int e) {
   g_signal_connect(b_agc_gain,"pressed",G_CALLBACK(action_select_cb),(gpointer *)ENCODER_AGC_GAIN);
 
   row++;
-
-  b_attenuation=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(b_agc_gain),"Attenuation");
+#ifdef RADIOBERRY
+       b_attenuation=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(b_agc_gain),"RX GAIN");
+#else
+       b_attenuation=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(b_agc_gain),"Attenuation");
+#endif
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b_attenuation), encoder_action==ENCODER_ATTENUATION);
   gtk_widget_show(b_attenuation);
   gtk_grid_attach(GTK_GRID(grid),b_attenuation,col,row,2,1);
diff --git a/gpio.c b/gpio.c
index beb40ce9675339c4f4f8c688b6fc525b7ff2a374..3aeff645364f1f8a7f2f91d81a8b4ef6d67ecc36 100644 (file)
--- a/gpio.c
+++ b/gpio.c
@@ -212,7 +212,11 @@ static int running=0;
 char *encoder_string[] = {
 "AF GAIN",
 "AGC GAIN",
-"ATTENUATION",
+#ifdef RADIOBERRY
+       "RX-GAIN",
+#else
+       "ATTENUATION",
+#endif
 "MIC GAIN",
 "DRIVE",
 "RIT",
@@ -1265,9 +1269,15 @@ static encoder_changed(int action,int pos) {
       value+=(double)pos;
       if(value<0.0) {
         value=0.0;
-      } else if (value>31.0) {
-        value=31.0;
+#ifdef RADIOBERRY
+      } else if (value>60.0) {
+        value=60.0;
       }
+#else
+         } else if (value>31.0) {
+        value=31.0;
+      }        
+#endif
       set_attenuation_value(value);
       break;
     case ENCODER_MIC_GAIN:
index cc99c8e0921eb6ce80af860014f3e947b2627c57..9678d94bc4ca3105fa3e209cf9ba88f92ef6836f 100644 (file)
@@ -54,7 +54,7 @@
 #define SPEED_192K                0x02
 #define SPEED_384K                0x03
 
-#define RECEIVED_SAMPLES 128
+#define RECEIVED_SAMPLES 64
 
 static GThread *radioberry_thread_id;
 static gpointer radioberry_thread(gpointer arg);
@@ -113,7 +113,7 @@ void radioberry_protocol_init(int rx,int pixels) {
        fprintf(stderr, "====================================================================\n");
        fprintf(stderr, "                      Radioberry V2.0 beta 2.\n");
        fprintf(stderr, "\n");
-       fprintf(stderr, "                    PIHPSDR plugin version 11-5-2018 \n");
+       fprintf(stderr, "                    PIHPSDR plugin version 19-5-2018 \n");
        fprintf(stderr, "\n");
        fprintf(stderr, "\n");
        fprintf(stderr, "                      Have fune Johan PA3GSB\n");
@@ -327,7 +327,7 @@ void rx1_spiReader(unsigned char iqdata[]) {
        }
        
        iqdata[0] = (sampleSpeed[0] & 0x03);
-       iqdata[1] = (((active_receiver->random << 6) & 0x40) | ((active_receiver->dither <<5) & 0x20) |  (radioberry_attenuation & 0x1F));
+       iqdata[1] = (((active_receiver->random << 6) & 0x40) | (~(radioberry_attenuation & 0x2F)));
        iqdata[2] = ((rxFrequency >> 24) & 0xFF);
        iqdata[3] = ((rxFrequency >> 16) & 0xFF);
        iqdata[4] = ((rxFrequency >> 8) & 0xFF);
index f5571fe4cd070447d4fae119a311e3e0e94e42d7..ae7d7f1cfc7c6f2016f031f1c464c4fbea25bfad 100644 (file)
--- a/sliders.c
+++ b/sliders.c
@@ -103,7 +103,11 @@ int sliders_active_receiver_changed(void *data) {
     gtk_range_set_value (GTK_RANGE(attenuation_scale),(double)adc_attenuation[active_receiver->adc]);
 
     char title[64];
+#ifdef RADIOBERRY
+       sprintf(title,"RX GAIN"/*,active_receiver->adc*/);
+#else
     sprintf(title,"ATT (dB)"/*,active_receiver->adc*/);
+#endif
     gtk_label_set_text(GTK_LABEL(attenuation_label),title);
     sliders_update();
   }
@@ -117,8 +121,23 @@ int scale_timeout_cb(gpointer data) {
 }
 
 static void attenuation_value_changed_cb(GtkWidget *widget, gpointer data) {
+#ifdef RADIOBERRY
+  //redfined the att slider to a rx-gain slider.
+  //AD9866 contains a pga amplifier from -12 - 48 dB
+  //from -12 to 0; the rx-gain slider functions as an att slider
+  //from 0 - 48 db; the rx-gain slider functions as a gain slider with att = 0;
+  //att set to 20 for good power measurement.
+  int rx_gain = (int)gtk_range_get_value(GTK_RANGE(attenuation_scale));
+  if (rx_gain > 12) {
+         adc_attenuation[active_receiver->adc]= 20;
+  } else {
+         adc_attenuation[active_receiver->adc]= 20 + (12- rx_gain);
+  }
+  set_attenuation(rx_gain);
+#else
   adc_attenuation[active_receiver->adc]=(int)gtk_range_get_value(GTK_RANGE(attenuation_scale));
   set_attenuation(adc_attenuation[active_receiver->adc]);
+#endif
 }
 
 void set_attenuation_value(double value) {
@@ -135,8 +154,12 @@ void set_attenuation_value(double value) {
     }
     if(scale_status==NONE) {
       char title[64];
+#ifdef RADIOBERRY
+         sprintf(title,"RX GAIN - ADC-%d (dB)",active_receiver->adc);
+#else
       sprintf(title,"Attenuation - ADC-%d (dB)",active_receiver->adc);
-      scale_status=ATTENUATION;
+#endif     
+         scale_status=ATTENUATION;
       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);
@@ -488,12 +511,20 @@ fprintf(stderr,"sliders_init: width=%d height=%d\n", width,height);
   g_signal_connect(G_OBJECT(agc_scale),"value_changed",G_CALLBACK(agcgain_value_changed_cb),NULL);
 
   char title[64];
+#ifdef RADIOBERRY
+       sprintf(title,"RX-GAIN:"/*,active_receiver->adc*/);
+#else
   sprintf(title,"ATT (dB)"/*,active_receiver->adc*/);
+#endif
   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);
+#ifdef RADIOBERRY
+       attenuation_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,0.0, 60.0, 1.0);
+#else
+       attenuation_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,0.0, 31.0, 1.0);
+#endif
   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);