From: pa3gsb <pa3gsb@gmail.com>
Date: Mon, 21 May 2018 13:05:36 +0000 (+0200)
Subject: radioberry using old-protocol
X-Git-Url: https://git.rkrishnan.org/components/frontends/pb.xhtml?a=commitdiff_plain;h=a6dfbf9d31544a67845cd86e11d4c803c148a60e;p=pihpsdr.git

radioberry using old-protocol
---

diff --git a/old_protocol.c b/old_protocol.c
index 6ec5fee..c8da877 100644
--- a/old_protocol.c
+++ b/old_protocol.c
@@ -797,9 +797,18 @@ void ozy_send_buffer() {
     if(active_receiver->random) {
       output_buffer[C3]|=LT2208_RANDOM_ON;
     }
-    if(active_receiver->dither) {
-      output_buffer[C3]|=LT2208_DITHER_ON;
-    }
+#ifdef RADIOBERRY
+	if (rx_gain_slider[active_receiver->adc] > 31) 
+	{
+		output_buffer[C3]|=LT2208_DITHER_OFF;}
+	else {
+		output_buffer[C3]|=LT2208_DITHER_ON;
+	}
+#else
+	if(active_receiver->dither) {
+		output_buffer[C3]|=LT2208_DITHER_ON;
+	}
+#endif
     if(active_receiver->preamp) {
       output_buffer[C3]|=LT2208_GAIN_ON;
     }
@@ -1021,7 +1030,12 @@ void ozy_send_buffer() {
         if(radio->device==DEVICE_HERMES || radio->device==DEVICE_ANGELIA || radio->device==DEVICE_ORION || radio->device==DEVICE_ORION2) {
           output_buffer[C4]=0x20|adc_attenuation[receiver[0]->adc];
         } else {
-          output_buffer[C4]=0x00;
+#ifdef RADIOBERRY
+		  int att = 63 - rx_gain_slider[active_receiver->adc];
+          output_buffer[C4]=0x20|att;
+#else
+		  output_buffer[C4]=0x00;
+#endif
         }
         break;
       case 5:
diff --git a/radio.c b/radio.c
index a7decc3..8f4c9ba 100644
--- a/radio.c
+++ b/radio.c
@@ -468,6 +468,8 @@ fprintf(stderr,"title: length=%d\n", (int)strlen(text));
 
   adc_attenuation[0]=0;
   adc_attenuation[1]=0;
+  rx_gain_slider[0] = 0;
+  rx_gain_slider[1] = 0;
 
 //fprintf(stderr,"meter_calibration=%f display_calibration=%f\n", meter_calibration, display_calibration);
   radioRestoreState();
diff --git a/radio.h b/radio.h
index 9130f0e..c40848a 100644
--- a/radio.h
+++ b/radio.h
@@ -143,6 +143,7 @@ int receivers;
 
 int adc[2];
 int adc_attenuation[2];
+int rx_gain_slider[2];
 
 int locked;
 
diff --git a/sliders.c b/sliders.c
index ae7d7f1..10150bc 100644
--- a/sliders.c
+++ b/sliders.c
@@ -127,13 +127,10 @@ static void attenuation_value_changed_cb(GtkWidget *widget, gpointer data) {
   //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);
+  int rx_gain_slider_value = (int)gtk_range_get_value(GTK_RANGE(attenuation_scale));
+  rx_gain_slider[active_receiver->adc]=rx_gain_slider_value;
+  adc_attenuation[active_receiver->adc]= MAX((12 - rx_gain_slider_value), 0);
+  set_attenuation(adc_attenuation[active_receiver->adc]);
 #else
   adc_attenuation[active_receiver->adc]=(int)gtk_range_get_value(GTK_RANGE(attenuation_scale));
   set_attenuation(adc_attenuation[active_receiver->adc]);