diff --git a/Makefile b/Makefile index 30d6b1b9..a27c99e1 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ GIT_DATE := $(firstword $(shell git --no-pager show --date=short --format="%ai" GIT_VERSION := $(shell git describe --abbrev=0 --tags) # uncomment the line below to include GPIO -GPIO_INCLUDE=GPIO +#GPIO_INCLUDE=GPIO # uncomment the line below to include MCP23017 I2C #I2C_INCLUDE=I2C @@ -85,19 +85,8 @@ endif ifeq ($(RADIOBERRY_INCLUDE),RADIOBERRY) RADIOBERRY_OPTIONS=-D RADIOBERRY -RADIOBERRYLIBS=-lpigpio -RADIOBERRY_SOURCES= \ -radioberry_discovery.c \ -radioberry.c -RADIOBERRY_HEADERS= \ -radioberry_discovery.h \ -radioberry.h -RADIOBERRY_OBJS= \ -radioberry_discovery.o \ -radioberry.o endif - ifeq ($(LIMESDR_INCLUDE),LIMESDR) LIMESDR_OPTIONS=-D LIMESDR SOAPYSDRLIBS=-lSoapySDR @@ -191,9 +180,9 @@ GTKLIBS=`pkg-config --libs gtk+-3.0` AUDIO_LIBS=-lasound #AUDIO_LIBS=-lsoundio -OPTIONS=-g -Wno-deprecated-declarations $(PURESIGNAL_OPTIONS) $(REMOTE_OPTIONS) $(RADIOBERRY_OPTIONS) $(USBOZY_OPTIONS) $(I2C_OPTIONS) $(GPIO_OPTIONS) $(LIMESDR_OPTIONS) $(FREEDV_OPTIONS) $(LOCALCW_OPTIONS) $(PSK_OPTIONS) $(STEMLAB_OPTIONS) -D GIT_DATE='"$(GIT_DATE)"' -D GIT_VERSION='"$(GIT_VERSION)"' $(DEBUG_OPTION) -O3 +OPTIONS=-g -Wno-deprecated-declarations $(PURESIGNAL_OPTIONS) $(REMOTE_OPTIONS) $(USBOZY_OPTIONS) $(I2C_OPTIONS) $(GPIO_OPTIONS) $(LIMESDR_OPTIONS) $(FREEDV_OPTIONS) $(LOCALCW_OPTIONS) $(RADIOBERRY_OPTIONS) $(PSK_OPTIONS) $(STEMLAB_OPTIONS) -D GIT_DATE='"$(GIT_DATE)"' -D GIT_VERSION='"$(GIT_VERSION)"' $(DEBUG_OPTION) -O3 -LIBS=-lrt -lm -lwdsp -lpthread $(AUDIO_LIBS) $(USBOZY_LIBS) $(PSKLIBS) $(GTKLIBS) $(GPIO_LIBS) $(RADIOBERRYLIBS) $(SOAPYSDRLIBS) $(FREEDVLIBS) $(STEMLAB_LIBS) +LIBS=-lrt -lm -lwdsp -lpthread $(AUDIO_LIBS) $(USBOZY_LIBS) $(PSKLIBS) $(GTKLIBS) $(GPIO_LIBS) $(SOAPYSDRLIBS) $(FREEDVLIBS) $(STEMLAB_LIBS) INCLUDES=$(GTKINCLUDES) COMPILE=$(CC) $(OPTIONS) $(INCLUDES) @@ -411,10 +400,10 @@ led.o \ ext.o \ error_handler.o -$(PROGRAM): $(OBJS) $(REMOTE_OBJS) $(USBOZY_OBJS) $(LIMESDR_OBJS) $(FREEDV_OBJS) $(LOCALCW_OBJS) $(I2C_OBJS) $(GPIO_OBJS) $(PSK_OBJS) $(RADIOBERRY_OBJS) $(PURESIGNAL_OBJS) $(STEMLAB_OBJS) - $(LINK) -o $(PROGRAM) $(OBJS) $(REMOTE_OBJS) $(USBOZY_OBJS) $(I2C_OBJS) $(GPIO_OBJS) $(LIMESDR_OBJS) $(FREEDV_OBJS) $(LOCALCW_OBJS) $(PSK_OBJS) $(RADIOBERRY_OBJS) $(PURESIGNAL_OBJS) $(STEMLAB_OBJS) $(LIBS) +$(PROGRAM): $(OBJS) $(REMOTE_OBJS) $(USBOZY_OBJS) $(LIMESDR_OBJS) $(FREEDV_OBJS) $(LOCALCW_OBJS) $(I2C_OBJS) $(GPIO_OBJS) $(PSK_OBJS) $(PURESIGNAL_OBJS) $(STEMLAB_OBJS) + $(LINK) -o $(PROGRAM) $(OBJS) $(REMOTE_OBJS) $(USBOZY_OBJS) $(I2C_OBJS) $(GPIO_OBJS) $(LIMESDR_OBJS) $(FREEDV_OBJS) $(LOCALCW_OBJS) $(PSK_OBJS) $(LIBS) $(PURESIGNAL_OBJS) $(STEMLAB_OBJS) -all: prebuild $(PROGRAM) $(HEADERS) $(REMOTE_HEADERS) $(RADIOBERRY_HEADERS) $(USBOZY_HEADERS) $(LIMESDR_HEADERS) $(FREEDV_HEADERS) $(LOCALCW_HEADERS) $(I2C_HEADERS) $(GPIO_HEADERS) $(PSK_HEADERS) $(PURESIGNAL_HEADERS) $(STEMLAB_HEADERS) $(SOURCES) $(REMOTE_SOURCES) $(USBOZY_SOURCES) $(LIMESDR_SOURCES) $(FREEDV_SOURCES) $(I2C_SOURCES) $(GPIO_SOURCES) $(PSK_SOURCES) $(RADIOBERRY_SOURCES) $(PURESIGNAL_SOURCES) $(STEMLAB_SOURCES) +all: prebuild $(PROGRAM) $(HEADERS) $(REMOTE_HEADERS) $(USBOZY_HEADERS) $(LIMESDR_HEADERS) $(FREEDV_HEADERS) $(LOCALCW_HEADERS) $(I2C_HEADERS) $(GPIO_HEADERS) $(PSK_HEADERS) $(PURESIGNAL_HEADERS) $(STEMLAB_HEADERS) $(SOURCES) $(REMOTE_SOURCES) $(USBOZY_SOURCES) $(LIMESDR_SOURCES) $(FREEDV_SOURCES) $(I2C_SOURCES) $(GPIO_SOURCES) $(PSK_SOURCES) $(PURESIGNAL_SOURCES) $(STEMLAB_SOURCES) prebuild: rm -f version.o diff --git a/Makefile.orig b/Makefile.orig index a43e6b9b..6e350397 100644 --- a/Makefile.orig +++ b/Makefile.orig @@ -4,7 +4,7 @@ GIT_DATE := $(firstword $(shell git --no-pager show --date=short --format="%ai" GIT_VERSION := $(shell git describe --abbrev=0 --tags) # uncomment the line below to include GPIO -GPIO_INCLUDE=GPIO +#GPIO_INCLUDE=GPIO # uncomment the line below to include MCP23017 I2C #I2C_INCLUDE=I2C @@ -16,10 +16,7 @@ GPIO_INCLUDE=GPIO #PSK_INCLUDE=PSK # uncomment the line to below include support for FreeDV codec2 -FREEDV_INCLUDE=FREEDV - -# uncomment the line below to include Pure Signal support -#PURESIGNAL_INCLUDE=PURESIGNAL +#FREEDV_INCLUDE=FREEDV # uncomment the line below to include Pure Signal support #PURESIGNAL_INCLUDE=PURESIGNAL @@ -28,11 +25,18 @@ FREEDV_INCLUDE=FREEDV #SX1509_INCLUDE=sx1509 # uncomment the line to below include support local CW keyer -LOCALCW_INCLUDE=LOCALCW +#LOCALCW_INCLUDE=LOCALCW # uncomment the line below to include support for STEMlab discovery #STEMLAB_DISCOVERY=STEMLAB_DISCOVERY +#uncomment the line below for the platform being compiled on +UNAME_N=raspberrypi +#UNAME_N=odroid +#UNAME_N=up +#UNAME_N=pine64 +#UNAME_N=jetsen + CC=gcc LINK=gcc @@ -76,24 +80,12 @@ endif # uncomment the line below for LimeSDR (uncomment line below) #LIMESDR_INCLUDE=LIMESDR -# uncomment the line below when Radioberry radio cape is plugged in +# uncomment the line below when Radioberry radio cape is plugged in (for now use emulator and old protocol) RADIOBERRY_INCLUDE=RADIOBERRY - ifeq ($(RADIOBERRY_INCLUDE),RADIOBERRY) RADIOBERRY_OPTIONS=-D RADIOBERRY -RADIOBERRYLIBS=-lpigpio -RADIOBERRY_SOURCES= \ -radioberry_discovery.c \ -radioberry.c -RADIOBERRY_HEADERS= \ -radioberry_discovery.h \ -radioberry.h -RADIOBERRY_OBJS= \ -radioberry_discovery.o \ -radioberry.o endif - ifeq ($(LIMESDR_INCLUDE),LIMESDR) LIMESDR_OPTIONS=-D LIMESDR SOAPYSDRLIBS=-lSoapySDR @@ -141,8 +133,10 @@ endif ifeq ($(LOCALCW_INCLUDE),LOCALCW) LOCALCW_OPTIONS=-D LOCALCW LOCALCW_SOURCES= \ +beep.c \ iambic.c LOCALCW_HEADERS= \ +beep.h \ iambic.h LOCALCW_OBJS= \ iambic.o @@ -150,11 +144,7 @@ endif ifeq ($(GPIO_INCLUDE),GPIO) GPIO_OPTIONS=-D GPIO -<<<<<<< HEAD - GPIO_LIBS=-lwiringPi -lpigpio -======= - GPIO_LIBS=-lwiringPi ->>>>>>> upstream/master + GPIO_LIBS=-lwiringPi -lpigpio GPIO_SOURCES= \ gpio.c \ encoder_menu.c @@ -189,13 +179,9 @@ GTKLIBS=`pkg-config --libs gtk+-3.0` AUDIO_LIBS=-lasound #AUDIO_LIBS=-lsoundio -OPTIONS=-g -Wno-deprecated-declarations $(PURESIGNAL_OPTIONS) $(REMOTE_OPTIONS) $(RADIOBERRY_OPTIONS) $(USBOZY_OPTIONS) $(I2C_OPTIONS) $(GPIO_OPTIONS) $(LIMESDR_OPTIONS) $(FREEDV_OPTIONS) $(LOCALCW_OPTIONS) $(PSK_OPTIONS) $(STEMLAB_OPTIONS) -D GIT_DATE='"$(GIT_DATE)"' -D GIT_VERSION='"$(GIT_VERSION)"' $(DEBUG_OPTION) -O3 +OPTIONS=-g -Wno-deprecated-declarations $(PURESIGNAL_OPTIONS) $(REMOTE_OPTIONS) $(USBOZY_OPTIONS) $(I2C_OPTIONS) $(GPIO_OPTIONS) $(LIMESDR_OPTIONS) $(FREEDV_OPTIONS) $(LOCALCW_OPTIONS) $(RADIOBERRY_OPTIONS) $(PSK_OPTIONS) $(STEMLAB_OPTIONS) -D GIT_DATE='"$(GIT_DATE)"' -D GIT_VERSION='"$(GIT_VERSION)"' $(DEBUG_OPTION) -O3 -<<<<<<< HEAD -LIBS=-lrt -lm -lwdsp -lpthread $(AUDIO_LIBS) $(USBOZY_LIBS) $(PSKLIBS) $(GTKLIBS) $(GPIO_LIBS) $(RADIOBERRYLIBS) $(SOAPYSDRLIBS) $(FREEDVLIBS) $(STEMLAB_LIBS) -======= LIBS=-lrt -lm -lwdsp -lpthread $(AUDIO_LIBS) $(USBOZY_LIBS) $(PSKLIBS) $(GTKLIBS) $(GPIO_LIBS) $(SOAPYSDRLIBS) $(FREEDVLIBS) $(STEMLAB_LIBS) ->>>>>>> upstream/master INCLUDES=$(GTKINCLUDES) COMPILE=$(CC) $(OPTIONS) $(INCLUDES) @@ -413,10 +399,15 @@ led.o \ ext.o \ error_handler.o +<<<<<<< HEAD +$(PROGRAM): $(OBJS) $(REMOTE_OBJS) $(USBOZY_OBJS) $(LIMESDR_OBJS) $(FREEDV_OBJS) $(LOCALCW_OBJS) $(I2C_OBJS) $(GPIO_OBJS) $(PSK_OBJS) $(PURESIGNAL_OBJS) $(STEMLAB_OBJS) + $(LINK) -o $(PROGRAM) $(OBJS) $(REMOTE_OBJS) $(USBOZY_OBJS) $(I2C_OBJS) $(GPIO_OBJS) $(LIMESDR_OBJS) $(FREEDV_OBJS) $(LOCALCW_OBJS) $(PSK_OBJS) $(LIBS) $(PURESIGNAL_OBJS) $(STEMLAB_OBJS) +======= $(PROGRAM): $(OBJS) $(REMOTE_OBJS) $(USBOZY_OBJS) $(LIMESDR_OBJS) $(FREEDV_OBJS) $(LOCALCW_OBJS) $(I2C_OBJS) $(GPIO_OBJS) $(PSK_OBJS) $(RADIOBERRY_OBJS) $(PURESIGNAL_OBJS) $(STEMLAB_OBJS) - $(LINK) -o $(PROGRAM) $(OBJS) $(REMOTE_OBJS) $(USBOZY_OBJS) $(I2C_OBJS) $(GPIO_OBJS) $(LIMESDR_OBJS) $(FREEDV_OBJS) $(LOCALCW_OBJS) $(PSK_OBJS) $(LIBS) $(RADIOBERRY_OBJS) $(PURESIGNAL_OBJS) $(STEMLAB_OBJS) + $(LINK) -o $(PROGRAM) $(OBJS) $(REMOTE_OBJS) $(USBOZY_OBJS) $(I2C_OBJS) $(GPIO_OBJS) $(LIMESDR_OBJS) $(FREEDV_OBJS) $(LOCALCW_OBJS) $(PSK_OBJS) $(RADIOBERRY_OBJS) $(PURESIGNAL_OBJS) $(STEMLAB_OBJS) $(LIBS) +>>>>>>> upstream/master -all: prebuild $(PROGRAM) $(HEADERS) $(REMOTE_HEADERS) $(RADIOBERRY_HEADERS) $(USBOZY_HEADERS) $(LIMESDR_HEADERS) $(FREEDV_HEADERS) $(LOCALCW_HEADERS) $(I2C_HEADERS) $(GPIO_HEADERS) $(PSK_HEADERS) $(PURESIGNAL_HEADERS) $(STEMLAB_HEADERS) $(SOURCES) $(REMOTE_SOURCES) $(USBOZY_SOURCES) $(LIMESDR_SOURCES) $(FREEDV_SOURCES) $(I2C_SOURCES) $(GPIO_SOURCES) $(PSK_SOURCES) $(RADIOBERRY_SOURCES) $(PURESIGNAL_SOURCES) $(STEMLAB_SOURCES) +all: prebuild $(PROGRAM) $(HEADERS) $(REMOTE_HEADERS) $(USBOZY_HEADERS) $(LIMESDR_HEADERS) $(FREEDV_HEADERS) $(LOCALCW_HEADERS) $(I2C_HEADERS) $(GPIO_HEADERS) $(PSK_HEADERS) $(PURESIGNAL_HEADERS) $(STEMLAB_HEADERS) $(SOURCES) $(REMOTE_SOURCES) $(USBOZY_SOURCES) $(LIMESDR_SOURCES) $(FREEDV_SOURCES) $(I2C_SOURCES) $(GPIO_SOURCES) $(PSK_SOURCES) $(PURESIGNAL_SOURCES) $(STEMLAB_SOURCES) prebuild: rm -f version.o diff --git a/audio.c b/audio.c index cb668d5c..923685aa 100644 --- a/audio.c +++ b/audio.c @@ -33,9 +33,6 @@ #include "new_protocol.h" #include "old_protocol.h" -#ifdef RADIOBERRY -#include "radioberry.h" -#endif #include "radio.h" #include "receiver.h" #include "audio.h" @@ -198,11 +195,6 @@ fprintf(stderr,"audio_open_input: %d\n",transmitter->input_device); case NEW_PROTOCOL: mic_buffer_size = 64; break; -#ifdef RADIOBERRY - case RADIOBERRY_PROTOCOL: - mic_buffer_size = 1024; - break; -#endif default: break; } @@ -432,11 +424,6 @@ fprintf(stderr,"mic_read_thread: mic_buffer_size=%d\n",mic_buffer_size); case NEW_PROTOCOL: new_protocol_process_local_mic(mic_buffer,1); break; -#ifdef RADIOBERRY - case RADIOBERRY_PROTOCOL: - radioberry_protocol_process_local_mic(mic_buffer,1); - break; -#endif default: break; } diff --git a/discovered.h b/discovered.h index 85976bcc..cc0ac108 100644 --- a/discovered.h +++ b/discovered.h @@ -53,10 +53,6 @@ #define LIMESDR_USB_DEVICE 0 #endif -#ifdef RADIOBERRY -#define RADIOBERRY_SPI_DEVICE 100 -#endif - #define STATE_AVAILABLE 2 #define STATE_SENDING 3 @@ -65,9 +61,7 @@ #ifdef LIMESDR #define LIMESDR_PROTOCOL 2 #endif -#ifdef RADIOBERRY -#define RADIOBERRY_PROTOCOL 3 -#endif + #ifdef REMOTE #define REMOTE_PROTOCOL 4 #endif diff --git a/discovery.c b/discovery.c index 96e1307a..a66cc4a3 100644 --- a/discovery.c +++ b/discovery.c @@ -37,12 +37,6 @@ #ifdef USBOZY #include "ozyio.h" #endif -#ifdef RADIOBERRY -#include "radioberry_discovery.h" -#endif -#ifdef RADIOBERRY -#include "radioberry.h" -#endif #ifdef REMOTE #include "remote_radio.h" #endif @@ -134,13 +128,8 @@ fprintf(stderr,"discovery\n"); lime_discovery(); #endif -#ifdef RADIOBERRY - status_text("Radioberry SDR ... Discovering Device"); - radioberry_discovery(); -#endif status_text("Discovery"); - - + if(devices==0) { gdk_window_set_cursor(gtk_widget_get_window(top_window),gdk_cursor_new(GDK_ARROW)); discovery_dialog = gtk_dialog_new(); @@ -244,11 +233,6 @@ fprintf(stderr,"%p Protocol=%d name=%s\n",d,d->protocol,d->name); d->name); break; #endif -#ifdef RADIOBERRY - case RADIOBERRY_PROTOCOL: - sprintf(text,"%s\n",d->name); - break; -#endif #ifdef STEMLAB_DISCOVERY case STEMLAB_PROTOCOL: sprintf(text, "STEMlab (%02X:%02X:%02X:%02X:%02X:%02X) on %s", diff --git a/encoder_menu.c b/encoder_menu.c index 1fb47244..e3d5af09 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/exit_menu.c b/exit_menu.c index 409ef13e..aa3f2857 100644 --- a/exit_menu.c +++ b/exit_menu.c @@ -67,11 +67,6 @@ static gboolean exit_cb (GtkWidget *widget, GdkEventButton *event, gpointer data case LIMESDR_PROTOCOL: lime_protocol_stop(); break; -#endif -#ifdef RADIOBERRY - case RADIOBERRY_PROTOCOL: - radioberry_protocol_stop(); - break; #endif } radioSaveState(); @@ -93,11 +88,6 @@ static gboolean reboot_cb (GtkWidget *widget, GdkEventButton *event, gpointer da case LIMESDR_PROTOCOL: lime_protocol_stop(); break; -#endif -#ifdef RADIOBERRY - case RADIOBERRY_PROTOCOL: - radioberry_protocol_stop(); - break; #endif } radioSaveState(); @@ -120,11 +110,6 @@ static gboolean shutdown_cb (GtkWidget *widget, GdkEventButton *event, gpointer case LIMESDR_PROTOCOL: lime_protocol_stop(); break; -#endif -#ifdef RADIOBERRY - case RADIOBERRY_PROTOCOL: - radioberry_protocol_stop(); - break; #endif } radioSaveState(); diff --git a/general_menu.c b/general_menu.c index 9645c554..91685446 100644 --- a/general_menu.c +++ b/general_menu.c @@ -186,12 +186,7 @@ void general_menu(GtkWidget *parent) { gtk_grid_attach(GTK_GRID(grid),vfo_divisor,4,2,1,1); g_signal_connect(vfo_divisor,"value_changed",G_CALLBACK(vfo_divisor_value_changed_cb),NULL); - if(protocol==ORIGINAL_PROTOCOL || protocol==NEW_PROTOCOL -#ifdef RADIOBERRY - || protocol==RADIOBERRY_PROTOCOL) { -#else - ){ -#endif + if(protocol==ORIGINAL_PROTOCOL || protocol==NEW_PROTOCOL){ if((protocol==NEW_PROTOCOL && device==NEW_DEVICE_ORION) || (protocol==NEW_PROTOCOL && device==NEW_DEVICE_ORION2) || @@ -218,10 +213,7 @@ void general_menu(GtkWidget *parent) { gtk_grid_attach(GTK_GRID(grid),bias_b,3,4,1,1); g_signal_connect(bias_b,"toggled",G_CALLBACK(bias_cb),NULL); } - -#ifdef RADIOBERRY - if (protocol==ORIGINAL_PROTOCOL || protocol==NEW_PROTOCOL) { -#endif + GtkWidget *alex_b=gtk_check_button_new_with_label("ALEX"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (alex_b), filter_board==ALEX); gtk_grid_attach(GTK_GRID(grid),alex_b,1,1,1,1); @@ -232,20 +224,12 @@ void general_menu(GtkWidget *parent) { g_signal_connect(alex_b,"toggled",G_CALLBACK(alex_cb),apollo_b); g_signal_connect(apollo_b,"toggled",G_CALLBACK(apollo_cb),alex_b); -#ifdef RADIOBERRY - } -#endif } GtkWidget *sample_rate_label=gtk_label_new("Sample Rate:"); gtk_grid_attach(GTK_GRID(grid),sample_rate_label,0,1,1,1); - if(protocol==ORIGINAL_PROTOCOL || protocol==NEW_PROTOCOL - #ifdef RADIOBERRY - || protocol==RADIOBERRY_PROTOCOL) { -#else - ){ -#endif + if(protocol==ORIGINAL_PROTOCOL || protocol==NEW_PROTOCOL){ GtkWidget *sample_rate_48=gtk_radio_button_new_with_label(NULL,"48000"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sample_rate_48), sample_rate==48000); gtk_grid_attach(GTK_GRID(grid),sample_rate_48,0,2,1,1); diff --git a/gpio.c b/gpio.c index beb40ce9..b11ad535 100644 --- a/gpio.c +++ b/gpio.c @@ -62,9 +62,6 @@ int settle_time=DEFAULT_SETTLE_TIME; static gint release_timer=-1; -#ifdef RADIOBERRY -#include -#endif #ifdef CONTROLLER2 @@ -212,7 +209,11 @@ static int running=0; char *encoder_string[] = { "AF GAIN", "AGC GAIN", -"ATTENUATION", +#ifdef RADIOBERRY + "RX-GAIN", +#else + "ATTENUATION", +#endif "MIC GAIN", "DRIVE", "RIT", @@ -997,13 +998,6 @@ int gpio_init() { gpio_restore_state(); wiringPiSetup(); // use WiringPi pin numbers - -#ifdef RADIOBERRY - if (gpioInitialise() < 0) { - fprintf(stderr,"radioberry_protocol: gpio could not be initialized. \n"); - exit(-1); - } -#endif if(ENABLE_VFO_ENCODER) { #ifdef CONTROLLER2 @@ -1265,9 +1259,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/main.c b/main.c index 16628ff6..b17a210a 100644 --- a/main.c +++ b/main.c @@ -37,9 +37,6 @@ #include "discovered.h" #include "configure.h" #include "gpio.h" -#ifdef RADIOBERRY -#include "radioberry.h" -#endif #include "wdsp.h" #include "new_menu.h" #include "radio.h" @@ -113,11 +110,6 @@ gboolean main_delete (GtkWidget *widget) { case LIMESDR_PROTOCOL: lime_protocol_stop(); break; -#endif -#ifdef RADIOBERRY - case RADIOBERRY_PROTOCOL: - radioberry_protocol_stop(); - break; #endif } radioSaveState(); diff --git a/old_discovery.c b/old_discovery.c index 87992da3..57ea09e3 100644 --- a/old_discovery.c +++ b/old_discovery.c @@ -178,7 +178,11 @@ fprintf(stderr,"discover_receive_thread\n"); strcpy(discovered[devices].name,"Orion"); break; case DEVICE_HERMES_LITE: - strcpy(discovered[devices].name,"Hermes Lite"); + #ifdef RADIOBERRY + strcpy(discovered[devices].name,"Radioberry"); + #else + strcpy(discovered[devices].name,"Hermes Lite"); + #endif break; case DEVICE_ORION2: strcpy(discovered[devices].name,"Orion 2"); @@ -229,11 +233,18 @@ fprintf(stderr,"old_discovery\n"); while (ifa) { g_main_context_iteration(NULL, 0); if (ifa->ifa_addr && ifa->ifa_addr->sa_family == AF_INET) { + #ifdef RADIOBERRY + if((ifa->ifa_flags&IFF_UP)==IFF_UP + && (ifa->ifa_flags&IFF_RUNNING)==IFF_RUNNING) { + discover(ifa); + } + #else if((ifa->ifa_flags&IFF_UP)==IFF_UP && (ifa->ifa_flags&IFF_RUNNING)==IFF_RUNNING && (ifa->ifa_flags&IFF_LOOPBACK)!=IFF_LOOPBACK) { discover(ifa); } + #endif } ifa = ifa->ifa_next; } diff --git a/old_protocol.c b/old_protocol.c index b3deec33..3459bec2 100644 --- a/old_protocol.c +++ b/old_protocol.c @@ -544,8 +544,13 @@ static void process_ozy_input_buffer(char *buffer) { #ifdef PURESIGNAL nreceivers=(RECEIVERS*2)+1; #else - nreceivers=RECEIVERS; + #ifdef RADIOBERRY + nreceivers = receivers; + #else + nreceivers=RECEIVERS; + #endif #endif + int iq_samples=(512-8)/((nreceivers*6)+2); for(i=0;irandom) { 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; } @@ -834,8 +848,13 @@ void ozy_send_buffer() { nreceivers=(RECEIVERS*2)-1; nreceivers+=1; // for PS TX Feedback #else - nreceivers=RECEIVERS-1; + #ifdef RADIOBERRY + nreceivers = receivers-1; + #else + nreceivers=RECEIVERS-1; + #endif #endif + output_buffer[C4]|=nreceivers<<3; if(isTransmitting()) { @@ -907,8 +926,13 @@ void ozy_send_buffer() { #ifdef PURESIGNAL nreceivers=(RECEIVERS*2)+1; #else - nreceivers=RECEIVERS; + #ifdef RADIOBERRY + nreceivers = receivers; + #else + nreceivers=RECEIVERS; + #endif #endif + if(current_rxdevice==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 e5b3cd17..658c8f54 100644 --- a/radio.c +++ b/radio.c @@ -45,9 +45,6 @@ #include "new_menu.h" #include "new_protocol.h" #include "old_protocol.h" -#ifdef RADIOBERRY -#include "radioberry.h" -#endif #include "store.h" #ifdef LIMESDR #include "lime_protocol.h" @@ -430,11 +427,6 @@ fprintf(stderr,"title: length=%d\n", (int)strlen(text)); case LIMESDR_PROTOCOL: sprintf(property_path,"limesdr.props"); break; -#endif -#ifdef RADIOBERRY - case RADIOBERRY_PROTOCOL: - sprintf(property_path,"radioberry.props"); - break; #endif } @@ -468,6 +460,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(); @@ -577,11 +571,6 @@ fprintf(stderr,"Create %d receivers: height=%d\n",receivers,rx_height); case LIMESDR_PROTOCOL: lime_protocol_init(0,display_width,receiver[0]->sample_rate); break; -#endif -#ifdef RADIOBERRY - case RADIOBERRY_PROTOCOL: - radioberry_protocol_init(0,display_width); - break; #endif } @@ -921,9 +910,6 @@ void setFrequency(long long f) { switch(protocol) { case NEW_PROTOCOL: case ORIGINAL_PROTOCOL: -#ifdef RADIOBERRY - case RADIOBERRY_PROTOCOL: -#endif if(vfo[v].ctun) { long long minf=vfo[v].frequency-(long long)(active_receiver->sample_rate/2); long long maxf=vfo[v].frequency+(long long)(active_receiver->sample_rate/2); @@ -958,9 +944,6 @@ fprintf(stderr,"setFrequency: %lld\n",f); schedule_high_priority(); break; case ORIGINAL_PROTOCOL: -#ifdef RADIOBERRY - case RADIOBERRY_PROTOCOL: -#endif break; #ifdef LIMESDR case LIMESDR_PROTOCOL: @@ -1275,7 +1258,12 @@ fprintf(stderr,"radioRestoreState: %s\n",property_path); if(value) adc_attenuation[0]=atoi(value); value=getProperty("adc_1_attenuation"); if(value) adc_attenuation[1]=atoi(value); - + + value=getProperty("rx1_gain_slider"); + if(value) rx_gain_slider[0]=atoi(value); + value=getProperty("rx2_gain_slider"); + if(value) rx_gain_slider[1]=atoi(value); + sem_post(&property_sem); } @@ -1442,7 +1430,12 @@ void radioSaveState() { setProperty("adc_0_attenuation",value); sprintf(value,"%d",adc_attenuation[1]); setProperty("adc_1_attenuation",value); - + + sprintf(value,"%d",rx_gain_slider[0]); + setProperty("rx1_gain_slider",value); + sprintf(value,"%d",rx_gain_slider[1]); + setProperty("rx2_gain_slider",value); + vfo_save_state(); sprintf(value,"%d",receivers); setProperty("receivers",value); diff --git a/radio.h b/radio.h index 0ec654f3..84d30eb3 100644 --- a/radio.h +++ b/radio.h @@ -144,6 +144,7 @@ int receivers; int adc[2]; int adc_attenuation[2]; +int rx_gain_slider[2]; int locked; diff --git a/radioberry.c b/radioberry.c deleted file mode 100644 index 9f8bf699..00000000 --- a/radioberry.c +++ /dev/null @@ -1,544 +0,0 @@ -/* Copyright (C) -* 2017 - Johan Maas, PA3GSB -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -* -*/ - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "audio.h" - -#include "band.h" -#include "channel.h" -#include "discovered.h" -#include "mode.h" -#include "filter.h" -#include "old_protocol.h" -#include "radio.h" -#include "toolbar.h" -#include "vox.h" -#include -#ifdef PSK -#include "psk.h" -#endif -#include "receiver.h" -#include "transmitter.h" -#include "vfo.h" -#include -#include "ext.h" - -#define SPEED_48K 0x00 -#define SPEED_96K 0x01 -#define SPEED_192K 0x02 -#define SPEED_384K 0x03 - -static int display_width; -static int running; -static int sampleSpeed =0; - -unsigned char tx_iqdata[6]; - -static GThread *radioberry_thread_id; -static gpointer radioberry_thread(gpointer arg); - -static GThread *rx_stream_thread_id; -static gpointer rx_stream_thread(gpointer arg); - -static void setSampleSpeed(int r); -static void handleReceiveStream(int r); - -struct timeval rx1_t0; -struct timeval rx1_t1; -struct timeval rx2_t0; -struct timeval rx2_t1; -struct timeval t10; -struct timeval t11; -struct timeval t20; -struct timeval t21; -float elapsed; - -void spiWriter(); -void rx1_spiReader(); -void rx2_spiReader(); - -int prev_drive_level; - -static int rx1_count =0; -static int rx2_count =0; -static int txcount =0; - -GMutex buf_rx1_mutex; -GMutex buf_rx2_mutex; -GMutex mutex_rxtx; - -#define MAX_RX_BUFFER (24000) - -double buffer_rx1[MAX_RX_BUFFER][2]; -int fill_rx1 = 0; -int use_rx1 = 0; -sem_t empty; -sem_t full; - -void put_rx1(unsigned char[]); -void get_rx1(double buffer[]); - -double buffer_rx2[MAX_RX_BUFFER][2]; -int fill_rx2 = 0; -int use_rx2 = 0; -sem_t empty_rx2; -sem_t full_rx2; - -void put_rx2(unsigned char[]); -void get_rx2(double buffer[]); - -#ifdef PSK -static int psk_samples=0; -static int psk_divisor=6; -#endif - -static int rx1_spi_handler; -static int rx2_spi_handler; - - -#define HANDLER_STEADY_TIME_US 5000 -void setup_handler(int pin, gpioAlertFunc_t pAlert) { - gpioSetMode(pin, PI_INPUT); - gpioSetPullUpDown(pin,PI_PUD_UP); - // give time to settle to avoid false triggers - usleep(10000); - gpioSetAlertFunc(pin, pAlert); - gpioGlitchFilter(pin, HANDLER_STEADY_TIME_US); -} - -void cwPTT_Alert(int gpio, int level, uint32_t tick) { - //fprintf(stderr,"radioberry ptt swith %d 0=ptt off and 1=ptt on\n", level); - //fprintf(stderr,"%d - %d -%d - %d\n", running, cw_breakin, transmitter->mode, level); - if (running && cw_breakin && (transmitter->mode==modeCWU || transmitter->mode==modeCWL)){ - g_idle_add(ext_mox_update,(gpointer)level); - } -} - -float timedifference_msec(struct timeval t0, struct timeval t1) -{ - return (t1.tv_sec - t0.tv_sec) * 1000.0f + (t1.tv_usec - t0.tv_usec) / 1000.0f; -} - -void radioberry_protocol_init(int rx,int pixels) { - int i; - - sem_init(&empty, 0, MAX_RX_BUFFER); - sem_init(&full, 0, 0); - sem_init(&empty_rx2, 0, MAX_RX_BUFFER); - sem_init(&full_rx2, 0, 0); - - fprintf(stderr,"radioberry_protocol_init\n"); - display_width=pixels; - fprintf(stderr,"radioberry_protocol: buffer size: =%d\n", buffer_size); - -#ifndef GPIO - if (gpioInitialise() < 0) { - fprintf(stderr,"radioberry_protocol: gpio could not be initialized. \n"); - exit(-1); - } -#endif - - gpioSetMode(13, PI_INPUT); //rx1_FIFOEmpty - gpioSetMode(16, PI_INPUT); //rx2_FIFOEmpty - gpioSetMode(20, PI_INPUT); - gpioSetMode(21, PI_OUTPUT); - - setup_handler(17, cwPTT_Alert); - - rx1_spi_handler = spiOpen(0, 15625000, 49155); //channel 0 - if (rx1_spi_handler < 0) { - fprintf(stderr,"radioberry_protocol: spi bus rx1 could not be initialized. \n"); - exit(-1); - } - - rx2_spi_handler = spiOpen(1, 15625000, 49155); //channel 1 - if (rx2_spi_handler < 0) { - fprintf(stderr,"radioberry_protocol: spi bus rx2 could not be initialized. \n"); - exit(-1); - } - - running=1; - printf("init done \n"); - - if(transmitter->local_microphone) { - if(audio_open_input()!=0) { - fprintf(stderr,"audio_open_input failed\n"); - transmitter->local_microphone=0; - } - } - - radioberry_thread_id = g_thread_new( "radioberry", radioberry_thread, NULL); - if( ! radioberry_thread_id ) - { - fprintf(stderr,"g_thread_new failed on radioberry_thread\n"); - exit( -1 ); - } - fprintf(stderr, "radioberry_thread: id=%p\n",radioberry_thread_id); - - rx_stream_thread_id = g_thread_new( "rx-streaming", rx_stream_thread, NULL); - if( ! rx_stream_thread_id ) - { - fprintf(stderr,"g_thread_new failed on rx_stream_thread\n"); - exit( -1 ); - } - fprintf(stderr, "rx1-streaming: id=%p\n",rx_stream_thread_id); -} - -static gpointer rx_stream_thread(gpointer arg) { - - double _iqdata[2]; - - fprintf(stderr, "radioberry_protocol: rx_stream_thread\n"); - - while(running) { - - get_rx1(_iqdata); - // add the samples to the receiver.. - add_iq_samples(receiver[0], _iqdata[0], _iqdata[1]); - - if (receivers==2) { - get_rx2(_iqdata); - // add the samples to the receiver.. - add_iq_samples(receiver[1], _iqdata[0], _iqdata[1]); - }; - } - - fprintf(stderr, "radioberry_protocol stop: rx_stream_thread\n"); -} - - - -static gpointer radioberry_thread(gpointer arg) { - fprintf(stderr, "radioberry_protocol: radioberry_thread\n"); - - gettimeofday(&t20, 0); - gettimeofday(&rx1_t0, 0); - gettimeofday(&rx2_t0, 0); - - gpioSetMode(13, PI_INPUT); - gpioSetMode(16, PI_INPUT); - gpioSetMode(20, PI_INPUT); - gpioSetMode(21, PI_OUTPUT); - - while(running) { - - if (!isTransmitting()) - { - g_mutex_lock(&mutex_rxtx); - - gpioWrite(21, 0); - - rx1_spiReader(); - rx2_spiReader(); - - g_mutex_unlock(&mutex_rxtx); - } - } - - fprintf(stderr, "radioberry_protocol stop: radioberry_thread\n"); -} - -void radioberry_protocol_iq_samples(int isample,int qsample) { - - g_mutex_lock(&mutex_rxtx); - - int power=0; - if(tune && !transmitter->tune_use_drive) { - power=(int)((double)transmitter->drive_level/100.0*(double)transmitter->tune_percent); - } else { - power=transmitter->drive_level; - } - - tx_iqdata[0] = 0; - tx_iqdata[1] = power / 6.4; // convert drive level from 0-255 to 0-39 steps of 0.5dB to control AD9866) - if (prev_drive_level != transmitter->drive_level) { - printf("drive level %d - corrected drive level %d \n", transmitter->drive_level, tx_iqdata[1]); - prev_drive_level = transmitter->drive_level; - } - tx_iqdata[2] = isample>>8; - tx_iqdata[3] = isample; - tx_iqdata[4] = qsample>>8; - tx_iqdata[5] = qsample; - - spiWriter(); - - g_mutex_unlock(&mutex_rxtx); -} - -void *radioberry_protocol_process_local_mic(unsigned char *buffer,int le) { - int b; - short mic_sample; - // always 48000 samples per second - - b=0; - int i; - for(i=0;i<1024;i++) { - if(le) { - mic_sample = (short)((buffer[b++]&0xFF) | (buffer[b++]<<8)); - } else { - mic_sample = (short)((buffer[b++]<<8) | (buffer[b++]&0xFF)); - } - add_mic_sample(transmitter,mic_sample); - } -} - -void setSampleSpeed(int r) { - - switch(receiver[r]->sample_rate) { - case 48000: - sampleSpeed=SPEED_48K; - break; - case 96000: - sampleSpeed=SPEED_96K; - break; - case 192000: - sampleSpeed=SPEED_192K; - break; - case 384000: - sampleSpeed=SPEED_384K; - break; - } -} - -void radioberry_protocol_stop() { - - running=FALSE; - - if (rx1_spi_handler !=0) - spiClose(rx1_spi_handler); - if (rx2_spi_handler !=0) - spiClose(rx2_spi_handler); - - gpioTerminate(); - -} - -void rx1_spiReader() { - unsigned char iqdata[6]; - - // return till rxFIFO buffer is filled with at least one element - while ( gpioRead(13) == 1) {return;}; - - setSampleSpeed(0); - - long long rxFrequency=vfo[0].frequency-vfo[0].lo; - if(vfo[0].rit_enabled) { - rxFrequency+=vfo[0].rit; - } - if (active_receiver->id==0) { - if(vfo[0].mode==modeCWU) { - rxFrequency-=(long long)cw_keyer_sidetone_frequency; - } else if(vfo[0].mode==modeCWL) { - rxFrequency+=(long long)cw_keyer_sidetone_frequency; - } - } - - iqdata[0] = (sampleSpeed & 0x03); - iqdata[1] = (((active_receiver->random << 6) & 0x40) | ((active_receiver->dither <<5) & 0x20) | (attenuation & 0x1F)); - iqdata[2] = ((rxFrequency >> 24) & 0xFF); - iqdata[3] = ((rxFrequency >> 16) & 0xFF); - iqdata[4] = ((rxFrequency >> 8) & 0xFF); - iqdata[5] = (rxFrequency & 0xFF); - - spiXfer(rx1_spi_handler, iqdata, iqdata, 6); - - put_rx1(iqdata); - - rx1_count ++; - if (rx1_count == 48000) { - rx1_count = 0; - gettimeofday(&rx1_t1, 0); - elapsed = timedifference_msec(rx1_t0, rx1_t1); - printf("Code rx1 mode spi executed in %f milliseconds.\n", elapsed); - gettimeofday(&rx1_t0, 0); - } -} - -void rx2_spiReader() { - - unsigned char iqdata[6]; - - if (receivers==1) return; - - // return till rx2FIFO buffer is filled with at least one element - while ( gpioRead(16) == 1) {return;}; - - setSampleSpeed(1); - - long long rxFrequency=vfo[1].frequency-vfo[1].lo; - if(vfo[1].rit_enabled) { - rxFrequency+=vfo[1].rit; - } - if (active_receiver->id==1) { - if(vfo[1].mode==modeCWU) { - rxFrequency-=(long long)cw_keyer_sidetone_frequency; - } else if(vfo[1].mode==modeCWL) { - rxFrequency+=(long long)cw_keyer_sidetone_frequency; - } - } - - iqdata[0] = (sampleSpeed & 0x03); - iqdata[1] = 0x00; //not used by firmware; the active receiver settings are set via rx1 - iqdata[2] = ((rxFrequency >> 24) & 0xFF); - iqdata[3] = ((rxFrequency >> 16) & 0xFF); - iqdata[4] = ((rxFrequency >> 8) & 0xFF); - iqdata[5] = (rxFrequency & 0xFF); - - spiXfer(rx2_spi_handler, iqdata, iqdata, 6); - - put_rx2(iqdata); - - rx2_count ++; - if (rx2_count == 48000) { - rx2_count = 0; - gettimeofday(&rx2_t1, 0); - elapsed = timedifference_msec(rx2_t0, rx2_t1); - printf("Code rx2 mode spi executed in %f milliseconds.\n", elapsed); - gettimeofday(&rx2_t0, 0); - } - -} - -void spiWriter() { - - gpioWrite(21, 1); - - while ( gpioRead(20) == 1) {}; - - spiXfer(rx1_spi_handler, tx_iqdata, tx_iqdata, 6); - - long long txFrequency; - if(split) { - txFrequency=vfo[VFO_B].frequency-vfo[VFO_A].lo+vfo[VFO_B].offset; - } else { - txFrequency=vfo[VFO_A].frequency-vfo[VFO_B].lo+vfo[VFO_A].offset; - } - tx_iqdata[0] = cw_keyer_speed | (cw_keyer_mode<<6); - tx_iqdata[1] = cw_keyer_weight | (cw_keyer_spacing<<7); - tx_iqdata[2] = ((txFrequency >> 24) & 0xFF); - tx_iqdata[3] = ((txFrequency >> 16) & 0xFF); - tx_iqdata[4] = ((txFrequency >> 8) & 0xFF); - tx_iqdata[5] = (txFrequency & 0xFF); - - spiXfer(rx2_spi_handler, tx_iqdata, tx_iqdata, 6); - - txcount ++; - if (txcount == 48000) { - txcount = 0; - gettimeofday(&t21, 0); - float elapsd = timedifference_msec(t20, t21); - printf("Code tx mode spi executed in %f milliseconds.\n", elapsd); - gettimeofday(&t20, 0); - } -} - -void put_rx1(unsigned char* value) { - - int left_sample; - int right_sample; - double left_sample_double; - double right_sample_double; - - sem_wait(&empty); - - left_sample = (int)((signed char) value[0]) << 16; - left_sample |= (int)((((unsigned char)value[1]) << 8)&0xFF00); - left_sample |= (int)((unsigned char)value[2]&0xFF); - right_sample = (int)((signed char) value[3]) << 16; - right_sample |= (int)((((unsigned char)value[4]) << 8)&0xFF00); - right_sample |= (int)((unsigned char)value[5]&0xFF); - - left_sample_double=(double)left_sample/8388607.0; // 24 bit sample 2^23-1 - right_sample_double=(double)right_sample/8388607.0; // 24 bit sample 2^23-1 - - buffer_rx1[fill_rx1][0] = left_sample_double; - buffer_rx1[fill_rx1][1] = right_sample_double; - - g_mutex_lock(&buf_rx1_mutex); - fill_rx1 = (fill_rx1 + 1) % MAX_RX_BUFFER; - g_mutex_unlock(&buf_rx1_mutex); - - sem_post(&full); -} - -void get_rx1(double buffer[]) { - sem_wait(&full); - - buffer[0] = buffer_rx1[use_rx1][0]; - buffer[1] = buffer_rx1[use_rx1][1]; - - g_mutex_lock(&buf_rx1_mutex); - use_rx1 = (use_rx1 + 1) % MAX_RX_BUFFER; - g_mutex_unlock(&buf_rx1_mutex); - - sem_post(&empty); -} - -void put_rx2(unsigned char* value) { - - int left_sample; - int right_sample; - double left_sample_double; - double right_sample_double; - - sem_wait(&empty_rx2); - - left_sample = (int)((signed char) value[0]) << 16; - left_sample |= (int)((((unsigned char)value[1]) << 8)&0xFF00); - left_sample |= (int)((unsigned char)value[2]&0xFF); - right_sample = (int)((signed char) value[3]) << 16; - right_sample |= (int)((((unsigned char)value[4]) << 8)&0xFF00); - right_sample |= (int)((unsigned char)value[5]&0xFF); - - left_sample_double=(double)left_sample/8388607.0; // 24 bit sample 2^23-1 - right_sample_double=(double)right_sample/8388607.0; // 24 bit sample 2^23-1 - - buffer_rx2[fill_rx2][0] = left_sample_double; - buffer_rx2[fill_rx2][1] = right_sample_double; - - g_mutex_lock(&buf_rx2_mutex); - fill_rx2 = (fill_rx2 + 1) % MAX_RX_BUFFER; - g_mutex_unlock(&buf_rx2_mutex); - - sem_post(&full_rx2); -} - -void get_rx2(double buffer[]) { - sem_wait(&full_rx2); - - buffer[0] = buffer_rx2[use_rx2][0]; - buffer[1] = buffer_rx2[use_rx2][1]; - - g_mutex_lock(&buf_rx2_mutex); - use_rx2 = (use_rx2 + 1) % MAX_RX_BUFFER; - g_mutex_unlock(&buf_rx2_mutex); - - sem_post(&empty_rx2); -} - -// end of source diff --git a/radioberry.c.orig b/radioberry.c.orig deleted file mode 100644 index 112c171f..00000000 --- a/radioberry.c.orig +++ /dev/null @@ -1,383 +0,0 @@ -/* Copyright (C) -* 2017 - Johan Maas, PA3GSB -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -* -*/ - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "audio.h" - -#include "band.h" -#include "channel.h" -#include "discovered.h" -#include "mode.h" -#include "filter.h" -#include "old_protocol.h" -#include "radio.h" -#include "toolbar.h" -#include "vox.h" -#include -#ifdef PSK -#include "psk.h" -#endif -#include "receiver.h" -#include "transmitter.h" -#include "vfo.h" - -#include -#include "ext.h" - -#define OUTPUT_BUFFER_SIZE 1024 -#define SPEED_48K 0x00 -#define SPEED_96K 0x01 -#define SPEED_192K 0x02 -#define SPEED_384K 0x03 - -static int display_width; -static int running; -static int sampleSpeed =0; - -unsigned char iqdata[6]; -unsigned char tx_iqdata[6]; - -static pthread_t radioberry_thread_id; -static void start_radioberry_thread(); -static void *radioberry_thread(void* arg); - -static void setSampleSpeed(); -static void handleReceiveStream(); - -struct timeval t0; -struct timeval t1; -struct timeval t10; -struct timeval t11; -struct timeval t20; -struct timeval t21; -float elapsed; - -#define RADIOSTATE_RX 0 -#define RADIOSTATE_TX 1 -static int radiostate = RADIOSTATE_RX; - -void spiWriter(); -void spiReader(); - - -int prev_drive_level; - -static int rxcount =0; -static int txcount =0; - -sem_t mutex; - -#ifdef PSK -static int psk_samples=0; -static int psk_divisor=6; -#endif - -static int h; - - -#define HANDLER_STEADY_TIME_US 5000 -void setup_handler(int pin, gpioAlertFunc_t pAlert) { - gpioSetMode(pin, PI_INPUT); - gpioSetPullUpDown(pin,PI_PUD_UP); - // give time to settle to avoid false triggers - usleep(10000); - gpioSetAlertFunc(pin, pAlert); - gpioGlitchFilter(pin, HANDLER_STEADY_TIME_US); -} - -void cwPTT_Alert(int gpio, int level, uint32_t tick) { - //fprintf(stderr,"radioberry ptt swith %d 0=ptt off and 1=ptt on\n", level); - //fprintf(stderr,"%d - %d -%d - %d\n", running, cw_breakin, transmitter->mode, level); - if (running && cw_breakin && (transmitter->mode==modeCWU || transmitter->mode==modeCWL)){ - g_idle_add(ext_mox_update,(gpointer)level); - } -} - -float timedifference_msec(struct timeval t0, struct timeval t1) -{ - return (t1.tv_sec - t0.tv_sec) * 1000.0f + (t1.tv_usec - t0.tv_usec) / 1000.0f; -} - -void radioberry_protocol_init(int rx,int pixels) { - int i; - - fprintf(stderr,"radioberry_protocol_init\n"); - sem_init(&mutex, 0, 1); //mutal exlusion - display_width=pixels; - fprintf(stderr,"radioberry_protocol: buffer size: =%d\n", buffer_size); - -/* - if (gpioInitialise() < 0) { - fprintf(stderr,"radioberry_protocol: gpio could not be initialized. \n"); - exit(-1); - } -<<<<<<< HEAD -*/ - - gpioSetMode(13, PI_INPUT); //rx1_FIFOEmpty - gpioSetMode(16, PI_INPUT); //rx2_FIFOEmpty -======= -#endif - - gpioSetMode(13, PI_INPUT); ->>>>>>> upstream/master - gpioSetMode(20, PI_INPUT); - gpioSetMode(21, PI_OUTPUT); - - setup_handler(17, cwPTT_Alert); - - - h = spiOpen(0, 15625000, 49155); - if (h < 0) { - fprintf(stderr,"radioberry_protocol: spi bus could not be initialized. \n"); - exit(-1); - } - - printf("init done \n"); - - setSampleSpeed(); - - if(transmitter->local_microphone) { - if(audio_open_input()!=0) { - fprintf(stderr,"audio_open_input failed\n"); - transmitter->local_microphone=0; - } - } - - start_radioberry_thread(); -} - -static void start_radioberry_thread() { - int rc; - fprintf(stderr,"radioberry_protocol starting radioberry thread\n"); - rc=pthread_create(&radioberry_thread_id,NULL,radioberry_thread,NULL); - if(rc != 0) { - fprintf(stderr,"radioberry_protocol: pthread_create failed on radioberry_thread: rc=%d\n", rc); - exit(-1); - } -} - -static void *radioberry_thread(void* arg) { - fprintf(stderr, "radioberry_protocol: radioberry_thread\n"); - - running=1; - - gettimeofday(&t20, 0); - gettimeofday(&t0, 0); - - gpioSetMode(13, PI_INPUT); - gpioSetMode(20, PI_INPUT); - gpioSetMode(21, PI_OUTPUT); - - while(running) { - - sem_wait(&mutex); - - if (isTransmitting()) - radiostate = RADIOSTATE_TX; - else - radiostate = RADIOSTATE_RX; - - if(radiostate == RADIOSTATE_TX) { - gpioWrite(21, 1); - } - else - { - gpioWrite(21, 0); - spiReader(); - handleReceiveStream(); - sem_post(&mutex); - } - } -} - -void radioberry_protocol_iq_samples(int isample,int qsample) { - - if(radiostate == RADIOSTATE_TX) { - - tx_iqdata[0] = 0; - tx_iqdata[1] = transmitter->drive / 6.4; // convert drive level from 0-255 to 0-39 ) - if (prev_drive_level != transmitter->drive) { - printf("drive level %d - corrected drive level %d \n", transmitter->drive_level, tx_iqdata[1]); - prev_drive_level = transmitter->drive; - } - tx_iqdata[2] = isample>>8; - tx_iqdata[3] = isample; - tx_iqdata[4] = qsample>>8; - tx_iqdata[5] = qsample; - - spiWriter(); - - sem_post(&mutex); - } - -} - -void *radioberry_protocol_process_local_mic(unsigned char *buffer,int le) { - int b; - short mic_sample; - // always 48000 samples per second - - b=0; - int i; - for(i=0;i<1024;i++) { - if(le) { - mic_sample = (short)((buffer[b++]&0xFF) | (buffer[b++]<<8)); - } else { - mic_sample = (short)((buffer[b++]<<8) | (buffer[b++]&0xFF)); - } - if(active_receiver->freedv) { - add_freedv_mic_sample(transmitter,mic_sample); - } else { - add_mic_sample(transmitter,mic_sample); - } - } -} - -static void handleReceiveStream() { - int left_sample; - int right_sample; - double left_sample_double; - double right_sample_double; - int r; - - left_sample = (int)((signed char) iqdata[0]) << 16; - left_sample += (int)((unsigned char)iqdata[1]) << 8; - left_sample += (int)((unsigned char)iqdata[2]); - right_sample = (int)((signed char) iqdata[3]) << 16; - right_sample += (int)((unsigned char)iqdata[4]) << 8; - right_sample += (int)((unsigned char)iqdata[5]); - - left_sample_double=(double)left_sample/8388607.0; // 24 bit sample 2^23-1 - right_sample_double=(double)right_sample/8388607.0; // 24 bit sample 2^23-1 - - for(r=0;rsample_rate) { - case 48000: - sampleSpeed=SPEED_48K; - break; - case 96000: - sampleSpeed=SPEED_96K; - break; - case 192000: - sampleSpeed=SPEED_192K; - break; - case 384000: - sampleSpeed=SPEED_384K; - break; - } -} - -void radioberry_protocol_stop() { - - running=FALSE; - - if (h !=0) - spiClose(h); - -#ifndef GPIO - gpioTerminate(); -#endif - -} - -void spiReader() { - // wait till rxFIFO buffer is filled with at least one element - while ( gpioRead(13) == 1) {}; - - setSampleSpeed(); - - int v=receiver[0]->id; - long long rxFrequency=vfo[v].frequency-vfo[v].lo; - if(vfo[v].rit_enabled) { - rxFrequency+=vfo[v].rit; - } - if(vfo[active_receiver->id].mode==modeCWU) { - rxFrequency-=(long long)cw_keyer_sidetone_frequency; - } else if(vfo[active_receiver->id].mode==modeCWL) { - rxFrequency+=(long long)cw_keyer_sidetone_frequency; - } - - iqdata[0] = (sampleSpeed & 0x03); - iqdata[1] = (((active_receiver->random << 6) & 0x40) | ((active_receiver->dither <<5) & 0x20) | (attenuation & 0x1F)); - iqdata[2] = ((rxFrequency >> 24) & 0xFF); - iqdata[3] = ((rxFrequency >> 16) & 0xFF); - iqdata[4] = ((rxFrequency >> 8) & 0xFF); - iqdata[5] = (rxFrequency & 0xFF); - - spiXfer(h, iqdata, iqdata, 6); - - //firmware: tdata(56'h00010203040506) -> 0-1-2-3-4-5-6 (element 0 contains 0; second element contains 1) - rxcount ++; - if (rxcount == 48000) { - rxcount = 0; - gettimeofday(&t1, 0); - elapsed = timedifference_msec(t0, t1); - printf("Code rx mode spi executed in %f milliseconds.\n", elapsed); - gettimeofday(&t0, 0); - } -} - -void spiWriter() { - while ( gpioRead(20) == 1) {}; - -<<<<<<< HEAD - spiXfer(rx1_spi_handler, tx_iqdata, tx_iqdata, 6); - - long long txFrequency; - if(split) { - txFrequency=vfo[VFO_B].frequency-vfo[VFO_A].lo+vfo[VFO_B].offset; - } else { - txFrequency=vfo[VFO_A].frequency-vfo[VFO_B].lo+vfo[VFO_A].offset; - } - tx_iqdata[0] = cw_keyer_speed | (cw_keyer_mode<<6); - tx_iqdata[1] = cw_keyer_weight | (cw_keyer_spacing<<7); - tx_iqdata[2] = ((txFrequency >> 24) & 0xFF); - tx_iqdata[3] = ((txFrequency >> 16) & 0xFF); - tx_iqdata[4] = ((txFrequency >> 8) & 0xFF); - tx_iqdata[5] = (txFrequency & 0xFF); - - spiXfer(rx2_spi_handler, tx_iqdata, tx_iqdata, 6); -======= - spiXfer(h, tx_iqdata, tx_iqdata, 6); ->>>>>>> upstream/master - - txcount ++; - if (txcount == 48000) { - txcount = 0; - gettimeofday(&t21, 0); - float elapsd = timedifference_msec(t20, t21); - printf("Code tx mode spi executed in %f milliseconds.\n", elapsd); - gettimeofday(&t20, 0); - } -} \ No newline at end of file diff --git a/radioberry.h b/radioberry.h deleted file mode 100644 index 3e8a0909..00000000 --- a/radioberry.h +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright (C) -* 2017 - Johan Maas, PA3GSB -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -* -*/ - -#define BUFFER_SIZE 1024 -void radioberry_protocol_stop(); -void radioberry_protocol_init(int rx,int pixels); -void *radioberry_protocol_process_local_mic(unsigned char *buffer,int le); -extern void radioberry_protocol_iq_samples(int isample,int qsample); diff --git a/radioberry_discovery.c b/radioberry_discovery.c deleted file mode 100644 index 322f535d..00000000 --- a/radioberry_discovery.c +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (C) -* 2017 - Johan Maas, PA3GSB -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -* -*/ - -#include -#include -#include "discovered.h" -#include "radioberry_discovery.h" - -void radioberry_discovery() { - - //check availability of RADIOBERRY for instance by si570 i2c address; - //for initial version when compiling with radioberry option; select it. - - - // setting clock and loading rbf file..... done before starting - - discovered[devices].protocol=RADIOBERRY_PROTOCOL; - discovered[devices].device=RADIOBERRY_SPI_DEVICE; - strcpy(discovered[devices].name, "RadioBerry"); - discovered[devices].status=STATE_AVAILABLE; - discovered[devices].software_version=100; - devices++; -} diff --git a/radioberry_discovery.h b/radioberry_discovery.h deleted file mode 100644 index 5afe47a9..00000000 --- a/radioberry_discovery.h +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright (C) -* 2017 - Johan Maas, PA3GSB -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -* -*/ -#ifndef _RADIOBERRY_DISCOVERY_H -#define _RADIOBERRY_DISCOVERY_H - -void radioberry_discovery(); - -#endif \ No newline at end of file diff --git a/receiver.c b/receiver.c index 702d4d88..2ea9f1de 100644 --- a/receiver.c +++ b/receiver.c @@ -52,9 +52,6 @@ #include "freedv.h" #endif #include "audio_waterfall.h" -#ifdef RADIOBERRY -#include "radioberry.h" -#endif #include "ext.h" #include "new_menu.h" @@ -840,13 +837,7 @@ fprintf(stderr,"create_receiver: id=%d buffer_size=%d fft_size=%d pixels=%d fps= } switch(protocol) { case ORIGINAL_PROTOCOL: -#ifdef RADIOBERRY - case RADIOBERRY_PROTOCOL: -#endif switch(device) { -#ifdef RADIOBERRY - case RADIOBERRY_SPI_DEVICE: -#endif case DEVICE_METIS: case DEVICE_HERMES: case DEVICE_HERMES_LITE: @@ -1186,11 +1177,6 @@ static void process_freedv_rx_buffer(RECEIVER *rx) { #ifdef LIMESDR case LIMESDR_PROTOCOL: break; -#endif -#ifdef RADIOBERRY - case RADIOBERRY_PROTOCOL: - //no audio stream to radioberry hardware, using local audio of rpi. - break; #endif } } @@ -1269,11 +1255,6 @@ static void process_rx_buffer(RECEIVER *rx) { #ifdef LIMESDR case LIMESDR_PROTOCOL: break; -#endif -#ifdef RADIOBERRY - case RADIOBERRY_PROTOCOL: - //no audio stream to radioberry hardware, using local audio of rpi. - break; #endif } diff --git a/rx_menu.c b/rx_menu.c index 95c8723a..704de480 100644 --- a/rx_menu.c +++ b/rx_menu.c @@ -169,9 +169,6 @@ void rx_menu(GtkWidget *parent) { int x=0; switch(protocol) { -#ifdef RADIOBERRY - case RADIOBERRY_PROTOCOL: -#endif case NEW_PROTOCOL: { GtkWidget *sample_rate_label=gtk_label_new("Sample Rate"); @@ -237,9 +234,6 @@ void rx_menu(GtkWidget *parent) { // so those are left out. PreAmps and Alex Attenuator are controlled via sliders. if (filter_board != CHARLY25) { switch(protocol) { -#ifdef RADIOBERRY - case RADIOBERRY_PROTOCOL: -#endif case ORIGINAL_PROTOCOL: case NEW_PROTOCOL: { diff --git a/rx_menu.c.orig b/rx_menu.c.orig new file mode 100644 index 00000000..4606dd6f --- /dev/null +++ b/rx_menu.c.orig @@ -0,0 +1,415 @@ +/* Copyright (C) +* 2015 - John Melton, G0ORX/N6LYT +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +* +*/ + +#include +#include +#include +#include +#include + +#include "audio.h" +#include "new_menu.h" +#include "rx_menu.h" +#include "band.h" +#include "discovered.h" +#include "filter.h" +#include "radio.h" +#include "receiver.h" +#include "sliders.h" + +static GtkWidget *parent_window=NULL; + +static GtkWidget *menu_b=NULL; + +static GtkWidget *dialog=NULL; + +static void cleanup() { + if(dialog!=NULL) { + gtk_widget_destroy(dialog); + dialog=NULL; + sub_menu=NULL; + } +} + +static gboolean close_cb (GtkWidget *widget, GdkEventButton *event, gpointer data) { + cleanup(); + return TRUE; +} + +static gboolean delete_event(GtkWidget *widget, GdkEvent *event, gpointer user_data) { + cleanup(); + return FALSE; +} + +static void dither_cb(GtkWidget *widget, gpointer data) { + active_receiver->dither=active_receiver->dither==1?0:1; + update_att_preamp(); +} + +static void random_cb(GtkWidget *widget, gpointer data) { + active_receiver->random=active_receiver->random==1?0:1; +} + +static void preamp_cb(GtkWidget *widget, gpointer data) { + active_receiver->preamp=active_receiver->preamp==1?0:1; + update_att_preamp(); +} + +static void alex_att_cb(GtkWidget *widget, gpointer data) { + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) { + set_alex_attenuation((intptr_t) data); + update_att_preamp(); + } +} + +static void sample_rate_cb(GtkWidget *widget, gpointer data) { + receiver_change_sample_rate(active_receiver,(uintptr_t)data); +} + +static void adc_cb(GtkWidget *widget, gpointer data) { + receiver_change_adc(active_receiver,(uintptr_t)data); +} + +static void local_audio_cb(GtkWidget *widget, gpointer data) { +fprintf(stderr,"local_audio_cb: rx=%d\n",active_receiver->id); + if(gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) { + if(audio_open_output(active_receiver)==0) { + active_receiver->local_audio=1; + } else { +fprintf(stderr,"local_audio_cb: audio_open_output failed\n"); + active_receiver->local_audio=0; + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE); + } + } else { + if(active_receiver->local_audio) { + active_receiver->local_audio=0; + audio_close_output(active_receiver); + } + } +fprintf(stderr,"local_audio_cb: local_audio=%d\n",active_receiver->local_audio); +} + +static void mute_audio_cb(GtkWidget *widget, gpointer data) { + active_receiver->mute_when_not_active=gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); +} + +static void mute_radio_cb(GtkWidget *widget, gpointer data) { + active_receiver->mute_radio=gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); +} + +static void local_output_changed_cb(GtkWidget *widget, gpointer data) { + active_receiver->audio_device=(int)(long)data; +fprintf(stderr,"local_output_changed rx=%d to %d\n",active_receiver->id,active_receiver->audio_device); + if(active_receiver->local_audio) { + audio_close_output(active_receiver); + if(audio_open_output(active_receiver)==0) { + active_receiver->local_audio=1; + } else { + active_receiver->local_audio=0; + } +fprintf(stderr,"local_output_changed rx=%d local_audio=%d\n",active_receiver->id,active_receiver->local_audio); + } +} + +static void audio_channel_cb(GtkWidget *widget, gpointer data) { + if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) { + active_receiver->audio_channel=(uintptr_t)data; + } +} + +void rx_menu(GtkWidget *parent) { + char label[32]; + GtkWidget *adc_b; + int i; + parent_window=parent; + + dialog=gtk_dialog_new(); + gtk_window_set_transient_for(GTK_WINDOW(dialog),GTK_WINDOW(parent_window)); + //gtk_window_set_decorated(GTK_WINDOW(dialog),FALSE); + char title[64]; + sprintf(title,"piHPSDR - Receive (RX %d VFO %s)",active_receiver->id,active_receiver->id==0?"A":"B"); + gtk_window_set_title(GTK_WINDOW(dialog),title); + g_signal_connect (dialog, "delete_event", G_CALLBACK (delete_event), NULL); + + GdkRGBA color; + color.red = 1.0; + color.green = 1.0; + color.blue = 1.0; + color.alpha = 1.0; + gtk_widget_override_background_color(dialog,GTK_STATE_FLAG_NORMAL,&color); + + GtkWidget *content=gtk_dialog_get_content_area(GTK_DIALOG(dialog)); + + GtkWidget *grid=gtk_grid_new(); + gtk_grid_set_column_spacing (GTK_GRID(grid),10); + //gtk_grid_set_row_spacing (GTK_GRID(grid),10); + //gtk_grid_set_row_homogeneous(GTK_GRID(grid),TRUE); + //gtk_grid_set_column_homogeneous(GTK_GRID(grid),TRUE); + + GtkWidget *close_b=gtk_button_new_with_label("Close"); + g_signal_connect (close_b, "button_press_event", G_CALLBACK(close_cb), NULL); + gtk_grid_attach(GTK_GRID(grid),close_b,0,0,1,1); + + int x=0; + + switch(protocol) { + case NEW_PROTOCOL: + { + GtkWidget *sample_rate_label=gtk_label_new("Sample Rate"); + gtk_grid_attach(GTK_GRID(grid),sample_rate_label,x,1,1,1); + + GtkWidget *sample_rate_48=gtk_radio_button_new_with_label(NULL,"48000"); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sample_rate_48), active_receiver->sample_rate==48000); + gtk_grid_attach(GTK_GRID(grid),sample_rate_48,x,2,1,1); + g_signal_connect(sample_rate_48,"pressed",G_CALLBACK(sample_rate_cb),(gpointer *)48000); + + GtkWidget *sample_rate_96=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(sample_rate_48),"96000"); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sample_rate_96), active_receiver->sample_rate==96000); + gtk_grid_attach(GTK_GRID(grid),sample_rate_96,x,3,1,1); + g_signal_connect(sample_rate_96,"pressed",G_CALLBACK(sample_rate_cb),(gpointer *)96000); + + GtkWidget *sample_rate_192=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(sample_rate_96),"192000"); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sample_rate_192), active_receiver->sample_rate==192000); + gtk_grid_attach(GTK_GRID(grid),sample_rate_192,x,4,1,1); + g_signal_connect(sample_rate_192,"pressed",G_CALLBACK(sample_rate_cb),(gpointer *)192000); + + GtkWidget *sample_rate_384=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(sample_rate_192),"384000"); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sample_rate_384), active_receiver->sample_rate==384000); + gtk_grid_attach(GTK_GRID(grid),sample_rate_384,x,5,1,1); + g_signal_connect(sample_rate_384,"pressed",G_CALLBACK(sample_rate_cb),(gpointer *)384000); + +#ifndef raspberrypi + GtkWidget *sample_rate_768=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(sample_rate_384),"768000"); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sample_rate_768), active_receiver->sample_rate==768000); + gtk_grid_attach(GTK_GRID(grid),sample_rate_768,x,6,1,1); + g_signal_connect(sample_rate_768,"pressed",G_CALLBACK(sample_rate_cb),(gpointer *)768000); + + GtkWidget *sample_rate_1536=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(sample_rate_768),"1536000"); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sample_rate_1536), active_receiver->sample_rate==1536000); + gtk_grid_attach(GTK_GRID(grid),sample_rate_1536,x,7,1,1); + g_signal_connect(sample_rate_1536,"pressed",G_CALLBACK(sample_rate_cb),(gpointer *)1536000); +#endif + } + x++; + break; + +#ifdef LIMESDR + case LIMESDR_PROTOCOL: + { + GtkWidget *sample_rate_label=gtk_label_new("Sample Rate"); + gtk_grid_attach(GTK_GRID(grid),sample_rate_label,x,1,1,1); + + GtkWidget *sample_rate_1M=gtk_radio_button_new_with_label(NULL,"1000000"); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sample_rate_1M), active_receiver->sample_rate==1000000); + gtk_grid_attach(GTK_GRID(grid),sample_rate_1M,x,2,1,1); + g_signal_connect(sample_rate_1M,"pressed",G_CALLBACK(sample_rate_cb),(gpointer *)1000000); + + GtkWidget *sample_rate_2M=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(sample_rate_1M),"2000000"); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sample_rate_2M), active_receiver->sample_rate==2000000); + gtk_grid_attach(GTK_GRID(grid),sample_rate_2M,x,3,1,1); + g_signal_connect(sample_rate_2M,"pressed",G_CALLBACK(sample_rate_cb),(gpointer *)2000000); + } + x++; + break; +#endif + } + +<<<<<<< HEAD + switch(protocol) { + case ORIGINAL_PROTOCOL: + case NEW_PROTOCOL: + { + GtkWidget *dither_b=gtk_check_button_new_with_label("Dither"); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dither_b), active_receiver->dither); + gtk_grid_attach(GTK_GRID(grid),dither_b,x,2,1,1); + g_signal_connect(dither_b,"toggled",G_CALLBACK(dither_cb),NULL); + + GtkWidget *random_b=gtk_check_button_new_with_label("Random"); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (random_b), active_receiver->random); + gtk_grid_attach(GTK_GRID(grid),random_b,x,3,1,1); + g_signal_connect(random_b,"toggled",G_CALLBACK(random_cb),NULL); + + if((protocol==ORIGINAL_PROTOCOL && device==DEVICE_METIS) || +======= + // The CHARLY25 board (with RedPitaya) has no support for dither or random, + // so those are left out. PreAmps and Alex Attenuator are controlled via sliders. + if (filter_board != CHARLY25) { + switch(protocol) { +#ifdef RADIOBERRY + case RADIOBERRY_PROTOCOL: +#endif + case ORIGINAL_PROTOCOL: + case NEW_PROTOCOL: + { + GtkWidget *dither_b=gtk_check_button_new_with_label("Dither"); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dither_b), active_receiver->dither); + gtk_grid_attach(GTK_GRID(grid),dither_b,x,2,1,1); + g_signal_connect(dither_b,"toggled",G_CALLBACK(dither_cb),NULL); + + GtkWidget *random_b=gtk_check_button_new_with_label("Random"); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (random_b), active_receiver->random); + gtk_grid_attach(GTK_GRID(grid),random_b,x,3,1,1); + g_signal_connect(random_b,"toggled",G_CALLBACK(random_cb),NULL); + + if((protocol==ORIGINAL_PROTOCOL && device==DEVICE_METIS) || +>>>>>>> upstream/master +#ifdef USBOZY + (protocol==ORIGINAL_PROTOCOL && device==DEVICE_OZY) || +#endif + (protocol==NEW_PROTOCOL && device==NEW_DEVICE_ATLAS)) { + + GtkWidget *preamp_b=gtk_check_button_new_with_label("Preamp"); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (preamp_b), active_receiver->preamp); + gtk_grid_attach(GTK_GRID(grid),preamp_b,x,4,1,1); + g_signal_connect(preamp_b,"toggled",G_CALLBACK(preamp_cb),NULL); + } + GtkWidget *alex_att_label=gtk_label_new("Alex Attenuator"); + gtk_grid_attach(GTK_GRID(grid), alex_att_label, x, 5, 1, 1); + GtkWidget *last_alex_att_b = NULL; + for (int i = 0; i <= 3; i++) { + gchar button_text[] = "xx dB"; + sprintf(button_text, "%d dB", i*10); + GtkWidget *alex_att_b=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(last_alex_att_b), button_text); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(alex_att_b), active_receiver->alex_attenuation == i); + gtk_grid_attach(GTK_GRID(grid), alex_att_b, x, 6 + i, 1, 1); + g_signal_connect(alex_att_b, "toggled", G_CALLBACK(alex_att_cb), (gpointer) (long) i); + last_alex_att_b = alex_att_b; + } + } + x++; + break; + default: + break; + } + } + + int n_adc=1; + switch(protocol) { + case ORIGINAL_PROTOCOL: + switch(device) { + case DEVICE_METIS: + n_adc=1; // FIX for multiple Mercury cards + break; + case DEVICE_HERMES: + case DEVICE_HERMES_LITE: + n_adc=1; + break; + default: + n_adc=2; + break; + } + break; + case NEW_PROTOCOL: + switch(device) { + case NEW_DEVICE_ATLAS: + n_adc=1; // FIX for multiple Mercury cards + break; + case NEW_DEVICE_HERMES: + case NEW_DEVICE_HERMES2: + case NEW_DEVICE_HERMES_LITE: + n_adc=1; + break; + default: + n_adc=2; + break; + } + break; + default: + break; + } + + if(n_adc>1) { + for(i=0;iadc==i); + gtk_grid_attach(GTK_GRID(grid),adc_b,x,2+i,1,1); + g_signal_connect(adc_b,"pressed",G_CALLBACK(adc_cb),(gpointer)(long)i); + } + x++; + } + + + int row=0; + if(n_output_devices>0) { + GtkWidget *local_audio_b=gtk_check_button_new_with_label("Local Audio Output"); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (local_audio_b), active_receiver->local_audio); + gtk_widget_show(local_audio_b); + gtk_grid_attach(GTK_GRID(grid),local_audio_b,x,++row,1,1); + g_signal_connect(local_audio_b,"toggled",G_CALLBACK(local_audio_cb),NULL); + + if(active_receiver->audio_device==-1) active_receiver->audio_device=0; + + GtkWidget *output=NULL; + for(i=0;iaudio_device==i); + gtk_widget_show(output); + gtk_grid_attach(GTK_GRID(grid),output,x,++row,1,1); + g_signal_connect(output,"pressed",G_CALLBACK(local_output_changed_cb),(gpointer)(long)i); + } + + row=0; + x++; + + GtkWidget *stereo_b=gtk_radio_button_new_with_label(NULL,"Stereo"); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (stereo_b), active_receiver->audio_channel==STEREO); + gtk_widget_show(stereo_b); + gtk_grid_attach(GTK_GRID(grid),stereo_b,x,++row,1,1); + g_signal_connect(stereo_b,"toggled",G_CALLBACK(audio_channel_cb),(gpointer)STEREO); + + GtkWidget *left_b=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(stereo_b),"Left"); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (left_b), active_receiver->audio_channel==LEFT); + gtk_widget_show(left_b); + gtk_grid_attach(GTK_GRID(grid),left_b,x,++row,1,1); + g_signal_connect(left_b,"toggled",G_CALLBACK(audio_channel_cb),(gpointer)LEFT); + + GtkWidget *right_b=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(left_b),"Right"); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (right_b), active_receiver->audio_channel==RIGHT); + gtk_widget_show(right_b); + gtk_grid_attach(GTK_GRID(grid),right_b,x,++row,1,1); + g_signal_connect(right_b,"toggled",G_CALLBACK(audio_channel_cb),(gpointer)RIGHT); + } + + GtkWidget *mute_audio_b=gtk_check_button_new_with_label("Mute when not active"); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (mute_audio_b), active_receiver->mute_when_not_active); + gtk_widget_show(mute_audio_b); + gtk_grid_attach(GTK_GRID(grid),mute_audio_b,x,++row,1,1); + g_signal_connect(mute_audio_b,"toggled",G_CALLBACK(mute_audio_cb),NULL); + + row++; + + GtkWidget *mute_radio_b=gtk_check_button_new_with_label("Mute audio to radio"); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (mute_radio_b), active_receiver->mute_radio); + gtk_widget_show(mute_radio_b); + gtk_grid_attach(GTK_GRID(grid),mute_radio_b,x,++row,1,1); + g_signal_connect(mute_radio_b,"toggled",G_CALLBACK(mute_radio_cb),NULL); + + gtk_container_add(GTK_CONTAINER(content),grid); + + sub_menu=dialog; + + gtk_widget_show_all(dialog); + +} + diff --git a/sliders.c b/sliders.c index 7c769853..acf78d78 100644 --- a/sliders.c +++ b/sliders.c @@ -106,7 +106,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(); } @@ -120,14 +124,30 @@ 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_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]); +#endif } void set_attenuation_value(double value) { adc_attenuation[active_receiver->adc]=(int)value; if(display_sliders) { +#ifdef RADIOBERRY + gtk_range_set_value (GTK_RANGE(attenuation_scale),(double)rx_gain_slider[active_receiver->adc]); +#else gtk_range_set_value (GTK_RANGE(attenuation_scale),(double)adc_attenuation[active_receiver->adc]); +#endif } else { if(scale_status!=ATTENUATION) { if(scale_status!=NONE) { @@ -138,8 +158,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); @@ -534,13 +558,23 @@ 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); - gtk_range_set_value (GTK_RANGE(attenuation_scale),adc_attenuation[active_receiver->adc]); +#ifdef RADIOBERRY + attenuation_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,0.0, 60.0, 1.0); + gtk_range_set_value (GTK_RANGE(attenuation_scale),rx_gain_slider[active_receiver->adc]); +#else + attenuation_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,0.0, 31.0, 1.0); + gtk_range_set_value (GTK_RANGE(attenuation_scale),adc_attenuation[active_receiver->adc]); +#endif + 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); diff --git a/toolbar.c b/toolbar.c index 025d5de0..b1fc62a9 100644 --- a/toolbar.c +++ b/toolbar.c @@ -46,9 +46,6 @@ #include "property.h" #include "new_menu.h" #include "button_text.h" -#ifdef RADIOBERRY -#include "radioberry.h" -#endif #include "ext.h" #define MAX_FUNCTION 3 @@ -266,11 +263,6 @@ static void vox_cb(GtkWidget *widget, gpointer data) { } static void stop() { -#ifdef RADIOBERRY - if(protocol==RADIOBERRY_PROTOCOL) { - radioberry_protocol_stop(); - } -#endif if(protocol==ORIGINAL_PROTOCOL) { old_protocol_stop(); } else { diff --git a/transmitter.c b/transmitter.c index a5076e7f..d2c12ec4 100644 --- a/transmitter.c +++ b/transmitter.c @@ -305,11 +305,7 @@ static gboolean update_display(gpointer data) { double constant1=3.3; double constant2=0.095; -#ifdef RADIOBERRY - if(protocol==ORIGINAL_PROTOCOL || protocol==RADIOBERRY_PROTOCOL) { -#else if(protocol==ORIGINAL_PROTOCOL) { -#endif switch(device) { case DEVICE_METIS: constant1=3.3; @@ -333,10 +329,6 @@ static gboolean update_display(gpointer data) { break; case DEVICE_HERMES_LITE: break; -#ifdef RADIOBERRY - case RADIOBERRY_SPI_DEVICE: - break; -#endif } int power=alex_forward_power; @@ -387,12 +379,6 @@ static gboolean update_display(gpointer data) { constant1=3.3; constant2=0.09; break; -#ifdef RADIOBERRY - case RADIOBERRY_SPI_DEVICE: - constant1=3.3; - constant2=0.09; - break; -#endif } int power=alex_forward_power; @@ -499,11 +485,7 @@ TRANSMITTER *create_transmitter(int id, int buffer_size, int fft_size, int fps, tx->fft_size=fft_size; tx->fps=fps; -#ifdef RADIOBERRY - if(protocol==ORIGINAL_PROTOCOL || protocol==RADIOBERRY_PROTOCOL) { -#else - if(protocol==ORIGINAL_PROTOCOL) { -#endif + if(protocol==ORIGINAL_PROTOCOL) { tx->mic_sample_rate=48000; tx->mic_dsp_rate=48000; tx->iq_output_rate=48000; @@ -741,9 +723,6 @@ static void full_tx_buffer(TRANSMITTER *tx) { int mode; switch(protocol) { -#ifdef RADIOBERRY - case RADIOBERRY_PROTOCOL: -#endif case ORIGINAL_PROTOCOL: gain=32767.0; // 16 bit break; @@ -789,11 +768,6 @@ static void full_tx_buffer(TRANSMITTER *tx) { case NEW_PROTOCOL: new_protocol_iq_samples(isample,qsample); break; -#ifdef RADIOBERRY - case RADIOBERRY_PROTOCOL: - radioberry_protocol_iq_samples(isample,qsample); - break; -#endif } } } diff --git a/tx_menu.c b/tx_menu.c index ffad2a29..a746fe18 100644 --- a/tx_menu.c +++ b/tx_menu.c @@ -204,12 +204,7 @@ void tx_menu(GtkWidget *parent) { row++; col=0; -#ifdef RADIOBERRY - if(protocol==ORIGINAL_PROTOCOL || protocol==NEW_PROTOCOL || protocol==RADIOBERRY_PROTOCOL) { -#else if(protocol==ORIGINAL_PROTOCOL || protocol==NEW_PROTOCOL) { -#endif - micin_b=gtk_radio_button_new_with_label_from_widget(NULL,"Mic In"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (micin_b), mic_linein==0); gtk_widget_show(micin_b); @@ -407,11 +402,8 @@ void tx_menu(GtkWidget *parent) { gtk_widget_show_all(dialog); -#ifdef RADIOBERRY - if(transmitter->local_microphone && (protocol==ORIGINAL_PROTOCOL || protocol==NEW_PROTOCOL || protocol==RADIOBERRY_PROTOCOL)) { -#else - if(transmitter->local_microphone && (protocol==ORIGINAL_PROTOCOL || protocol==NEW_PROTOCOL)) { -#endif + + if(transmitter->local_microphone && (protocol==ORIGINAL_PROTOCOL || protocol==NEW_PROTOCOL)) { gtk_widget_hide(linein_b); gtk_widget_hide(micboost_b); } diff --git a/vfo.c b/vfo.c index 4666596f..61262d86 100644 --- a/vfo.c +++ b/vfo.c @@ -49,9 +49,6 @@ #include "wdsp.h" #include "new_menu.h" #include "rigctl.h" -#ifdef RADIOBERRY -#include "radioberry.h" -#endif #include "ext.h" #ifdef FREEDV #include "freedv.h"