From: John Melton g0orx/n6lyt Date: Wed, 11 May 2016 11:20:17 +0000 (+0000) Subject: changes to CW and Tune functions. Codec2 support started. X-Git-Url: https://git.rkrishnan.org/components/%22news.html?a=commitdiff_plain;h=3a43a03fd876825908fbfd70cf6c01d2b4f3f5f9;p=pihpsdr.git changes to CW and Tune functions. Codec2 support started. --- diff --git a/Makefile b/Makefile index 952b621..709985f 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,18 @@ LINK=gcc #LIMESDR_OBJS= \ #lime_discovery.o -OPTIONS=-g -D $(UNAME_N) $(LIMESDR_OPTIONS) -O3 + +#required for FREEDV (uncomment lines below) +#FREEDV_OPTIONS=-D FREEDV +#FREEDVLIBS=-lcodec2 +#FREEDV_SOURCES= \ +#freedv.c +#FREEDV_HEADERS= \ +#freedv.h +#FREEDV_OBJS= \ +#freedv.o + +OPTIONS=-g -D $(UNAME_N) $(LIMESDR_OPTIONS) $(FREEDV_OPTIONS) -O3 GTKINCLUDES=`pkg-config --cflags gtk+-3.0` GTKLIBS=`pkg-config --libs gtk+-3.0` @@ -23,7 +34,7 @@ endif ifeq ($(UNAME_N),odroid) GPIOLIBS=-lwiringPi endif -LIBS=-lrt -lm -lwdsp -lpthread $(GTKLIBS) $(GPIOLIBS) $(SOAPYSDRLIBS) +LIBS=-lcodec2 -lrt -lm -lwdsp -lpthread $(GTKLIBS) $(GPIOLIBS) $(SOAPYSDRLIBS) $(FREEDVLIBS) INCLUDES=$(GTKINCLUDES) COMPILE=$(CC) $(OPTIONS) $(INCLUDES) @@ -113,13 +124,13 @@ vfo.o \ waterfall.o \ wdsp_init.o -all: prebuild $(PROGRAM) $(HEADERS) $(LIMESDR_HEADERS) $(SOURCES) $(LIMESDR_SOURCES) +all: prebuild $(PROGRAM) $(HEADERS) $(LIMESDR_HEADERS) $(SOURCES) $(LIMESDR_SOURCES) $(FREEDV_SOURCES) prebuild: rm -f version.o -$(PROGRAM): $(OBJS) $(LIMESDR_OBJS) - $(LINK) -o $(PROGRAM) $(OBJS) $(LIMESDR_OBJS) $(LIBS) +$(PROGRAM): $(OBJS) $(LIMESDR_OBJS) $(FREEDV_OBJS) + $(LINK) -o $(PROGRAM) $(OBJS) $(LIMESDR_OBJS) $(FREEDV_OBJS) $(LIBS) .c.o: $(COMPILE) -c -o $@ $< @@ -132,4 +143,5 @@ clean: install: cp pihpsdr ../pihpsdr cp pihpsdr ./release/pihpsdr + cd release; tar cvf pihpsdr.tar pihpsdr diff --git a/band.h b/band.h index 61e61ae..5916e5d 100644 --- a/band.h +++ b/band.h @@ -33,7 +33,6 @@ #define band6 10 #ifdef LIMESDR #define band70 11 -#define band144 12 #define band220 13 #define band430 14 #define band902 15 diff --git a/discovered.h b/discovered.h index 110561e..d57010a 100644 --- a/discovered.h +++ b/discovered.h @@ -36,12 +36,14 @@ #define NEW_DEVICE_ORION2 5 #define NEW_DEVICE_HERMES_LITE 6 +#define LIMESDR_DEVICE 0 + #define STATE_AVAILABLE 2 #define STATE_SENDING 3 #define ORIGINAL_PROTOCOL 0 #define NEW_PROTOCOL 1 -#define LIME_SDR 2 +#define LIMESDR_PROTOCOL 2 struct _DISCOVERED { int protocol; diff --git a/filter.c b/filter.c index c6a4ff8..84f12e3 100644 --- a/filter.c +++ b/filter.c @@ -199,5 +199,21 @@ FILTER filterDRM[FILTERS]={ {-3300,3300,"Var2"}*/ }; -FILTER *filters[]={filterLSB,filterUSB,filterDSB,filterCWL,filterCWU,filterFMN,filterAM,filterDIGU,filterSPEC,filterDIGL,filterSAM,filterDRM}; +FILTER filterFREEDV[FILTERS]={ + {150,5150,"5.0k"}, + {150,4550,"4.4k"}, + {150,3950,"3.8k"}, + {150,3450,"3.3k"}, + {150,3050,"2.9k"}, + {150,2850,"2.7k"}, + {150,2550,"2.4k"}, + {150,2250,"2.1k"}, + {150,1950,"1.8k"}, + {150,1150,"1.0k"}/*, + {150,2850,"Var1"}, + {150,2850,"Var2"}*/ + }; + + +FILTER *filters[]={filterLSB,filterUSB,filterDSB,filterCWL,filterCWU,filterFMN,filterAM,filterDIGU,filterSPEC,filterDIGL,filterSAM,filterDRM,filterFREEDV}; diff --git a/filter.h b/filter.h index c6e0503..e0cbe07 100644 --- a/filter.h +++ b/filter.h @@ -61,12 +61,3 @@ int filterVar2High; FILTER *filters[MODES]; -/* -int updateFilter(void * data); -GtkWidget* buildFilterUI(); -void filterSaveState(); -void filterRestoreState(); -void setFilterValues(int mode); -void setFilter(int filter); -void setTxFilters(); -*/ diff --git a/gpio.c b/gpio.c index efadf09..b30a50e 100644 --- a/gpio.c +++ b/gpio.c @@ -23,6 +23,7 @@ #include "band.h" #include "channel.h" +#include "discovered.h" #include "mode.h" #include "filter.h" #include "bandstack.h" @@ -855,11 +856,25 @@ fprintf(stderr,"band_pressed\n"); if(b<0) { b=BANDS-1; } +#ifdef LIMESDR + if(protocol!=LIMESDR_PROTOCOL) { + if(b==band3400) { + b=band6; + } + } +#endif } else { b++; if(b>=BANDS) { b=0; } +#ifdef LIMESDR + if(protocol!=LIMESDR_PROTOCOL) { + if(b==band70) { + b=bandGen; + } + } +#endif } band=band_set_current(b); entry=bandstack_entry_get_current(); diff --git a/mode.c b/mode.c index 9b6048f..8bf7706 100644 --- a/mode.c +++ b/mode.c @@ -17,5 +17,5 @@ * */ -char *mode_string[]={"LSB","USB","DSB","CWL","CWU","FMN","AM","DIGU","SPEC","DIGL","SAM","DRM"}; +char *mode_string[]={"LSB","USB","DSB","CWL","CWU","FMN","AM","DIGU","SPEC","DIGL","SAM","DRM","FREEDV"}; diff --git a/mode.h b/mode.h index 154bab6..6176396 100644 --- a/mode.h +++ b/mode.h @@ -29,19 +29,11 @@ #define modeDIGL 9 #define modeSAM 10 #define modeDRM 11 +#define modeFREEDV 12 -#define MODES 12 +#define MODES 13 int mode; char *mode_string[MODES]; -/* -int updateMode(void * data); - -void setMode(int mode); -void modeSaveState(); -void modeRestoreState(); -GtkWidget* buildModeUI(); -char* modeToString(); -*/ diff --git a/new_protocol.c b/new_protocol.c index 736fc90..a308cf7 100644 --- a/new_protocol.c +++ b/new_protocol.c @@ -523,17 +523,6 @@ void new_protocol_stop() { sleep(1); } -/* -float sineWave(float* buf, int samples, float phase, float freq) { - float phase_step = 2 * PI * freq / 192000.0F; - int i; - for (i = 0; i < samples; i++) { - buf[i] = (float) sin(phase); - phase += phase_step; - } - return phase; -} -*/ float sineWave(double* buf, int samples, float phase, float freq) { float phase_step = 2 * PI * freq / 192000.0F; int i; diff --git a/old_protocol.c b/old_protocol.c index 88bee25..9e02f86 100644 --- a/old_protocol.c +++ b/old_protocol.c @@ -43,6 +43,7 @@ #include "old_protocol.h" #include "radio.h" #include "toolbar.h" +#include "freedv.h" #define SYNC0 0 #define SYNC1 1 @@ -176,7 +177,7 @@ void schedule_frequency_changed() { } static float sineWave(double* buf, int samples, float phase, float freq) { - float phase_step = 2 * PI * freq / 192000.0F; + float phase_step = 2 * PI * freq / 48000.0F; int i; for (i = 0; i < samples; i++) { buf[i*2] = (double) sin(phase); @@ -439,10 +440,25 @@ static void process_ozy_input_buffer(char *buffer) { // add to buffer if(isTransmitting()) { - micinputbuffer[samples*2]=(double)mic_sample_float*mic_gain; - micinputbuffer[(samples*2)+1]=(double)mic_sample_float*mic_gain; - samples++; +#ifdef FREEDV + if(mode==modeFREEDV) { + int modem_samples=mod_sample_freedv(mic_sample); + if(modem_samples!=0) { + + } + } else { +#endif + micinputbuffer[samples*2]=(double)mic_sample_float*mic_gain; + micinputbuffer[(samples*2)+1]=(double)mic_sample_float*mic_gain; + iqinputbuffer[samples*2]=0.0; + iqinputbuffer[(samples*2)+1]=0.0; + samples++; +#ifdef FREEDV + } +#endif } else { + micinputbuffer[samples*2]=0.0; + micinputbuffer[(samples*2)+1]=0.0; iqinputbuffer[samples*2]=(double)left_sample_float; iqinputbuffer[(samples*2)+1]=(double)right_sample_float; samples++; @@ -496,24 +512,62 @@ static void process_ozy_input_buffer(char *buffer) { fprintf(stderr,"fexchange2 (CHANNEL_RX0) returned error: %d\n", error); } Spectrum0(1, CHANNEL_RX0, 0, 0, iqinputbuffer); - for(j=0;j>8; - output_buffer[output_buffer_index++]=left_rx_sample; - output_buffer[output_buffer_index++]=right_rx_sample>>8; - output_buffer[output_buffer_index++]=right_rx_sample; - output_buffer[output_buffer_index++]=left_tx_sample>>8; - output_buffer[output_buffer_index++]=left_tx_sample; - output_buffer[output_buffer_index++]=right_tx_sample>>8; - output_buffer[output_buffer_index++]=right_tx_sample; - if(output_buffer_index>=OZY_BUFFER_SIZE) { - ozy_send_buffer(); - output_buffer_index=8; + +#ifdef FREEDV + if(mode==modeFREEDV) { + int demod_samples; + int increment=6; // 48000 to 8000 + for(j=0;j>8; + output_buffer[output_buffer_index++]=left_rx_sample; + output_buffer[output_buffer_index++]=right_rx_sample>>8; + output_buffer[output_buffer_index++]=right_rx_sample; + output_buffer[output_buffer_index++]=left_tx_sample>>8; + output_buffer[output_buffer_index++]=left_tx_sample; + output_buffer[output_buffer_index++]=right_tx_sample>>8; + output_buffer[output_buffer_index++]=right_tx_sample; + if(output_buffer_index>=OZY_BUFFER_SIZE) { + ozy_send_buffer(); + output_buffer_index=8; + } + } + } + } + } + } else { +#endif + for(j=0;j>8; + output_buffer[output_buffer_index++]=left_rx_sample; + output_buffer[output_buffer_index++]=right_rx_sample>>8; + output_buffer[output_buffer_index++]=right_rx_sample; + output_buffer[output_buffer_index++]=left_tx_sample>>8; + output_buffer[output_buffer_index++]=left_tx_sample; + output_buffer[output_buffer_index++]=right_tx_sample>>8; + output_buffer[output_buffer_index++]=right_tx_sample; + if(output_buffer_index>=OZY_BUFFER_SIZE) { + ozy_send_buffer(); + output_buffer_index=8; + } } +#ifdef FREEDV } +#endif } samples=0; } @@ -758,7 +812,7 @@ void ozy_send_buffer() { if(mode!=modeCWU && mode!=modeCWL) { // output_buffer[C1]|=0x00; } else { - if((tune==1) || (cw_keyer_internal==0)) { + if((tune==1) || (mox==1) || (cw_keyer_internal==0)) { // output_buffer[C1]|=0x00; } else { output_buffer[C1]|=0x01; @@ -783,9 +837,7 @@ void ozy_send_buffer() { output_buffer[C0]|=0x01; } } else { - if(tune==1) { - output_buffer[C0]|=0x01; - } else { + if(tune==0) { if(cw_keyer_internal==0) { output_buffer[C0]|=0x01; } diff --git a/pihpsdr b/pihpsdr index e3eb205..e230a63 100755 Binary files a/pihpsdr and b/pihpsdr differ diff --git a/radio.c b/radio.c index 8be22cf..657811f 100644 --- a/radio.c +++ b/radio.c @@ -237,13 +237,6 @@ int getTune() { } int isTransmitting() { -/* - BANDSTACK_ENTRY *entry; - entry=bandstack_entry_get_current(); - if((entry->mode==modeCWL || entry->mode==modeCWU) && cw_keyer_internal==1 && ptt==1) { - return 0; - } -*/ return ptt!=0 || mox!=0 || tune!=0; } @@ -266,7 +259,6 @@ double getDrive() { } void setDrive(double value) { -//fprintf(stderr,"setDrive: protocol=%d\n", protocol); drive=(int)(value*255.0); if(protocol==NEW_PROTOCOL) { schedule_high_priority(6); diff --git a/release/pihpsdr.tar b/release/pihpsdr.tar index a2ad1a0..4f18e64 100644 Binary files a/release/pihpsdr.tar and b/release/pihpsdr.tar differ diff --git a/release/pihpsdr/install.sh b/release/pihpsdr/install.sh new file mode 100755 index 0000000..f838b18 --- /dev/null +++ b/release/pihpsdr/install.sh @@ -0,0 +1,7 @@ +cp libwdsp.so /usr/local/lib +cp libcodec2.so.0.5 /usr/local/lib +cp libSoapySDR.so.0.5-1 /usr/local/lib +cd /usr/local/lib; ln -s libcodec2.so.0.5 libcodec2.so +cd /usr/local/lib; ln -s libSoapySDR.so.0.5-1 libSoapySDR.so.0.5.0 +cd /usr/local/lib; ln -s libSoapySDR.so.0.5-1 libSoapySDR.so +ldconfig diff --git a/release/pihpsdr/libSoapySDR.so b/release/pihpsdr/libSoapySDR.so deleted file mode 100755 index 3c0232f..0000000 Binary files a/release/pihpsdr/libSoapySDR.so and /dev/null differ diff --git a/release/pihpsdr/libSoapySDR.so.0.5-1 b/release/pihpsdr/libSoapySDR.so.0.5-1 new file mode 100755 index 0000000..3c0232f Binary files /dev/null and b/release/pihpsdr/libSoapySDR.so.0.5-1 differ diff --git a/release/pihpsdr/libcodec2.so.0.5 b/release/pihpsdr/libcodec2.so.0.5 new file mode 100755 index 0000000..364d31c Binary files /dev/null and b/release/pihpsdr/libcodec2.so.0.5 differ diff --git a/release/pihpsdr/pihpsdr b/release/pihpsdr/pihpsdr index e3eb205..e230a63 100755 Binary files a/release/pihpsdr/pihpsdr and b/release/pihpsdr/pihpsdr differ diff --git a/toolbar.c b/toolbar.c index ac179e0..3c413c9 100644 --- a/toolbar.c +++ b/toolbar.c @@ -101,6 +101,13 @@ static void band_cb(GtkWidget *widget, gpointer data) { GtkWidget *b; int i; for(i=0;i=band70 && i<=band3400) { + continue; + } + } +#endif BAND* band=band_get_band(i); GtkWidget *b=gtk_button_new_with_label(band->title); gtk_widget_override_background_color(b, GTK_STATE_NORMAL, &white); @@ -789,11 +796,25 @@ fprintf(stderr,"sim_band_cb\n"); if(b<0) { b=BANDS-1; } +#ifdef LIMESDR + if(protocol!=LIMESDR_PROTOCOL) { + if(b==band3400) { + b=band6; + } + } +#endif } else { b++; if(b>=BANDS) { b=0; } +#ifdef LIMESDR + if(protocol!=LIMESDR_PROTOCOL) { + if(b==band70) { + b=bandGen; + } + } +#endif } band=band_set_current(b); entry=bandstack_entry_get_current(); diff --git a/wdsp_init.c b/wdsp_init.c index 1add75c..ff25aa6 100644 --- a/wdsp_init.c +++ b/wdsp_init.c @@ -47,6 +47,7 @@ #include "vfo.h" #include "toolbar.h" #include "wdsp_init.h" +#include "freedv.h" #define PI 3.1415926535897932F #define min(x,y) (x