From 20f32fad55086855a489b69ba9b48bc042dbbdfe Mon Sep 17 00:00:00 2001 From: pa3gsb Date: Sun, 20 May 2018 17:47:15 +0200 Subject: [PATCH] rx gain slider --- encoder_menu.c | 7 +++++-- gpio.c | 16 +++++++++++++--- radioberry.c | 6 +++--- sliders.c | 35 +++++++++++++++++++++++++++++++++-- 4 files changed, 54 insertions(+), 10 deletions(-) diff --git a/encoder_menu.c b/encoder_menu.c index 1fb4724..e3d5af0 100644 --- a/encoder_menu.c +++ b/encoder_menu.c @@ -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 beb40ce..3aeff64 100644 --- 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: diff --git a/radioberry.c b/radioberry.c index cc99c8e..9678d94 100644 --- a/radioberry.c +++ b/radioberry.c @@ -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); diff --git a/sliders.c b/sliders.c index f5571fe..ae7d7f1 100644 --- 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); -- 2.45.2