From a6dfbf9d31544a67845cd86e11d4c803c148a60e Mon Sep 17 00:00:00 2001 From: pa3gsb Date: Mon, 21 May 2018 15:05:36 +0200 Subject: [PATCH] radioberry using old-protocol --- old_protocol.c | 22 ++++++++++++++++++---- radio.c | 2 ++ radio.h | 1 + sliders.c | 11 ++++------- 4 files changed, 25 insertions(+), 11 deletions(-) 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]); -- 2.45.2