From: pa3gsb <pa3gsb@gmail.com>
Date: Tue, 22 May 2018 17:26:16 +0000 (+0200)
Subject: radioberry using protocol-1
X-Git-Url: https://git.rkrishnan.org/pf/components/$rel_link?a=commitdiff_plain;h=19bd53fe2b3f7fa4cd9782aed8bcb2c02a34068f;p=pihpsdr.git

radioberry using protocol-1
---

diff --git a/Makefile b/Makefile
index 6b3034d..cc96230 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
@@ -80,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
-#RADIOBERRY_INCLUDE=RADIOBERRY
-
+# 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
@@ -191,9 +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
 
-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 +399,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) $(LIBS) $(RADIOBERRY_OBJS) $(PURESIGNAL_OBJS) $(STEMLAB_OBJS)
+$(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/audio.c b/audio.c
index cb668d5..923685a 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/discovery.c b/discovery.c
index b4f7caa..1acc19c 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
@@ -133,13 +127,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();
@@ -243,11 +232,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/exit_menu.c b/exit_menu.c
index 409ef13..aa3f285 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 9645c55..9168544 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 3aeff64..b11ad53 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 <pigpio.h>
-#endif
 
 #ifdef CONTROLLER2
 
@@ -1001,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
diff --git a/main.c b/main.c
index 16628ff..b17a210 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/radio.c b/radio.c
index 8f4c9ba..658c8f5 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
   }
 
@@ -579,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
   }
 
@@ -923,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);
@@ -960,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:
@@ -1043,11 +1024,6 @@ void set_attenuation(int value) {
       case LIMESDR_PROTOCOL:
         lime_protocol_set_attenuation(value);
         break;
-#endif
-#ifdef RADIOBERRY
-      case RADIOBERRY_PROTOCOL:
-        radioberry_set_attenuation(value);
-        break;
 #endif
     }
 }
@@ -1282,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);
 }
 
@@ -1449,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/radioberry.c b/radioberry.c
deleted file mode 100644
index 9678d94..0000000
--- a/radioberry.c
+++ /dev/null
@@ -1,395 +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 <gtk/gtk.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <semaphore.h>
-#include <pthread.h>
-#include <sys/time.h>
-
-#include <string.h>
-#include <errno.h>
-#include <math.h>
-
-#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 <semaphore.h>
-#ifdef PSK
-#include "psk.h"
-#endif
-#include "receiver.h"
-#include "transmitter.h"
-#include "vfo.h"
-#include <pigpio.h>
-#include "ext.h"
-
-#define SPEED_48K                 0x00
-#define SPEED_96K                 0x01
-#define SPEED_192K                0x02
-#define SPEED_384K                0x03
-
-#define RECEIVED_SAMPLES 64
-
-static GThread *radioberry_thread_id;
-static gpointer radioberry_thread(gpointer arg);
-
-static int running;
-
-static void setSampleSpeed(int r);
-static int sampleSpeed[2];
-
-unsigned char tx_iqdata[6];
-struct timeval t20;
-struct timeval t21;
-
-void spiWriter();
-void rx1_spiReader(unsigned char iqdata[]);
-void rx2_spiReader(unsigned char iqdata[]);
-
-int radioberry_attenuation = 0;
-int prev_drive_level;
-static int txcount =0;
-
-GMutex mutex_rxtx;
-
-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;
-
-	fprintf(stderr,"\n");
-	fprintf(stderr,	"====================================================================\n");
-	fprintf(stderr,	"====================================================================\n");
-	fprintf(stderr, "                      Radioberry V2.0 beta 2.\n");
-	fprintf(stderr,	"\n");
-	fprintf(stderr, "                    PIHPSDR plugin version 19-5-2018 \n");
-	fprintf(stderr,	"\n");
-	fprintf(stderr,	"\n");
-	fprintf(stderr, "                      Have fune Johan PA3GSB\n");
-	fprintf(stderr, "\n");
-	fprintf(stderr, "\n");
-	fprintf(stderr, "====================================================================\n");
-	fprintf(stderr, "====================================================================\n");
-
-#ifndef GPIO
-	if (gpioInitialise() < 0) {
-		fprintf(stderr,"radioberry_protocol: gpio could not be initialized. \n");
-		exit(-1);
-	}
-#endif
- 	gpioSetMode(13, PI_INPUT); 	//rx1_x-samples received.
-	gpioSetMode(16, PI_INPUT);	//rx2_x-samples received.
-	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;
-	radioberry_attenuation = adc_attenuation[active_receiver->adc];
-	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);
-
-}
-
-void convertToDouble(unsigned char* value, double buffer[]) {
-	
-	int left_sample;
-	int right_sample;
-	double left_sample_double;
-	double right_sample_double;
-	
-	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[0] = left_sample_double;  
-	buffer[1] = right_sample_double; 
-}
-
-static gpointer radioberry_thread(gpointer arg) {
-	fprintf(stderr, "radioberry_protocol: radioberry_thread\n");
-	
-	unsigned char iqdata[6];
-	double _iqdata[2];
-
-	while(running) {
-	
-		if (!isTransmitting()) 
-		{
-			g_mutex_lock(&mutex_rxtx);
-			
-			gpioWrite(21, 0);
-			
-			setSampleSpeed(0);
-			setSampleSpeed(1);
-			
-			if (gpioRead(13) == 1) {
-				int i=0;
-				for (i=0; i< RECEIVED_SAMPLES; i++) {
-					rx1_spiReader(iqdata);
-					convertToDouble(iqdata, _iqdata);
-					add_iq_samples(receiver[0], _iqdata[0], _iqdata[1]);
-				}
-			}
-			
-			if (receivers==2) {
-				if (gpioRead(16) == 1) {
-					int i=0;
-					for (i=0; i< RECEIVED_SAMPLES; i++) {
-						rx2_spiReader(iqdata);
-						convertToDouble(iqdata, _iqdata);
-						add_iq_samples(receiver[1], _iqdata[0], _iqdata[1]);
-					}
-				}
-			}
-			
-			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[r]=SPEED_48K;
-          break;
-        case 96000:
-          sampleSpeed[r]=SPEED_96K;
-          break;
-        case 192000:
-          sampleSpeed[r]=SPEED_192K;
-          break;
-        case 384000:
-          sampleSpeed[r]=SPEED_384K;
-          break;
-      }
-}
-
-void radioberry_set_attenuation(int attenuation) {
-	radioberry_attenuation = attenuation;
-}
-
-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[]) {
-	
-	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[0] & 0x03);
-	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);
-	iqdata[5] = (rxFrequency & 0xFF);
-			
-	spiXfer(rx1_spi_handler, iqdata, iqdata, 6);
-}
-
-void rx2_spiReader(unsigned char iqdata[]) {
-	
-	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[1] & 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);	
-}
-
-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);
-	}
-}
-// end of source
diff --git a/radioberry.c.orig b/radioberry.c.orig
deleted file mode 100644
index 112c171..0000000
--- 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 <gtk/gtk.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <semaphore.h>
-#include <pthread.h>
-
-#include <string.h>
-#include <errno.h>
-#include <math.h>
-
-#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 <semaphore.h>
-#ifdef PSK
-#include "psk.h"
-#endif
-#include "receiver.h"
-#include "transmitter.h"
-#include "vfo.h"
-
-#include <pigpio.h>
-#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;r<RECEIVERS;r++) {
-		add_iq_samples(receiver[r], left_sample_double,right_sample_double);
-	}
-}
-
-void setSampleSpeed() {
-     switch(active_receiver->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 (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 383c3f1..0000000
--- a/radioberry.h
+++ /dev/null
@@ -1,25 +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);
-void radioberry_set_attenuation(int attenuation);
diff --git a/radioberry_discovery.c b/radioberry_discovery.c
deleted file mode 100644
index 322f535..0000000
--- 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 <stdio.h>
-#include <string.h>
-#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 5afe47a..0000000
--- 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 702d4d8..2ea9f1d 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 af86bdf..f07574f 100644
--- a/rx_menu.c
+++ b/rx_menu.c
@@ -159,9 +159,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");
@@ -224,9 +221,6 @@ void rx_menu(GtkWidget *parent) {
   }
 
   switch(protocol) {
-#ifdef RADIOBERRY
-	case RADIOBERRY_PROTOCOL:
-#endif
     case ORIGINAL_PROTOCOL:
     case NEW_PROTOCOL: 
       {
diff --git a/sliders.c b/sliders.c
index 10150bc..bc6e399 100644
--- a/sliders.c
+++ b/sliders.c
@@ -140,7 +140,11 @@ static void attenuation_value_changed_cb(GtkWidget *widget, gpointer data) {
 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) {
@@ -519,10 +523,12 @@ fprintf(stderr,"sliders_init: width=%d height=%d\n", width,height);
 
 #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_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);
   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 025d5de..b1fc62a 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 a5076e7..d2c12ec 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 ffad2a2..a746fe1 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 4666596..61262d8 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"