From 5698e47f67a0dc7afb4a8d7f06d55bd8c5eb1cb9 Mon Sep 17 00:00:00 2001 From: c vw Date: Wed, 29 Jan 2020 17:21:10 +0100 Subject: [PATCH] manual merge with John's update --- Makefile | 116 ++---- Makefile.mac | 111 +----- about_menu.c | 4 - ant_menu.c | 72 +++- audio.c | 9 +- band.c | 154 ++++++- band.h | 60 +-- channel.h | 3 - discovery.c | 34 ++ display_menu.c | 25 +- dsp_menu.c | 11 +- encoder_menu.c | 159 +++----- equalizer_menu.c | 16 +- exit_menu.c | 2 +- ext.c | 7 + ext.h | 3 + fft_menu.c | 3 +- filter.c | 83 ++-- filter.h | 21 +- gpio.c | 996 +++++++++++++++++++++++++++++----------------- gpio.h | 157 +++++--- i2c.c | 34 +- iambic.c | 355 ++++------------- main.c | 1 - meter.c | 284 ++++++------- meter.h | 4 - meter_menu.c | 49 ++- mode.c | 3 - mode.h | 5 - new_discovery.c | 1 - new_menu.c | 37 +- new_menu.h | 3 + new_protocol.c | 147 +++---- oc_menu.c | 133 +++++-- old_discovery.c | 16 +- old_protocol.c | 109 +++-- pa_menu.c | 205 +++++++++- property.c | 20 +- property.h | 2 +- ps_menu.c | 4 +- radio.c | 328 ++++++++------- radio.h | 22 +- radio_menu.c | 60 ++- receiver.c | 170 +------- receiver.h | 8 - rigctl_menu.c | 9 +- rx_menu.c | 9 +- rx_panadapter.c | 53 +-- sliders.c | 208 ++++++---- sliders.h | 1 + soapy_discovery.c | 1 + soapy_protocol.c | 38 +- soundio.c | 10 - switch_menu.c | 492 +++++++++++------------ toolbar.c | 5 +- transmitter.c | 171 ++++---- transmitter.h | 7 +- tx_menu.c | 192 +++++---- tx_panadapter.c | 76 ++-- version.c | 25 +- vfo.c | 36 +- vfo_menu.c | 16 - vox_menu.c | 11 +- xvtr_menu.c | 40 +- 64 files changed, 2937 insertions(+), 2509 deletions(-) diff --git a/Makefile b/Makefile index 96de4ba..cfa1059 100644 --- a/Makefile +++ b/Makefile @@ -5,15 +5,6 @@ GIT_VERSION := $(shell git describe --abbrev=0 --tags) # uncomment the line below to include GPIO (For original piHPSDR Controller and Controller2) GPIO_INCLUDE=GPIO -# uncomment the line below to include MCP23017 I2C (required for Controller2) -#I2C_INCLUDE=I2C - -# uncomment the line below to include CONTROLLER2_V1 (single encoders) (Also uncomment GPIO and I2C) -#CONTROLLER2_V1_INCLUDE=CONTROLLER2_V1 - -# uncomment the line below to include CONTROLLER2_V2 (dual encoders) (Also uncomment GPIO and I2C) -#CONTROLLER2_V2_INCLUDE=CONTROLLER2_V2 - # uncomment the line below to include USB Ozy support # USBOZY_INCLUDE=USBOZY @@ -21,16 +12,10 @@ GPIO_INCLUDE=GPIO PURESIGNAL_INCLUDE=PURESIGNAL # uncomment the line to below include support local CW keyer -LOCALCW_INCLUDE=LOCALCW +#LOCALCW_INCLUDE=LOCALCW # uncomment the line below for SoapySDR -#SOAPYSDR_INCLUDE=SOAPYSDR - -# uncomment the line below to include support for psk31 -#PSK_INCLUDE=PSK - -# uncomment the line to below include support for FreeDV codec2 -#FREEDV_INCLUDE=FREEDV +SOAPYSDR_INCLUDE=SOAPYSDR # uncomment the line to below include support for sx1509 i2c expander #SX1509_INCLUDE=sx1509 @@ -39,7 +24,7 @@ LOCALCW_INCLUDE=LOCALCW #STEMLAB_DISCOVERY=STEMLAB_DISCOVERY # uncomment the line below to include support for STEMlab discovery (WITHOUT AVAHI) -# STEMLAB_DISCOVERY=STEMLAB_DISCOVERY_NOAVAHI +#STEMLAB_DISCOVERY=STEMLAB_DISCOVERY_NOAVAHI # uncomment the line below to include MIDI support MIDI_INCLUDE=MIDI @@ -50,13 +35,6 @@ MIDI_INCLUDE=MIDI CC=gcc LINK=gcc -ifeq ($(CONTROLLER2_V2_INCLUDE),CONTROLLER2_V2) -CONTROLLER2_OPTIONS=-D CONTROLLER2_V2 -endif -ifeq ($(CONTROLLER2_V1_INCLUDE),CONTROLLER2_V1) -CONTROLLER2_OPTIONS=-D CONTROLLER2_V1 -endif - ifeq ($(MIDI_INCLUDE),MIDI) MIDI_OPTIONS=-D MIDI MIDI_SOURCES= alsa_midi.c midi2.c midi3.c @@ -115,35 +93,6 @@ soapy_protocol.o endif -ifeq ($(PSK_INCLUDE),PSK) -PSK_OPTIONS=-D PSK -PSKLIBS=-lpsk -PSK_SOURCES= \ -psk.c \ -psk_waterfall.c -PSK_HEADERS= \ -psk.h \ -psk_waterfall.h -PSK_OBJS= \ -psk.o \ -psk_waterfall.o -endif - - -ifeq ($(FREEDV_INCLUDE),FREEDV) -FREEDV_OPTIONS=-D FREEDV -FREEDVLIBS=-lcodec2 -FREEDV_SOURCES= \ -freedv.c \ -freedv_menu.c -FREEDV_HEADERS= \ -freedv.h \ -freedv_menu.h -FREEDV_OBJS= \ -freedv.o \ -freedv_menu.o -endif - ifeq ($(LOCALCW_INCLUDE),LOCALCW) LOCALCW_OPTIONS=-D LOCALCW LOCALCW_SOURCES= iambic.c @@ -153,29 +102,27 @@ endif ifeq ($(GPIO_INCLUDE),GPIO) GPIO_OPTIONS=-D GPIO - GPIO_LIBS=-lwiringPi + GPIO_LIBS=-lwiringPi -li2c GPIO_SOURCES= \ + i2c.c \ + gpio_menu.c \ gpio.c \ encoder_menu.c \ switch_menu.c GPIO_HEADERS= \ + i2c.h \ + gpio_menu.h \ gpio.h \ encoder_menu.h \ switch_menu.h GPIO_OBJS= \ + i2c.o \ + gpio_menu.o \ gpio.o \ encoder_menu.o \ switch_menu.o endif -ifeq ($(I2C_INCLUDE),I2C) - I2C_OPTIONS=-D I2C - I2C_LIBS=-li2c - I2C_SOURCES=i2c.c - I2C_HEADERS=i2c.h - I2C_OBJS=i2c.o -endif - # # We have two versions of STEMLAB_DISCOVERY here, # the second one has to be used @@ -208,11 +155,11 @@ AUDIO_LIBS=-lasound CFLAGS= -g -Wno-deprecated-declarations -O3 OPTIONS=$(MIDI_OPTIONS) $(PURESIGNAL_OPTIONS) $(REMOTE_OPTIONS) $(USBOZY_OPTIONS) \ - $(I2C_OPTIONS) $(GPIO_OPTIONS) $(SOAPYSDR_OPTIONS) $(FREEDV_OPTIONS) $(LOCALCW_OPTIONS) \ - $(PSK_OPTIONS) $(STEMLAB_OPTIONS) $(CONTROLLER2_OPTIONS) \ + $(GPIO_OPTIONS) $(SOAPYSDR_OPTIONS) $(LOCALCW_OPTIONS) \ + $(STEMLAB_OPTIONS) \ -D GIT_DATE='"$(GIT_DATE)"' -D GIT_VERSION='"$(GIT_VERSION)"' $(DEBUG_OPTION) -LIBS=-lrt -lm -lwdsp -lpthread $(AUDIO_LIBS) $(USBOZY_LIBS) $(PSKLIBS) $(GTKLIBS) $(GPIO_LIBS) $(I2C_LIBS) $(SOAPYSDRLIBS) $(FREEDVLIBS) $(STEMLAB_LIBS) $(MIDI_LIBS) +LIBS=-lrt -lm -lwdsp -lpthread $(AUDIO_LIBS) $(USBOZY_LIBS) $(GTKLIBS) $(GPIO_LIBS) $(SOAPYSDRLIBS) $(STEMLAB_LIBS) $(MIDI_LIBS) INCLUDES=$(GTKINCLUDES) COMPILE=$(CC) $(CFLAGS) $(OPTIONS) $(INCLUDES) @@ -224,10 +171,7 @@ PROGRAM=pihpsdr SOURCES= \ audio.c \ -audio_waterfall.c \ band.c \ -configure.c \ -frequency.c \ discovered.c \ discovery.c \ filter.c \ @@ -293,12 +237,9 @@ cwramp.c HEADERS= \ audio.h \ -audio_waterfall.h \ agc.h \ alex.h \ band.h \ -configure.h \ -frequency.h \ bandstack.h \ channel.h \ discovered.h \ @@ -363,10 +304,7 @@ error_handler.h OBJS= \ audio.o \ -audio_waterfall.o \ band.o \ -configure.o \ -frequency.o \ discovered.o \ discovery.o \ filter.o \ @@ -429,19 +367,19 @@ ext.o \ error_handler.o \ cwramp.o -$(PROGRAM): $(OBJS) $(REMOTE_OBJS) $(USBOZY_OBJS) $(SOAPYSDR_OBJS) $(FREEDV_OBJS) \ - $(LOCALCW_OBJS) $(I2C_OBJS) $(GPIO_OBJS) $(PSK_OBJS) $(PURESIGNAL_OBJS) \ +$(PROGRAM): $(OBJS) $(REMOTE_OBJS) $(USBOZY_OBJS) $(SOAPYSDR_OBJS) \ + $(LOCALCW_OBJS) $(GPIO_OBJS) $(PURESIGNAL_OBJS) \ $(MIDI_OBJS) $(STEMLAB_OBJS) - $(LINK) -o $(PROGRAM) $(OBJS) $(REMOTE_OBJS) $(USBOZY_OBJS) $(I2C_OBJS) $(GPIO_OBJS) \ - $(SOAPYSDR_OBJS) $(FREEDV_OBJS) $(LOCALCW_OBJS) $(PSK_OBJS) $(PURESIGNAL_OBJS) \ + $(LINK) -o $(PROGRAM) $(OBJS) $(REMOTE_OBJS) $(USBOZY_OBJS) $(GPIO_OBJS) \ + $(SOAPYSDR_OBJS) $(LOCALCW_OBJS) $(PURESIGNAL_OBJS) \ $(MIDI_OBJS) $(STEMLAB_OBJS) $(LIBS) .PHONY: all all: prebuild $(PROGRAM) $(HEADERS) $(REMOTE_HEADERS) $(USBOZY_HEADERS) $(SOAPYSDR_HEADERS) \ - $(FREEDV_HEADERS) $(LOCALCW_HEADERS) $(I2C_HEADERS) $(GPIO_HEADERS) $(PSK_HEADERS) \ + $(LOCALCW_HEADERS) $(GPIO_HEADERS) \ $(PURESIGNAL_HEADERS) $(MIDI_HEADERS) $(STEMLAB_HEADERS) $(SOURCES) $(REMOTE_SOURCES) \ - $(USBOZY_SOURCES) $(SOAPYSDR_SOURCES) $(FREEDV_SOURCES) $(I2C_SOURCES) $(GPIO_SOURCES) \ - $(PSK_SOURCES) $(PURESIGNAL_SOURCES) $(MIDI_SOURCES) $(LOCALCW_SOURCES) $(STEMLAB_SOURCES) + $(USBOZY_SOURCES) $(SOAPYSDR_SOURCES) $(GPIO_SOURCES) \ + $(PURESIGNAL_SOURCES) $(MIDI_SOURCES) $(LOCALCW_SOURCES) $(STEMLAB_SOURCES) .PHONY: prebuild prebuild: @@ -459,8 +397,8 @@ CPPINCLUDES:=$(shell echo $(INCLUDES) | sed -e "s/-pthread / /" ) .PHONY: cppcheck cppcheck: cppcheck $(CPPOPTIONS) $(OPTIONS) $(CPPINCLUDES) $(SOURCES) $(REMOTE_SOURCES) \ - $(USBOZY_SOURCES) $(SOAPYSDR_SOURCES) $(FREEDV_SOURCES) $(I2C_SOURCES) $(GPIO_SOURCES) \ - $(PSK_SOURCES) $(PURESIGNAL_SOURCES) $(MIDI_SOURCES) $(STEMLAB_SOURCES) $(LOCALCW_SOURCES) + $(USBOZY_SOURCES) $(SOAPYSDR_SOURCES) $(GPIO_SOURCES) \ + $(PURESIGNAL_SOURCES) $(MIDI_SOURCES) $(STEMLAB_SOURCES) $(LOCALCW_SOURCES) .PHONY: clean clean: @@ -515,3 +453,13 @@ newhpsdrsim.o: newhpsdrsim.c hpsdrsim.h hpsdrsim: hpsdrsim.o newhpsdrsim.o $(LINK) -o hpsdrsim hpsdrsim.o newhpsdrsim.o -lasound -lm -lpthread + + +debian: + cp $(PROGRAM) pkg/pihpsdr/usr/local/bin + cp /usr/local/lib/libwdsp.so pkg/pihpsdr/usr/local/lib + cp release/pihpsdr/hpsdr.png pkg/pihpsdr/usr/share/pihpsdr + cp release/pihpsdr/hpsdr_icon.png pkg/pihpsdr/usr/share/pihpsdr + cp release/pihpsdr/pihpsdr.desktop pkg/pihpsdr/usr/share/applications + cd pkg; dpkg-deb --build pihpsdr + diff --git a/Makefile.mac b/Makefile.mac index a355c65..0f08cc4 100644 --- a/Makefile.mac +++ b/Makefile.mac @@ -2,18 +2,6 @@ GIT_DATE := $(firstword $(shell git --no-pager show --date=short --format="%ai" --name-only)) GIT_VERSION := $(shell git describe --abbrev=0 --tags) -# uncomment the line below to include GPIO (For original piHPSDR Controller and Controller2) -#GPIO_INCLUDE=GPIO - -# uncomment the line below to include MCP23017 I2C (required for Controller2) -#I2C_INCLUDE=I2C - -# uncomment the line below to include CONTROLLER2_V1 (single encoders) (Also uncomment GPIO and I2C) -#CONTROLLER2_V1_INCLUDE=CONTROLLER2_V1 - -# uncomment the line below to include CONTROLLER2_V2 (dual encoders) (Also uncomment GPIO and I2C) -#CONTROLLER2_V2_INCLUDE=CONTROLLER2_V2 - # uncomment the line below to include USB Ozy support # USBOZY_INCLUDE=USBOZY @@ -26,12 +14,6 @@ LOCALCW_INCLUDE=LOCALCW # uncomment the line below for SoapySDR #SOAPYSDR_INCLUDE=SOAPYSDR -# uncomment the line below to include support for psk31 -#PSK_INCLUDE=PSK - -# uncomment the line to below include support for FreeDV codec2 -#FREEDV_INCLUDE=FREEDV - # uncomment the line to below include support for sx1509 i2c expander #SX1509_INCLUDE=sx1509 @@ -99,7 +81,6 @@ USBOZY_OBJS= \ ozyio.o endif - ifeq ($(SOAPYSDR_INCLUDE),SOAPYSDR) SOAPYSDR_OPTIONS=-D SOAPYSDR SOAPYSDRLIBS=-lSoapySDR @@ -114,36 +95,6 @@ soapy_discovery.o \ soapy_protocol.o endif - -ifeq ($(PSK_INCLUDE),PSK) -PSK_OPTIONS=-D PSK -PSKLIBS=-lpsk -PSK_SOURCES= \ -psk.c \ -psk_waterfall.c -PSK_HEADERS= \ -psk.h \ -psk_waterfall.h -PSK_OBJS= \ -psk.o \ -psk_waterfall.o -endif - - -ifeq ($(FREEDV_INCLUDE),FREEDV) -FREEDV_OPTIONS=-D FREEDV -FREEDVLIBS=-lcodec2 -FREEDV_SOURCES= \ -freedv.c \ -freedv_menu.c -FREEDV_HEADERS= \ -freedv.h \ -freedv_menu.h -FREEDV_OBJS= \ -freedv.o \ -freedv_menu.o -endif - ifeq ($(LOCALCW_INCLUDE),LOCALCW) LOCALCW_OPTIONS=-D LOCALCW LOCALCW_SOURCES= iambic.c @@ -151,30 +102,6 @@ LOCALCW_HEADERS= iambic.h LOCALCW_OBJS = iambic.o endif -ifeq ($(GPIO_INCLUDE),GPIO) - GPIO_OPTIONS=-D GPIO - GPIO_LIBS=-lwiringPi - GPIO_SOURCES= \ - gpio.c \ - encoder_menu.c \ - switch_menu.c - GPIO_HEADERS= \ - gpio.h \ - encoder_menu.h \ - switch_menu.h - GPIO_OBJS= \ - gpio.o \ - encoder_menu.o \ - switch_menu.o -endif - -ifeq ($(I2C_INCLUDE),I2C) - I2C_OPTIONS=-D I2C - I2C_SOURCES=i2c.c - I2C_HEADERS=i2c.h - I2C_OBJS=i2c.o -endif - # # We have two versions of STEMLAB_DISCOVERY here, # the second one has to be used @@ -207,12 +134,12 @@ AUDIO_LIBS=-lportaudio -O3 CFLAGS= -g -Wno-deprecated-declarations OPTIONS=$(MIDI_OPTIONS) $(PURESIGNAL_OPTIONS) $(REMOTE_OPTIONS) $(USBOZY_OPTIONS) \ - $(I2C_OPTIONS) $(GPIO_OPTIONS) $(SOAPYSDR_OPTIONS) $(FREEDV_OPTIONS) $(LOCALCW_OPTIONS) \ - $(PSK_OPTIONS) $(STEMLAB_OPTIONS) \ + $(SOAPYSDR_OPTIONS) $(LOCALCW_OPTIONS) \ + $(STEMLAB_OPTIONS) \ $(CONTROLLER2_OPTIONS) $(AUDIO_OPTIONS) \ -D GIT_DATE='"$(GIT_DATE)"' -D GIT_VERSION='"$(GIT_VERSION)"' $(DEBUG_OPTION) -LIBS= -lm -lwdsp -lpthread $(AUDIO_LIBS) $(USBOZY_LIBS) $(PSKLIBS) $(GTKLIBS) $(GPIO_LIBS) $(SOAPYSDRLIBS) $(FREEDVLIBS) $(STEMLAB_LIBS) $(MIDI_LIBS) +LIBS= -lm -lwdsp -lpthread $(AUDIO_LIBS) $(USBOZY_LIBS) $(GTKLIBS) $(SOAPYSDRLIBS) $(STEMLAB_LIBS) $(MIDI_LIBS) INCLUDES=$(GTKINCLUDES) COMPILE=$(CC) $(CFLAGS) $(OPTIONS) $(INCLUDES) @@ -224,10 +151,8 @@ PROGRAM=pihpsdr SOURCES= \ audio.c \ -audio_waterfall.c \ band.c \ configure.c \ -frequency.c \ discovered.c \ discovery.c \ filter.c \ @@ -294,12 +219,10 @@ cwramp.c HEADERS= \ audio.h \ -audio_waterfall.h \ agc.h \ alex.h \ band.h \ configure.h \ -frequency.h \ bandstack.h \ channel.h \ discovered.h \ @@ -365,10 +288,8 @@ error_handler.h OBJS= \ audio.o \ portaudio.o \ -audio_waterfall.o \ band.o \ configure.o \ -frequency.o \ discovered.o \ discovery.o \ filter.o \ @@ -431,18 +352,18 @@ ext.o \ error_handler.o \ cwramp.o -$(PROGRAM): $(OBJS) $(REMOTE_OBJS) $(USBOZY_OBJS) $(SOAPYSDR_OBJS) $(FREEDV_OBJS) \ - $(LOCALCW_OBJS) $(I2C_OBJS) $(GPIO_OBJS) $(PSK_OBJS) $(PURESIGNAL_OBJS) \ +$(PROGRAM): $(OBJS) $(REMOTE_OBJS) $(USBOZY_OBJS) $(SOAPYSDR_OBJS) \ + $(LOCALCW_OBJS) $(PURESIGNAL_OBJS) \ $(MIDI_OBJS) $(STEMLAB_OBJS) - $(LINK) -o $(PROGRAM) $(OBJS) $(REMOTE_OBJS) $(USBOZY_OBJS) $(I2C_OBJS) $(GPIO_OBJS) \ - $(SOAPYSDR_OBJS) $(FREEDV_OBJS) $(LOCALCW_OBJS) $(PSK_OBJS) $(PURESIGNAL_OBJS) \ + $(LINK) -o $(PROGRAM) $(OBJS) $(REMOTE_OBJS) $(USBOZY_OBJS) \ + $(SOAPYSDR_OBJS) $(LOCALCW_OBJS) $(PURESIGNAL_OBJS) \ $(MIDI_OBJS) $(STEMLAB_OBJS) $(LIBS) all: prebuild $(PROGRAM) $(HEADERS) $(REMOTE_HEADERS) $(USBOZY_HEADERS) $(SOAPYSDR_HEADERS) \ - $(FREEDV_HEADERS) $(LOCALCW_HEADERS) $(I2C_HEADERS) $(GPIO_HEADERS) $(PSK_HEADERS) \ + $(LOCALCW_HEADERS) \ $(PURESIGNAL_HEADERS) $(MIDI_HEADERS) $(STEMLAB_HEADERS) $(SOURCES) $(REMOTE_SOURCES) \ - $(USBOZY_SOURCES) $(SOAPYSDR_SOURCES) $(FREEDV_SOURCES) $(I2C_SOURCES) $(GPIO_SOURCES) \ - $(PSK_SOURCES) $(PURESIGNAL_SOURCES) $(MIDI_SOURCES) $(STEMLAB_SOURCES) $(LOCALCW_SOURCES) + $(USBOZY_SOURCES) $(SOAPYSDR_SOURCES) \ + $(PURESIGNAL_SOURCES) $(MIDI_SOURCES) $(STEMLAB_SOURCES) $(LOCALCW_SOURCES) prebuild: rm -f version.o @@ -459,8 +380,8 @@ CPPINCLUDES:=$(shell echo $(INCLUDES) | sed -e "s/-pthread / /" ) .PHONY: cppcheck cppcheck: cppcheck $(CPPOPTIONS) $(OPTIONS) $(CPPINCLUDES) $(SOURCES) $(REMOTE_SOURCES) \ - $(USBOZY_SOURCES) $(SOAPYSDR_SOURCES) $(FREEDV_SOURCES) $(I2C_SOURCES) $(GPIO_SOURCES) \ - $(PSK_SOURCES) $(PURESIGNAL_SOURCES) $(MIDI_SOURCES) $(STEMLAB_SOURCES) $(LOCALCW_SOURCES) + $(USBOZY_SOURCES) $(SOAPYSDR_SOURCES) \ + $(PURESIGNAL_SOURCES) $(MIDI_SOURCES) $(STEMLAB_SOURCES) $(LOCALCW_SOURCES) clean: -rm -f *.o @@ -536,12 +457,12 @@ hpsdrsim: hpsdrsim.o newhpsdrsim.o # are stored. # ############################################################################# -app: $(OBJS) $(REMOTE_OBJS) $(USBOZY_OBJS) $(LIMESDR_OBJS) $(FREEDV_OBJS) \ - $(LOCALCW_OBJS) $(I2C_OBJS) $(GPIO_OBJS) $(PSK_OBJS) \ +app: $(OBJS) $(REMOTE_OBJS) $(USBOZY_OBJS) \ + $(LOCALCW_OBJS) \ $(PURESIGNAL_OBJS) $(MIDI_OBJS) $(STEMLAB_OBJS) $(LINK) -headerpad_max_install_names -o $(PROGRAM) $(OBJS) $(REMOTE_OBJS) \ - $(USBOZY_OBJS) $(I2C_OBJS) $(GPIO_OBJS) $(LIMESDR_OBJS) \ - $(FREEDV_OBJS) $(LOCALCW_OBJS) $(PSK_OBJS) $(PURESIGNAL_OBJS) \ + $(USBOZY_OBJS) \ + $(LOCALCW_OBJS) $(PURESIGNAL_OBJS) \ $(MIDI_OBJS) $(STEMLAB_OBJS) $(LIBS) @rm -rf pihpsdr.app @mkdir -p pihpsdr.app/Contents/MacOS diff --git a/about_menu.c b/about_menu.c index 8c4e9ee..d25b21c 100644 --- a/about_menu.c +++ b/about_menu.c @@ -144,10 +144,6 @@ void about_menu(GtkWidget *parent) { break; } -#ifdef FREEDV - strcat(text,"\n\nIncludes: FREEDV"); -#endif - label=gtk_label_new(text); gtk_label_set_justify(GTK_LABEL(label),GTK_JUSTIFY_LEFT); gtk_grid_attach(GTK_GRID(grid),label,1,row,4,1); diff --git a/ant_menu.c b/ant_menu.c index b0cec5b..be686d7 100644 --- a/ant_menu.c +++ b/ant_menu.c @@ -109,11 +109,37 @@ static void tx_ant_cb(GtkToggleButton *widget, gpointer data) { static void show_hf() { int i; - for(i=0;ititle)>0) { - GtkWidget *band_label=gtk_label_new(band->title); + GtkWidget *band_label=gtk_label_new(NULL); //gtk_widget_override_font(band_label, pango_font_description_from_string("Arial 18")); + gtk_label_set_markup(GTK_LABEL(band_label), band->title); gtk_widget_show(band_label); gtk_grid_attach(GTK_GRID(grid),band_label,0,i+2,1,1); @@ -184,8 +210,9 @@ static void show_xvtr() { for(i=0;ititle)>0) { - GtkWidget *band_label=gtk_label_new(band->title); + GtkWidget *band_label=gtk_label_new(NULL); //gtk_widget_override_font(band_label, pango_font_description_from_string("Arial 18")); + gtk_label_set_markup(GTK_LABEL(band_label), band->title); gtk_widget_show(band_label); gtk_grid_attach(GTK_GRID(grid),band_label,0,i+2,1,1); @@ -335,57 +362,68 @@ void ant_menu(GtkWidget *parent) { if(protocol==ORIGINAL_PROTOCOL || protocol==NEW_PROTOCOL) { - GtkWidget *rx_ant_label=gtk_label_new("Receive"); + GtkWidget *rx_ant_label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(rx_ant_label), "Receive"); //gtk_widget_override_font(rx_ant_label, pango_font_description_from_string("Arial 18")); gtk_widget_show(rx_ant_label); gtk_grid_attach(GTK_GRID(grid),rx_ant_label,0,1,1,1); - GtkWidget *rx1_label=gtk_label_new("1"); + GtkWidget *rx1_label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(rx1_label), "1"); //gtk_widget_override_font(rx1_label, pango_font_description_from_string("Arial 18")); gtk_widget_show(rx1_label); gtk_grid_attach(GTK_GRID(grid),rx1_label,1,1,1,1); - GtkWidget *rx2_label=gtk_label_new("2"); + GtkWidget *rx2_label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(rx2_label), "2"); //gtk_widget_override_font(rx2_label, pango_font_description_from_string("Arial 18")); gtk_widget_show(rx2_label); gtk_grid_attach(GTK_GRID(grid),rx2_label,2,1,1,1); - GtkWidget *rx3_label=gtk_label_new("3"); + GtkWidget *rx3_label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(rx3_label), "3"); //gtk_widget_override_font(rx3_label, pango_font_description_from_string("Arial 18")); gtk_widget_show(rx3_label); gtk_grid_attach(GTK_GRID(grid),rx3_label,3,1,1,1); - GtkWidget *ext1_label=gtk_label_new("EXT1"); + GtkWidget *ext1_label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(ext1_label), "EXT1"); //gtk_widget_override_font(ext1_label, pango_font_description_from_string("Arial 18")); gtk_widget_show(ext1_label); gtk_grid_attach(GTK_GRID(grid),ext1_label,4,1,1,1); - GtkWidget *ext2_label=gtk_label_new("EXT2"); + GtkWidget *ext2_label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(ext2_label), "EXT2"); //gtk_widget_override_font(ext2_label, pango_font_description_from_string("Arial 18")); gtk_widget_show(ext2_label); gtk_grid_attach(GTK_GRID(grid),ext2_label,5,1,1,1); - GtkWidget *xvtr_label=gtk_label_new("XVTR"); + GtkWidget *xvtr_label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(xvtr_label), "XVTR"); //gtk_widget_override_font(xvtr_label, pango_font_description_from_string("Arial 18")); gtk_widget_show(xvtr_label); gtk_grid_attach(GTK_GRID(grid),xvtr_label,6,1,1,1); - GtkWidget *tx_ant_label=gtk_label_new("Transmit"); + GtkWidget *tx_ant_label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(tx_ant_label), "Transmit"); //gtk_widget_override_font(tx_ant_label, pango_font_description_from_string("Arial 18")); gtk_widget_show(tx_ant_label); gtk_grid_attach(GTK_GRID(grid),tx_ant_label,7,1,1,1); - GtkWidget *tx1_label=gtk_label_new("1"); + GtkWidget *tx1_label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(tx1_label), "1"); //gtk_widget_override_font(tx1_label, pango_font_description_from_string("Arial 18")); gtk_widget_show(tx1_label); gtk_grid_attach(GTK_GRID(grid),tx1_label,8,1,1,1); - GtkWidget *tx2_label=gtk_label_new("2"); + GtkWidget *tx2_label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(tx2_label), "2"); //gtk_widget_override_font(tx2_label, pango_font_description_from_string("Arial 18")); gtk_widget_show(tx2_label); gtk_grid_attach(GTK_GRID(grid),tx2_label,9,1,1,1); - GtkWidget *tx3_label=gtk_label_new("3"); + GtkWidget *tx3_label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(tx3_label), "3"); //gtk_widget_override_font(tx3_label, pango_font_description_from_string("Arial 18")); gtk_widget_show(tx3_label); gtk_grid_attach(GTK_GRID(grid),tx3_label,10,1,1,1); @@ -399,7 +437,8 @@ void ant_menu(GtkWidget *parent) { g_print("rx_antennas=%ld\n",radio->info.soapy.rx_antennas); if(radio->info.soapy.rx_antennas>0) { - GtkWidget *antenna_label=gtk_label_new("RX Antenna:"); + GtkWidget *antenna_label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(antenna_label), "RX Antenna:"); gtk_grid_attach(GTK_GRID(grid),antenna_label,0,1,1,1); adc0_antenna_combo_box=gtk_combo_box_text_new(); @@ -415,7 +454,8 @@ g_print("rx_antennas=%ld\n",radio->info.soapy.rx_antennas); if(can_transmit) { g_print("tx_antennas=%ld\n",radio->info.soapy.tx_antennas); if(radio->info.soapy.tx_antennas>0) { - GtkWidget *antenna_label=gtk_label_new("TX Antenna:"); + GtkWidget *antenna_label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(antenna_label), "TX Antenna:"); gtk_grid_attach(GTK_GRID(grid),antenna_label,0,2,1,1); dac0_antenna_combo_box=gtk_combo_box_text_new(); diff --git a/audio.c b/audio.c index 238d6d2..d08adfc 100644 --- a/audio.c +++ b/audio.c @@ -522,6 +522,9 @@ g_print("mic_read_thread: snd_pcm_start\n"); switch(protocol) { case ORIGINAL_PROTOCOL: case NEW_PROTOCOL: +#ifdef SOAPYSDR + case SOAPYSDR_PROTOCOL: +#endif // // put sample into ring buffer // @@ -538,12 +541,6 @@ g_print("mic_read_thread: snd_pcm_start\n"); } } break; -#ifdef SOAPYSDR - case SOAPYSDR_PROTOCOL: - // Note that this call ends up deeply in the TX engine - soapy_protocol_process_local_mic(sample); - break; -#endif default: break; } diff --git a/band.c b/band.c index ca073d5..92543d2 100644 --- a/band.c +++ b/band.c @@ -27,12 +27,17 @@ #include "mode.h" #include "alex.h" #include "property.h" +#include "radio.h" +#include "vfo.h" #define LINESDR int band=band20; int xvtr_band=BANDS; +char* outOfBand="Out of band"; +int info_band; + /* --------------------------------------------------------------------------*/ /** * @brief bandstack @@ -265,7 +270,9 @@ BANDSTACK bandstack_xvtr_7={3,0,bandstack_entries_xvtr_7}; BAND bands[BANDS+XVTRS] = - {{"160",&bandstack160,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,1800000LL,2000000LL,0LL,0LL,0}, + {{"136kHz",&bandstack136,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,135700LL,137800LL,0LL,0LL,0}, + {"472kHz",&bandstack472,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,472000LL,479000LL,0LL,0LL,0}, + {"160",&bandstack160,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,1800000LL,2000000LL,0LL,0LL,0}, {"80",&bandstack80,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,3500000LL,4000000LL,0LL,0LL,0}, {"60",&bandstack60,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,5330500LL,5403500LL,0LL,0LL,0}, {"40",&bandstack40,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,7000000LL,7300000LL,0LL,0LL,0}, @@ -289,8 +296,6 @@ BAND bands[BANDS+XVTRS] = #endif {"GEN",&bandstackGEN,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,0LL,0LL,0LL,0LL,0}, {"WWV",&bandstackWWV,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,0LL,0LL,0LL,0LL,0}, - {"136kHz",&bandstack136,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,135700LL,137800LL,0LL,0LL,0}, - {"472kHz",&bandstack472,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,472000LL,479000LL,0LL,0LL,0}, // XVTRS {"",&bandstack_xvtr_0,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,0LL,0LL,0LL,0LL,0}, {"",&bandstack_xvtr_1,0,0,0,0,0,ALEX_ATTENUATION_0dB,53.0,0LL,0LL,0LL,0LL,0}, @@ -644,3 +649,146 @@ int get_band_from_frequency(long long f) { g_print("get_band_from_frequency: %lld id %d\n",f,found); return found; } + +char* getFrequencyInfo(long long frequency,int filter_low,int filter_high) { + char* result=outOfBand; + int i; + + long long flow=frequency+(long long)filter_low; + long long fhigh=frequency+(long long)filter_high; + + + int b; + + info_band=BANDS+XVTRS; + for(b=0;btitle)>0) { + + if(flow>=band->frequencyMin && fhigh<=band->frequencyMax) { + if(b==band60) { + for(i=0;i=low_freq && fhigh<=hi_freq) { + info_band=b; + result=band->title; + break; + } + } + } else { + info_band=b; + result=band->title; + break; + } + } + } + } + +g_print("getFrequencyInfo %lld is %s\n",frequency,result); + + return result; +} + +int canTransmit() { + int result; + long long txfreq, flow, fhigh; + int txb, txvfo, txmode; + BAND *txband; + int i; + + // + // If there is no transmitter, we cannot transmit + // + if (!can_transmit) return 0; + + // + // In the code canTransmit() is always ORed with tx_out_of_band, + // but this should be done in ONE PLACE (here) + // + if (tx_out_of_band) return 1; + + txvfo=get_tx_vfo(); + txb=vfo[txvfo].band; + + // + // See if we have a band + // +if(info_band!=bandGen + && info_band!=bandWWV +#ifdef SOAPYSDR + && info_band!=bandAIR +#endif + ) { + result=TRUE; + } + + if (txb == bandGen + || txb ==bandWWV +#ifdef SOAPYSDR + || txb ==bandAIR +#endif + ) return 0; + + // + // Determine the edges of our band + // and the edges of our TX signal + // + txband=band_get_band(vfo[txvfo].band); + txfreq=get_tx_freq(); + txmode=get_tx_mode(); + switch (txmode) { + case modeCWU: + flow = fhigh = cw_is_on_vfo_freq ? txfreq : txfreq + cw_keyer_sidetone_frequency; + break; + case modeCWL: + flow = fhigh = cw_is_on_vfo_freq ? txfreq : txfreq - cw_keyer_sidetone_frequency; + break; + default: + flow = txfreq + transmitter->filter_low; + fhigh= txfreq + transmitter->filter_high; + break; + } + + if (txb == band60) { + // + // For 60m band, ensure signal is within one of the "channels" + // + result=0; + for(i=0;i=low_freq && fhigh<=hi_freq) { +//fprintf(stderr,"60m channel OK: chan=%d flow=%lld fhigh=%lld\n", i, flow, fhigh); + result = 1; + break; + } + } +//fprintf(stderr,"60m channel NOT FOUND: flow=%lld fhigh=%lld\n", flow, fhigh); + } else { + // + // For other bands, return true if signal within band + // + result = flow >= txband->frequencyMin && fhigh <= txband->frequencyMax; + } +//fprintf(stderr,"CANTRANSMIT: low=%lld high=%lld transmit=%d\n", flow, fhigh, result); + return result; +} + + +/* +int canTransmit() { + int result=FALSE; + if (tx_out_of_band) return TRUE; + if(info_band!=bandGen + && info_band!=bandWWV +#ifdef SOAPYSDR + && info_band!=bandAIR +#endif + ) { + result=TRUE; + } + return result; +} +*/ diff --git a/band.h b/band.h index 026f318..7d2de4d 100644 --- a/band.h +++ b/band.h @@ -23,38 +23,35 @@ #include #include "bandstack.h" -#define band160 0 -#define band80 1 -#define band60 2 -#define band40 3 -#define band30 4 -#define band20 5 -#define band17 6 -#define band15 7 -#define band12 8 -#define band10 9 -#define band6 10 +enum { + band136=0, + band472, + band160, + band80, + band60, + band40, + band30, + band20, + band17, + band15, + band12, + band10, + band6, #ifdef SOAPYSDR -#define band70 11 -#define band220 13 -#define band430 14 -#define band902 15 -#define band1240 16 -#define band2300 17 -#define band3400 18 -#define bandAIR 19 -#define bandGen 20 -#define bandWWV 21 -#define band136 22 -#define band472 23 -#define BANDS 24 -#else -#define bandGen 11 -#define bandWWV 12 -#define band136 13 -#define band472 14 -#define BANDS 15 + band70, + band144, + band220, + band430, + band902, + band1240, + band2300, + band3400, + bandAIR, #endif + bandWWV, + bandGen, + BANDS +}; #define XVTRS 8 @@ -127,4 +124,7 @@ extern BANDSTACK_ENTRY *bandstack_entry_get_current(); extern void bandSaveState(); extern void bandRestoreState(); +char* getFrequencyInfo(long long frequency,int filter_low,int filter_high); +int canTransmit(); + #endif diff --git a/channel.h b/channel.h index 43b2dff..9a64bcd 100644 --- a/channel.h +++ b/channel.h @@ -32,9 +32,6 @@ #define CHANNEL_BS 9 #define CHANNEL_SUBRX 10 #define CHANNEL_AUDIO 11 -#ifdef PSK -#define CHANNEL_PSK 12 -#endif #endif diff --git a/discovery.c b/discovery.c index d082983..30a8a76 100644 --- a/discovery.c +++ b/discovery.c @@ -49,6 +49,9 @@ #include "stemlab_discovery.h" #endif #include "ext.h" +#ifdef GPIO +#include "gpio.h" +#endif #include "configure.h" static GtkWidget *discovery_dialog; @@ -63,6 +66,10 @@ GtkWidget *tcpaddr; static char ipaddr_tcp_buf[IPADDR_LEN] = "10.10.10.10"; char *ipaddr_tcp = &ipaddr_tcp_buf[0]; +static gboolean delete_event_cb(GtkWidget *widget, GdkEvent *event, gpointer data) { + _exit(0); +} + static gboolean start_cb (GtkWidget *widget, GdkEventButton *event, gpointer data) { radio=(DISCOVERED *)data; #ifdef STEMLAB_DISCOVERY @@ -198,10 +205,18 @@ static gboolean midi_cb(GtkWidget *widget, GdkEventButton *event, gpointer data) #endif #ifdef GPIO +/* static gboolean gpio_cb (GtkWidget *widget, GdkEventButton *event, gpointer data) { configure_gpio(discovery_dialog); return TRUE; } +*/ + +static void gpio_changed_cb(GtkWidget *widget, gpointer data) { + controller=gtk_combo_box_get_active(GTK_COMBO_BOX(widget)); + gpio_set_defaults(controller); + gpio_save_state(); +} #endif static gboolean discover_cb (GtkWidget *widget, GdkEventButton *event, gpointer data) { @@ -304,6 +319,7 @@ void discovery() { //gtk_window_set_decorated(GTK_WINDOW(discovery_dialog),FALSE); //gtk_widget_override_font(discovery_dialog, pango_font_description_from_string("FreeMono 16")); + g_signal_connect(discovery_dialog, "delete_event", G_CALLBACK(delete_event_cb), NULL); GdkRGBA color; color.red = 1.0; @@ -352,6 +368,7 @@ void discovery() { //gtk_window_set_decorated(GTK_WINDOW(discovery_dialog),FALSE); //gtk_widget_override_font(discovery_dialog, pango_font_description_from_string("FreeMono 16")); + g_signal_connect(discovery_dialog, "delete_event", G_CALLBACK(delete_event_cb), NULL); GdkRGBA color; color.red = 1.0; @@ -497,9 +514,26 @@ fprintf(stderr,"%p Protocol=%d name=%s\n",d,d->protocol,d->name); } #ifdef GPIO +/* GtkWidget *gpio_b=gtk_button_new_with_label("Config GPIO"); g_signal_connect (gpio_b, "button-press-event", G_CALLBACK(gpio_cb), NULL); gtk_grid_attach(GTK_GRID(grid),gpio_b,0,i,1,1); +*/ + + controller=CONTROLLER2_V2; + gpio_set_defaults(controller); + gpio_restore_state(); + + GtkWidget *gpio=gtk_combo_box_text_new(); + gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(gpio),NULL,"No Controller"); + gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(gpio),NULL,"Controller1"); + gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(gpio),NULL,"Controller2 V1"); + gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(gpio),NULL,"Controller2 V2"); + gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(gpio),NULL,"Custom"); + gtk_grid_attach(GTK_GRID(grid),gpio,0,i,1,1); + + gtk_combo_box_set_active(GTK_COMBO_BOX(gpio),controller); + g_signal_connect(gpio,"changed",G_CALLBACK(gpio_changed_cb),NULL); #endif GtkWidget *discover_b=gtk_button_new_with_label("Discover"); diff --git a/display_menu.c b/display_menu.c index 63ec35f..7155bb2 100644 --- a/display_menu.c +++ b/display_menu.c @@ -171,7 +171,8 @@ void display_menu(GtkWidget *parent) { row++; col=0; - GtkWidget *frames_per_second_label=gtk_label_new("Frames Per Second: "); + GtkWidget *frames_per_second_label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(frames_per_second_label), "Frames Per Second:"); //gtk_widget_override_font(frames_per_second_label, pango_font_description_from_string("Arial 18")); gtk_widget_show(frames_per_second_label); gtk_grid_attach(GTK_GRID(grid),frames_per_second_label,col,row,1,1); @@ -188,7 +189,8 @@ void display_menu(GtkWidget *parent) { row++; col=0; - GtkWidget *panadapter_high_label=gtk_label_new("Panadapter High: "); + GtkWidget *panadapter_high_label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(panadapter_high_label), "Panadapter High: "); //gtk_widget_override_font(panadapter_high_label, pango_font_description_from_string("Arial 18")); gtk_widget_show(panadapter_high_label); gtk_grid_attach(GTK_GRID(grid),panadapter_high_label,col,row,1,1); @@ -205,7 +207,8 @@ void display_menu(GtkWidget *parent) { row++; col=0; - GtkWidget *panadapter_low_label=gtk_label_new("Panadapter Low: "); + GtkWidget *panadapter_low_label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(panadapter_low_label), "Panadapter Low: "); //gtk_widget_override_font(panadapter_low_label, pango_font_description_from_string("Arial 18")); gtk_widget_show(panadapter_low_label); gtk_grid_attach(GTK_GRID(grid),panadapter_low_label,col,row,1,1); @@ -222,7 +225,8 @@ void display_menu(GtkWidget *parent) { row++; col=0; - GtkWidget *panadapter_step_label=gtk_label_new("Panadapter Step: "); + GtkWidget *panadapter_step_label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(panadapter_step_label), "Panadapter Step: "); //gtk_widget_override_font(panadapter_step_label, pango_font_description_from_string("Arial 18")); gtk_widget_show(panadapter_step_label); gtk_grid_attach(GTK_GRID(grid),panadapter_step_label,col,row,1,1); @@ -239,7 +243,8 @@ void display_menu(GtkWidget *parent) { row++; col=0; - GtkWidget *waterfall_automatic_label=gtk_label_new("Waterfall Automatic: "); + GtkWidget *waterfall_automatic_label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(waterfall_automatic_label), "Waterfall Automatic: "); //gtk_widget_override_font(waterfall_automatic_label, pango_font_description_from_string("Arial 18")); gtk_widget_show(waterfall_automatic_label); gtk_grid_attach(GTK_GRID(grid),waterfall_automatic_label,col,row,1,1); @@ -256,7 +261,8 @@ void display_menu(GtkWidget *parent) { row++; col=0; - GtkWidget *waterfall_high_label=gtk_label_new("Waterfall High: "); + GtkWidget *waterfall_high_label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(waterfall_high_label), "Waterfall High: "); //gtk_widget_override_font(waterfall_high_label, pango_font_description_from_string("Arial 18")); gtk_widget_show(waterfall_high_label); gtk_grid_attach(GTK_GRID(grid),waterfall_high_label,col,row,1,1); @@ -273,7 +279,8 @@ void display_menu(GtkWidget *parent) { row++; col=0; - GtkWidget *waterfall_low_label=gtk_label_new("Waterfall Low: "); + GtkWidget *waterfall_low_label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(waterfall_low_label), "Waterfall Low: "); //gtk_widget_override_font(waterfall_low_label, pango_font_description_from_string("Arial 18")); gtk_widget_show(waterfall_low_label); gtk_grid_attach(GTK_GRID(grid),waterfall_low_label,col,row,1,1); @@ -290,7 +297,8 @@ void display_menu(GtkWidget *parent) { col=2; row=1; - GtkWidget *detector_mode_label=gtk_label_new("Detector: "); + GtkWidget *detector_mode_label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(detector_mode_label), "Detector:"); //gtk_widget_override_font(detector_mode_label, pango_font_description_from_string("Arial 18")); gtk_widget_show(detector_mode_label); gtk_grid_attach(GTK_GRID(grid),detector_mode_label,col,row,1,1); @@ -332,6 +340,7 @@ void display_menu(GtkWidget *parent) { row=1; GtkWidget *average_mode_label=gtk_label_new("Averaging: "); + gtk_label_set_markup(GTK_LABEL(average_mode_label), "Averaging:"); //gtk_widget_override_font(average_mode_label, pango_font_description_from_string("Arial 18")); gtk_widget_show(average_mode_label); gtk_grid_attach(GTK_GRID(grid),average_mode_label,col,row,1,1); diff --git a/dsp_menu.c b/dsp_menu.c index e0780bb..c02b631 100644 --- a/dsp_menu.c +++ b/dsp_menu.c @@ -121,16 +121,19 @@ void dsp_menu(GtkWidget *parent) { g_signal_connect (close_b, "pressed", G_CALLBACK(close_cb), NULL); gtk_grid_attach(GTK_GRID(grid),close_b,0,0,1,1); - GtkWidget *agc_hang_threshold_label=gtk_label_new("AGC Hang Threshold:"); + GtkWidget *agc_hang_threshold_label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(agc_hang_threshold_label), "AGC Hang Threshold"); gtk_widget_show(agc_hang_threshold_label); gtk_grid_attach(GTK_GRID(grid),agc_hang_threshold_label,0,1,1,1); GtkWidget *agc_hang_threshold_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, 0.0, 100.0, 1.0); + gtk_range_set_increments (GTK_RANGE(agc_hang_threshold_scale),1.0,1.0); gtk_range_set_value (GTK_RANGE(agc_hang_threshold_scale),active_receiver->agc_hang_threshold); gtk_widget_show(agc_hang_threshold_scale); gtk_grid_attach(GTK_GRID(grid),agc_hang_threshold_scale,1,1,2,1); g_signal_connect(G_OBJECT(agc_hang_threshold_scale),"value_changed",G_CALLBACK(agc_hang_threshold_value_changed_cb),NULL); - GtkWidget *pre_post_agc_label=gtk_label_new("NR/NR2/ANF"); + GtkWidget *pre_post_agc_label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(pre_post_agc_label), "NR/NR2/ANF"); //gtk_widget_override_font(pre_post_agc_label, pango_font_description_from_string("Arial 18")); gtk_widget_show(pre_post_agc_label); gtk_grid_attach(GTK_GRID(grid),pre_post_agc_label,0,2,1,1); @@ -147,7 +150,8 @@ void dsp_menu(GtkWidget *parent) { gtk_grid_attach(GTK_GRID(grid),post_agc_b,2,2,1,1); g_signal_connect(post_agc_b,"toggled",G_CALLBACK(pre_post_agc_cb),(gpointer *)1); - GtkWidget *nr2_gain_label=gtk_label_new("NR2 Gain Method"); + GtkWidget *nr2_gain_label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(nr2_gain_label), "NR Gain Method"); //gtk_widget_override_font(nr2_gain_label, pango_font_description_from_string("Arial 18")); gtk_widget_show(nr2_gain_label); gtk_grid_attach(GTK_GRID(grid),nr2_gain_label,0,3,1,1); @@ -171,6 +175,7 @@ void dsp_menu(GtkWidget *parent) { g_signal_connect(gamma_b,"toggled",G_CALLBACK(nr2_gain_cb),(gpointer *)2); GtkWidget *nr2_npe_method_label=gtk_label_new("NR2 NPE Method"); + gtk_label_set_markup(GTK_LABEL(nr2_npe_method_label), "NR2 NPE Method"); //gtk_widget_override_font(nr2_npe_method_label, pango_font_description_from_string("Arial 18")); gtk_widget_show(nr2_npe_method_label); gtk_grid_attach(GTK_GRID(grid),nr2_npe_method_label,0,4,1,1); diff --git a/encoder_menu.c b/encoder_menu.c index 71dd31b..da4f775 100644 --- a/encoder_menu.c +++ b/encoder_menu.c @@ -32,9 +32,7 @@ #include "vfo.h" #include "button_text.h" #include "gpio.h" -#if defined (CONTROLLER2_V2) || defined (CONTROLLER_V1) #include "i2c.h" -#endif static GtkWidget *parent_window=NULL; @@ -58,7 +56,6 @@ static GtkWidget *b_panadapter_low; static GtkWidget *b_squelch; static GtkWidget *b_compression; -#ifdef CONTROLLER2_V2 static GtkWidget *b_top_af_gain_rx1; static GtkWidget *b_top_af_gain_rx2; static GtkWidget *b_top_agc_gain_rx1; @@ -76,31 +73,20 @@ static GtkWidget *b_top_panadapter_high; static GtkWidget *b_top_panadapter_low; static GtkWidget *b_top_squelch; static GtkWidget *b_top_compression; -#endif enum { ENC2, -#ifdef CONTROLLER2_V2 ENC2_TOP, -#endif ENC2_SW, ENC3, -#ifdef CONTROLLER2_V2 ENC3_TOP, -#endif ENC3_SW, ENC4, -#ifdef CONTROLLER2_V2 ENC4_TOP, -#endif ENC4_SW, -#if defined (CONTROLLER2_V2) || defined (CONTROLLER2_V1) ENC5, -#if defined (CONTROLLER2_V2) ENC5_TOP, -#endif ENC5_SW, -#endif }; typedef struct _choice { @@ -136,37 +122,27 @@ static void enc_select_cb(GtkWidget *widget,gpointer data) { case ENC2: e2_encoder_action=choice->action; break; -#ifdef CONTROLLER2_V2 case ENC2_TOP: e2_top_encoder_action=choice->action; break; -#endif case ENC3: e3_encoder_action=choice->action; break; -#ifdef CONTROLLER2_V2 case ENC3_TOP: e3_top_encoder_action=choice->action; break; -#endif case ENC4: e4_encoder_action=choice->action; break; -#ifdef CONTROLLER2_V2 case ENC4_TOP: e4_top_encoder_action=choice->action; break; -#endif -#if defined (CONTROLLER2_V2) || defined (CONTROLLER2_V1) case ENC5: e5_encoder_action=choice->action; break; -#endif -#if defined (CONTROLLER2_V2) case ENC5_TOP: e5_top_encoder_action=choice->action; break; -#endif } gtk_button_set_label(GTK_BUTTON(choice->button),encoder_string[choice->action]); } @@ -209,11 +185,9 @@ static void sw_select_cb(GtkWidget *widget,gpointer data) { case ENC4_SW: e4_sw_action=choice->action; break; -#ifdef CONTROLLER2_V2 case ENC5_SW: e5_sw_action=choice->action; break; -#endif } gtk_button_set_label(GTK_BUTTON(choice->button),sw_string[choice->action]); } @@ -268,11 +242,9 @@ GtkWidget* getRadioButton(int action) { case ENCODER_DRIVE: button=b_drive; break; -/* case ENCODER_TUNE_DRIVE: button=b_tune_drive; break; -*/ case ENCODER_RIT_RX1: button=b_rit_rx1; break; @@ -304,7 +276,6 @@ GtkWidget* getRadioButton(int action) { return button; } -#ifdef CONTROLLER2_V2 GtkWidget* getTopRadioButton(int action) { GtkWidget* button; switch(action) { @@ -364,8 +335,6 @@ GtkWidget* getTopRadioButton(int action) { } return button; } -#endif - static gboolean select_cb (GtkWidget *widget, gpointer data) { GtkWidget *button; @@ -389,7 +358,6 @@ static gboolean select_cb (GtkWidget *widget, gpointer data) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE); } -#ifdef CONTROLLER2_V2 static gboolean top_select_cb (GtkWidget *widget, gpointer data) { GtkWidget *button; int action; @@ -411,7 +379,6 @@ static gboolean top_select_cb (GtkWidget *widget, gpointer data) { button=getTopRadioButton(action); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE); } -#endif void encoder_select(int pos) { int action; @@ -466,7 +433,6 @@ void encoder_select(int pos) { } -#ifdef CONTROLLER2_V2 void top_encoder_select(int pos) { int action; GtkWidget *button; @@ -533,7 +499,6 @@ void top_encoder_select(int pos) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE); } -#endif static gboolean action_select_cb (GtkWidget *widget, gpointer data) { int action=(int)data; @@ -553,7 +518,6 @@ void top_encoder_select(int pos) { } } -#ifdef CONTROLLER2_V2 static gboolean top_action_select_cb (GtkWidget *widget, gpointer data) { int action=(int)data; switch(encoder) { @@ -571,7 +535,6 @@ void top_encoder_select(int pos) { break; } } -#endif static gboolean enc2_cb(GtkWidget *widget, gpointer data) { int i=gtk_combo_box_get_active (GTK_COMBO_BOX(widget)); @@ -609,7 +572,6 @@ void top_encoder_select(int pos) { return TRUE; } -#ifdef CONTROLLER2_V2 static gboolean enc2_top_cb(GtkWidget *widget, gpointer data) { int i=gtk_combo_box_get_active (GTK_COMBO_BOX(widget)); e2_top_encoder_action=i; @@ -645,7 +607,6 @@ void top_encoder_select(int pos) { e5_top_encoder_action=i; return TRUE; } -#endif void encoder_menu(GtkWidget *parent) { int row=0; @@ -673,33 +634,36 @@ void encoder_menu(GtkWidget *parent) { gtk_grid_attach(GTK_GRID(grid),close_b,col,row,1,1); row++; - col=1; -#ifdef CONTROLLER2_V2 -#ifdef CONTROLLER2_V1 - GtkWidget *label_encoder=gtk_label_new("Encoder"); - gtk_grid_attach(GTK_GRID(grid),label_encoder,col,row,1,1); - col++; -#else - GtkWidget *label_bottom=gtk_label_new("Bottom"); - gtk_grid_attach(GTK_GRID(grid),label_bottom,col,row,1,1); - col++; - GtkWidget *label_top=gtk_label_new("Top"); - gtk_grid_attach(GTK_GRID(grid),label_top,col,row,1,1); - col++; -#endif -#else - GtkWidget *label_encoder=gtk_label_new("Encoder"); + col=0; + GtkWidget *label_encoder=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(label_encoder), "Encoder"); gtk_grid_attach(GTK_GRID(grid),label_encoder,col,row,1,1); col++; -#endif - GtkWidget *label_switch=gtk_label_new("Switch"); + if(controller==CONTROLLER2_V2) { + GtkWidget *label_bottom=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(label_bottom), "Bottom"); + gtk_grid_attach(GTK_GRID(grid),label_bottom,col,row,1,1); + col++; + GtkWidget *label_top=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(label_top), "Top"); + gtk_grid_attach(GTK_GRID(grid),label_top,col,row,1,1); + col++; + } else { + GtkWidget *label_bottom=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(label_bottom), "Encoder"); + gtk_grid_attach(GTK_GRID(grid),label_bottom,col,row,1,1); + col++; + } + GtkWidget *label_switch=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(label_switch), "Switch"); gtk_grid_attach(GTK_GRID(grid),label_switch,col,row,1,1); col++; row++; col=0; - GtkWidget *enc2_title=gtk_label_new("ENC2: "); + GtkWidget *enc2_title=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(enc2_title), "ENC2: "); gtk_grid_attach(GTK_GRID(grid),enc2_title,col,row,1,1); col++; @@ -708,12 +672,12 @@ void encoder_menu(GtkWidget *parent) { g_signal_connect(enc2,"button_press_event",G_CALLBACK(enc_cb),GINT_TO_POINTER(ENC2)); col++; -#ifdef CONTROLLER2_V2 - GtkWidget *enc2_top=gtk_button_new_with_label(encoder_string[e2_top_encoder_action]); - gtk_grid_attach(GTK_GRID(grid),enc2_top,col,row,1,1); - g_signal_connect(enc2_top,"button_press_event",G_CALLBACK(enc_cb),GINT_TO_POINTER(ENC2_TOP)); - col++; -#endif + if(controller==CONTROLLER2_V2) { + GtkWidget *enc2_top=gtk_button_new_with_label(encoder_string[e2_top_encoder_action]); + gtk_grid_attach(GTK_GRID(grid),enc2_top,col,row,1,1); + g_signal_connect(enc2_top,"button_press_event",G_CALLBACK(enc_cb),GINT_TO_POINTER(ENC2_TOP)); + col++; + } GtkWidget *enc2_sw=gtk_button_new_with_label(sw_string[e2_sw_action]); gtk_grid_attach(GTK_GRID(grid),enc2_sw,col,row,1,1); @@ -722,7 +686,8 @@ void encoder_menu(GtkWidget *parent) { row++; col=0; - GtkWidget *enc3_title=gtk_label_new("ENC3: "); + GtkWidget *enc3_title=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(enc3_title), "ENC3: "); gtk_grid_attach(GTK_GRID(grid),enc3_title,col,row,1,1); col++; @@ -731,12 +696,12 @@ void encoder_menu(GtkWidget *parent) { g_signal_connect(enc3,"button_press_event",G_CALLBACK(enc_cb),GINT_TO_POINTER(ENC3)); col++; -#ifdef CONTROLLER2_V2 - GtkWidget *enc3_top=gtk_button_new_with_label(encoder_string[e3_top_encoder_action]); - gtk_grid_attach(GTK_GRID(grid),enc3_top,col,row,1,1); - g_signal_connect(enc3_top,"button_press_event",G_CALLBACK(enc_cb),GINT_TO_POINTER(ENC3_TOP)); - col++; -#endif + if(controller==CONTROLLER2_V2) { + GtkWidget *enc3_top=gtk_button_new_with_label(encoder_string[e3_top_encoder_action]); + gtk_grid_attach(GTK_GRID(grid),enc3_top,col,row,1,1); + g_signal_connect(enc3_top,"button_press_event",G_CALLBACK(enc_cb),GINT_TO_POINTER(ENC3_TOP)); + col++; + } GtkWidget *enc3_sw=gtk_button_new_with_label(sw_string[e3_sw_action]); gtk_grid_attach(GTK_GRID(grid),enc3_sw,col,row,1,1); @@ -745,7 +710,8 @@ void encoder_menu(GtkWidget *parent) { row++; col=0; - GtkWidget *enc4_title=gtk_label_new("ENC4: "); + GtkWidget *enc4_title=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(enc4_title), "ENC4: "); gtk_grid_attach(GTK_GRID(grid),enc4_title,col,row,1,1); col++; @@ -754,12 +720,12 @@ void encoder_menu(GtkWidget *parent) { g_signal_connect(enc4,"button_press_event",G_CALLBACK(enc_cb),GINT_TO_POINTER(ENC4)); col++; -#ifdef CONTROLLER2_V2 - GtkWidget *enc4_top=gtk_button_new_with_label(encoder_string[e4_top_encoder_action]); - gtk_grid_attach(GTK_GRID(grid),enc4_top,col,row,1,1); - g_signal_connect(enc4_top,"button_press_event",G_CALLBACK(enc_cb),GINT_TO_POINTER(ENC4_TOP)); - col++; -#endif + if(controller==CONTROLLER2_V2) { + GtkWidget *enc4_top=gtk_button_new_with_label(encoder_string[e4_top_encoder_action]); + gtk_grid_attach(GTK_GRID(grid),enc4_top,col,row,1,1); + g_signal_connect(enc4_top,"button_press_event",G_CALLBACK(enc_cb),GINT_TO_POINTER(ENC4_TOP)); + col++; + } GtkWidget *enc4_sw=gtk_button_new_with_label(sw_string[e4_sw_action]); gtk_grid_attach(GTK_GRID(grid),enc4_sw,col,row,1,1); @@ -768,27 +734,28 @@ void encoder_menu(GtkWidget *parent) { row++; col=0; -#if defined (CONTROLLER2_V2) || defined (CONTROLLER2_V1) - GtkWidget *enc5_title=gtk_label_new("ENC5: "); - gtk_grid_attach(GTK_GRID(grid),enc5_title,col,row,1,1); - col++; + if(controller==CONTROLLER2_V1 || controller==CONTROLLER2_V2) { + GtkWidget *enc5_title=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(enc5_title), "ENC5: "); + gtk_grid_attach(GTK_GRID(grid),enc5_title,col,row,1,1); + col++; - GtkWidget *enc5=gtk_button_new_with_label(encoder_string[e5_encoder_action]); - gtk_grid_attach(GTK_GRID(grid),enc5,col,row,1,1); - g_signal_connect(enc5,"button_press_event",G_CALLBACK(enc_cb),GINT_TO_POINTER(ENC5)); - col++; + GtkWidget *enc5=gtk_button_new_with_label(encoder_string[e5_encoder_action]); + gtk_grid_attach(GTK_GRID(grid),enc5,col,row,1,1); + g_signal_connect(enc5,"button_press_event",G_CALLBACK(enc_cb),GINT_TO_POINTER(ENC5)); + col++; -#if defined (CONTROLLER2_V2) - GtkWidget *enc5_top=gtk_button_new_with_label(encoder_string[e5_top_encoder_action]); - gtk_grid_attach(GTK_GRID(grid),enc5_top,col,row,1,1); - g_signal_connect(enc5_top,"button_press_event",G_CALLBACK(enc_cb),GINT_TO_POINTER(ENC5_TOP)); - col++; -#endif + if(controller==CONTROLLER2_V2) { + GtkWidget *enc5_top=gtk_button_new_with_label(encoder_string[e5_top_encoder_action]); + gtk_grid_attach(GTK_GRID(grid),enc5_top,col,row,1,1); + g_signal_connect(enc5_top,"button_press_event",G_CALLBACK(enc_cb),GINT_TO_POINTER(ENC5_TOP)); + col++; + } - GtkWidget *enc5_sw=gtk_button_new_with_label(sw_string[e5_sw_action]); - gtk_grid_attach(GTK_GRID(grid),enc5_sw,col,row,1,1); - g_signal_connect(enc5_sw,"button_press_event",G_CALLBACK(sw_cb),GINT_TO_POINTER(ENC5_SW)); -#endif + GtkWidget *enc5_sw=gtk_button_new_with_label(sw_string[e5_sw_action]); + gtk_grid_attach(GTK_GRID(grid),enc5_sw,col,row,1,1); + g_signal_connect(enc5_sw,"button_press_event",G_CALLBACK(sw_cb),GINT_TO_POINTER(ENC5_SW)); + } gtk_container_add(GTK_CONTAINER(content),grid); diff --git a/equalizer_menu.c b/equalizer_menu.c index 3880e6d..1d6faa3 100644 --- a/equalizer_menu.c +++ b/equalizer_menu.c @@ -167,19 +167,24 @@ void equalizer_menu(GtkWidget *parent) { gtk_grid_attach(GTK_GRID(grid),enable_b,0,1,1,1); - GtkWidget *label=gtk_label_new("Preamp"); + GtkWidget *label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(label), "Preamp"); gtk_grid_attach(GTK_GRID(grid),label,0,2,1,2); - label=gtk_label_new("Low"); + label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(label), "Low"); gtk_grid_attach(GTK_GRID(grid),label,0,4,1,2); - label=gtk_label_new("Mid"); + label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(label), "Mid"); gtk_grid_attach(GTK_GRID(grid),label,0,6,1,2); - label=gtk_label_new("High"); + label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(label), "High"); gtk_grid_attach(GTK_GRID(grid),label,0,8,1,2); preamp_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,-12.0,15.0,1.0); + gtk_range_set_increments (GTK_RANGE(preamp_scale),1.0,1.0); if(can_transmit) { gtk_range_set_value(GTK_RANGE(preamp_scale),(double)tx_equalizer[0]); } else { @@ -199,6 +204,7 @@ void equalizer_menu(GtkWidget *parent) { gtk_scale_add_mark(GTK_SCALE(preamp_scale),15.0,GTK_POS_LEFT,"15dB"); low_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,-12.0,15.0,1.0); + gtk_range_set_increments (GTK_RANGE(low_scale),1.0,1.0); if(can_transmit) { gtk_range_set_value(GTK_RANGE(low_scale),(double)tx_equalizer[1]); } else { @@ -218,6 +224,7 @@ void equalizer_menu(GtkWidget *parent) { gtk_scale_add_mark(GTK_SCALE(low_scale),15.0,GTK_POS_LEFT,"15dB"); mid_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,-12.0,15.0,1.0); + gtk_range_set_increments (GTK_RANGE(mid_scale),1.0,1.0); if(can_transmit) { gtk_range_set_value(GTK_RANGE(mid_scale),(double)tx_equalizer[2]); } else { @@ -237,6 +244,7 @@ void equalizer_menu(GtkWidget *parent) { gtk_scale_add_mark(GTK_SCALE(mid_scale),15.0,GTK_POS_LEFT,"15dB"); high_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,-12.0,15.0,1.0); + gtk_range_set_increments (GTK_RANGE(high_scale),1.0,1.0); if(can_transmit) { gtk_range_set_value(GTK_RANGE(high_scale),(double)tx_equalizer[3]); } else { diff --git a/exit_menu.c b/exit_menu.c index d7b5877..d74597f 100644 --- a/exit_menu.c +++ b/exit_menu.c @@ -181,7 +181,7 @@ void exit_menu(GtkWidget *parent) { int row=0; int col=0; - GtkWidget *close_b=gtk_button_new_with_label("Close"); + GtkWidget *close_b=gtk_button_new_with_label("Cancel"); g_signal_connect (close_b, "pressed", G_CALLBACK(close_cb), NULL); gtk_grid_attach(GTK_GRID(grid),close_b,col,row,1,1); diff --git a/ext.c b/ext.c index 7c8a5cb..9543b78 100644 --- a/ext.c +++ b/ext.c @@ -574,6 +574,13 @@ int ext_diversity_update(void *data) { return 0; } +#ifdef PURESIGNAL +int ext_start_ps(void *data) { + start_ps(); + return 0; +} +#endif + int ext_sat_update(void *data) { switch(sat_mode) { case SAT_NONE: diff --git a/ext.h b/ext.h index 5a365f5..6442dc5 100644 --- a/ext.h +++ b/ext.h @@ -109,3 +109,6 @@ int ext_set_rf_gain(void *data); int ext_set_duplex(void *data); int ext_update_noise(void *data); +#ifdef PURESIGNAL +int ext_start_ps(void *data); +#endif diff --git a/fft_menu.c b/fft_menu.c index 76c2d3c..9f9c082 100644 --- a/fft_menu.c +++ b/fft_menu.c @@ -97,7 +97,8 @@ void fft_menu(GtkWidget *parent) { int row=1; int col=0; - GtkWidget *filter_type_label=gtk_label_new("Filter Type: "); + GtkWidget *filter_type_label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(filter_type_label), "Filter Type"); gtk_grid_attach(GTK_GRID(grid),filter_type_label,col,row,1,1); row++; diff --git a/filter.c b/filter.c index 28043af..af0160a 100644 --- a/filter.c +++ b/filter.c @@ -207,24 +207,6 @@ FILTER filterDRM[FILTERS]={ {-3300,3300,"Var2"} }; -#ifdef PSK -FILTER filterPSK[FILTERS]={ - {150,5150,"5.0k"}, - {150,4550,"4.4k"}, - {150,3950,"3.8k"}, - {150,3150,"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"} - }; -#endif - - FILTER *filters[]={ filterLSB ,filterUSB @@ -238,12 +220,10 @@ FILTER *filters[]={ ,filterDIGL ,filterSAM ,filterDRM -#ifdef PSK - ,filterPSK -#endif - }; +gint filter_step=5; + void filterSaveState() { char value[128]; @@ -443,18 +423,57 @@ void filter_width_changed(int rx,int increment) { fprintf(stderr,"filter_width_changed: rx=%d mode=%d filter=%d increment=%d\n",rx,vfo[id].mode,vfo[id].filter,increment); if(vfo[id].filter==filterVar1 || vfo[id].filter==filterVar2) { - filter->high=filter->high+increment; -fprintf(stderr,"filter->low=%d filter->high=%d\n",filter->low,filter->high); - if(vfo[id].mode==modeCWL || vfo[id].mode==modeCWU) { - filter->low=filter->high; + + switch(vfo[id].mode) { + case modeCWL: + case modeLSB: + case modeDIGL: + filter->low=filter->low-(increment*filter_step); + break; + case modeCWU: + case modeUSB: + case modeDIGU: + filter->high=filter->high+(increment*filter_step); + break; + default: + filter->low=filter->low-(increment*filter_step); + filter->high=filter->high+(increment*filter_step); + break; } vfo_filter_changed(vfo[id].filter); - int width=filter->high-filter->low; - if(vfo[id].mode==modeCWL || vfo[id].mode==modeCWU) { - width=filter->high; - } else { - if(width<0) width=filter->low-filter->high; + set_filter_width(id,filter->high-filter->low); + } +} + +void filter_shift_changed(int rx,int increment) { + int id=receiver[rx]->id; + FILTER *mode_filters=filters[vfo[id].mode]; + FILTER *filter=&mode_filters[vfo[id].filter]; + +fprintf(stderr,"filter_shift_changed: rx=%d mode=%d filter=%d increment=%d\n",rx,vfo[id].mode,vfo[id].filter,increment); + + if(vfo[id].filter==filterVar1 || vfo[id].filter==filterVar2) { + switch(vfo[id].mode) { + case modeCWL: + case modeLSB: + case modeDIGL: + filter->low=filter->low+(increment*filter_step); + filter->high=filter->high+(increment*filter_step); + set_filter_shift(id,filter->high); + break; + case modeCWU: + case modeUSB: + case modeDIGU: + filter->low=filter->low+(increment*filter_step); + filter->high=filter->high+(increment*filter_step); + set_filter_shift(id,filter->low); + break; + + default: + // not for AM, FM, DSB + break; } - set_filter_width(id,width); + vfo_filter_changed(vfo[id].filter); } + } diff --git a/filter.h b/filter.h index 1e1b463..97c2f8b 100644 --- a/filter.h +++ b/filter.h @@ -47,17 +47,20 @@ typedef struct _FILTER FILTER; #define filterVar1 10 #define filterVar2 11 -int filter; +extern int filter; -int filterLow; -int filterHigh; +extern int filterLow; +extern int filterHigh; -int txFilterLowCut; -int txFilterHighCut; +extern int txFilterLowCut; +extern int txFilterHighCut; -FILTER *filters[MODES]; +extern FILTER *filters[MODES]; -void filterSaveState(); -void filterRestoreState(); -void filter_width_changed(int rx,int increment); +extern gint filter_step; + +extern void filterSaveState(); +extern void filterRestoreState(); +extern void filter_width_changed(int rx,int increment); +extern void filter_shift_changed(int rx,int increment); #endif diff --git a/gpio.c b/gpio.c index d1b0a12..afca5df 100644 --- a/gpio.c +++ b/gpio.c @@ -45,16 +45,11 @@ #include "property.h" #include "vfo.h" #include "wdsp.h" -#ifdef PSK -#include "psk.h" -#endif #include "new_menu.h" #include "encoder_menu.h" #include "diversity_menu.h" #include "gpio.h" -#if defined (CONTROLLER2_V2) || defined(CONTROLLER2_V1) #include "i2c.h" -#endif #include "ext.h" #include "sliders.h" #include "new_protocol.h" @@ -68,124 +63,73 @@ int settle_time=DEFAULT_SETTLE_TIME; static gint release_timer=-1; -#if defined (CONTROLLER2_V1) -// uses wiringpi pin numbers -int ENABLE_VFO_ENCODER=1; -int ENABLE_VFO_PULLUP=1; -int VFO_ENCODER_A=1; -int VFO_ENCODER_B=0; -int ENABLE_E2_ENCODER=1; -int ENABLE_E2_PULLUP=1; -int E2_ENCODER_A=28; -int E2_ENCODER_B=25; -int E2_FUNCTION=3; -int ENABLE_E3_ENCODER=1; -int ENABLE_E3_PULLUP=1; -int E3_ENCODER_A=7; -int E3_ENCODER_B=29; -int E3_FUNCTION=2; -int ENABLE_E4_ENCODER=1; -int ENABLE_E4_PULLUP=1; -int E4_ENCODER_A=27; -int E4_ENCODER_B=24; -int E4_FUNCTION=4; -int ENABLE_E5_ENCODER=1; -int ENABLE_E5_PULLUP=1; -int E5_ENCODER_A=6; -int E5_ENCODER_B=10; -int E5_FUNCTION=5; - -int ENABLE_E2_BUTTON=1; -int ENABLE_E3_BUTTON=1; -int ENABLE_E4_BUTTON=1; -int ENABLE_E5_BUTTON=1; +int controller; int I2C_INTERRUPT=16; -#endif -#if defined (CONTROLLER2_V2) -// uses wiringpi pin numbers -int ENABLE_VFO_ENCODER=1; -int ENABLE_VFO_PULLUP=0; -int VFO_ENCODER_A=1; -int VFO_ENCODER_B=0; -int ENABLE_E2_ENCODER=1; -int ENABLE_E2_PULLUP=1; -int E2_ENCODER_A=21; -int E2_ENCODER_B=22; -int E2_TOP_ENCODER_A=25; -int E2_TOP_ENCODER_B=28; -int E2_FUNCTION=3; -int ENABLE_E3_ENCODER=1; -int ENABLE_E3_PULLUP=1; -int E3_ENCODER_A=13; -int E3_ENCODER_B=11; -int E3_TOP_ENCODER_A=29; -int E3_TOP_ENCODER_B=7; -int E3_FUNCTION=2; -int ENABLE_E4_ENCODER=1; -int ENABLE_E4_PULLUP=1; -int E4_ENCODER_A=14; -int E4_ENCODER_B=12; -int E4_TOP_ENCODER_A=24; -int E4_TOP_ENCODER_B=27; -int E4_FUNCTION=4; -int ENABLE_E5_ENCODER=1; -int ENABLE_E5_PULLUP=1; -int E5_ENCODER_A=23; -int E5_ENCODER_B=26; -int E5_TOP_ENCODER_A=10; -int E5_TOP_ENCODER_B=6; -int E5_FUNCTION=5; - -int ENABLE_E2_BUTTON=1; -int ENABLE_E3_BUTTON=1; -int ENABLE_E4_BUTTON=1; -int ENABLE_E5_BUTTON=1; -int I2C_INTERRUPT=16; -#endif - -#if !defined (CONTROLLER2_V2) && !defined (CONTROLLER2_V1) // uses wiringpi pin numbers -int ENABLE_VFO_ENCODER=1; -int ENABLE_VFO_PULLUP=1; -int VFO_ENCODER_A=1; -int VFO_ENCODER_B=0; -int ENABLE_E2_ENCODER=1; -int ENABLE_E2_PULLUP=0; -int E2_ENCODER_A=28; -int E2_ENCODER_B=25; -int E2_FUNCTION=6; -int ENABLE_E3_ENCODER=1; -int ENABLE_E3_PULLUP=0; -int E3_ENCODER_A=27; -int E3_ENCODER_B=24; -int E3_FUNCTION=10; -int ENABLE_E4_ENCODER=1; -int ENABLE_E4_PULLUP=0; -int E4_ENCODER_A=7; -int E4_ENCODER_B=29; -int E4_FUNCTION=11; -int ENABLE_S1_BUTTON=1; -int S1_BUTTON=23; -int ENABLE_S2_BUTTON=1; -int S2_BUTTON=26; -int ENABLE_S3_BUTTON=1; -int S3_BUTTON=22; -int ENABLE_S4_BUTTON=1; -int S4_BUTTON=21; -int ENABLE_S5_BUTTON=1; -int S5_BUTTON=5; -int ENABLE_S6_BUTTON=1; -int S6_BUTTON=4; -int ENABLE_MOX_BUTTON=1; -int MOX_BUTTON=2; -int ENABLE_FUNCTION_BUTTON=1; -int FUNCTION_BUTTON=3; -int ENABLE_E2_BUTTON=1; -int ENABLE_E3_BUTTON=1; -int ENABLE_E4_BUTTON=1; -#endif +int ENABLE_VFO_ENCODER; +int ENABLE_VFO_PULLUP; +int VFO_ENCODER_A; +int VFO_ENCODER_B; +int ENABLE_E2_ENCODER; +int ENABLE_E2_PULLUP; +int E2_ENCODER_A; +int E2_ENCODER_B; +int ENABLE_E2_TOP_ENCODER; +int E2_TOP_ENCODER_A; +int E2_TOP_ENCODER_B; +int E2_FUNCTION; +int ENABLE_E3_ENCODER; +int ENABLE_E3_PULLUP; +int E3_ENCODER_A; +int E3_ENCODER_B; +int ENABLE_E3_TOP_ENCODER; +int E3_TOP_ENCODER_A; +int E3_TOP_ENCODER_B; +int E3_FUNCTION; +int ENABLE_E4_ENCODER; +int ENABLE_E4_PULLUP; +int E4_ENCODER_A; +int E4_ENCODER_B; +int ENABLE_E4_TOP_ENCODER; +int E4_TOP_ENCODER_A; +int E4_TOP_ENCODER_B; +int E4_FUNCTION; +int ENABLE_E5_ENCODER; +int ENABLE_E5_PULLUP; +int E5_ENCODER_A; +int E5_ENCODER_B; +int ENABLE_E5_TOP_ENCODER; +int E5_TOP_ENCODER_A; +int E5_TOP_ENCODER_B; +int E5_FUNCTION; + +int ENABLE_E2_BUTTON; +int ENABLE_E3_BUTTON; +int ENABLE_E4_BUTTON; +int ENABLE_E5_BUTTON; + +int ENABLE_S1_BUTTON; +int S1_BUTTON; +int ENABLE_S2_BUTTON; +int S2_BUTTON; +int ENABLE_S3_BUTTON; +int S3_BUTTON; +int ENABLE_S4_BUTTON; +int S4_BUTTON; +int ENABLE_S5_BUTTON; +int S5_BUTTON; +int ENABLE_S6_BUTTON; +int S6_BUTTON; +int ENABLE_MOX_BUTTON; +int MOX_BUTTON; +int ENABLE_FUNCTION_BUTTON; +int FUNCTION_BUTTON; +int ENABLE_E2_BUTTON; +int ENABLE_E3_BUTTON; +int ENABLE_E4_BUTTON; + #ifdef LOCALCW int CWL_BUTTON=14; @@ -199,58 +143,27 @@ int CW_ACTIVE_LOW=1; int vfoEncoderPos; int vfoFunction; -#if defined (CONTROLLER2_V1) -int e2EncoderPos; -int e2_sw_action=MENU_BAND; -int e2_encoder_action=ENCODER_AF_GAIN_RX1; -int e3EncoderPos; -int e3_sw_action=MENU_MODE; -int e3_encoder_action=ENCODER_AGC_GAIN_RX1; -int e4EncoderPos; -int e4_sw_action=MENU_FILTER; -int e4_encoder_action=ENCODER_IF_WIDTH_RX1; -int e5EncoderPos; -int e5_sw_action=MENU_FREQUENCY; -int e5_encoder_action=ENCODER_DRIVE; -#endif - -#if defined (CONTROLLER2_V2) int e2EncoderPos; -int e2_sw_action=MENU_BAND; -int e2_encoder_action=ENCODER_AF_GAIN_RX2; +int e2_sw_action; +int e2_encoder_action; int e3EncoderPos; -int e3_sw_action=MENU_MODE; -int e3_encoder_action=ENCODER_AGC_GAIN_RX2; +int e3_sw_action; +int e3_encoder_action; int e4EncoderPos; -int e4_sw_action=MENU_FILTER; -int e4_encoder_action=ENCODER_IF_WIDTH_RX2; +int e4_sw_action; +int e4_encoder_action; int e5EncoderPos; -int e5_sw_action=MENU_FREQUENCY; -int e5_encoder_action=ENCODER_DRIVE; -#endif +int e5_sw_action; +int e5_encoder_action; -#if defined (CONTROLLER2_V2) -int e2_top_encoder_action=ENCODER_AF_GAIN_RX1; -int e3_top_encoder_action=ENCODER_AGC_GAIN_RX1; -int e4_top_encoder_action=ENCODER_IF_WIDTH_RX1; -int e5_top_encoder_action=ENCODER_TUNE_DRIVE; int e2TopEncoderPos; +int e2_top_encoder_action; int e3TopEncoderPos; +int e3_top_encoder_action; int e4TopEncoderPos; +int e4_top_encoder_action; int e5TopEncoderPos; -#endif - -#if !defined (CONTROLLER2_V2) && !defined (CONTROLLER2_V1) -int e2EncoderPos; -int e2_sw_action=RIT; -int e2_encoder_action=ENCODER_AF_GAIN_RX1; -int e3EncoderPos; -int e3_sw_action=AGC; -int e3_encoder_action=ENCODER_AGC_GAIN_RX1; -int e4EncoderPos; -int e4_sw_action=BAND_PLUS; -int e4_encoder_action=ENCODER_DRIVE; -#endif +int e5_top_encoder_action; static volatile int function_state; static volatile int band_state; @@ -284,6 +197,12 @@ static int previous_mox_button=0; static int running=0; char *encoder_string[ENCODER_ACTIONS] = { + "NO ACTION", + "AF GAIN", + "RF GAIN", + "AGC GAIN", + "IF WIDTH", + "IF SHIFT", "AF GAIN RX1", "RF GAIN RX1", "AF GAIN RX2", @@ -292,10 +211,13 @@ char *encoder_string[ENCODER_ACTIONS] = { "AGC GAIN RX2", "IF WIDTH RX1", "IF WIDTH RX2", - "ATTENUATION", + "IF SHIFT RX1", + "IF SHIFT RX2", + "ATTENUATION/RX GAIN", "MIC GAIN", "DRIVE", "TUNE DRIVE", + "RIT", "RIT RX1", "RIT RX2", "XIT", @@ -303,13 +225,18 @@ char *encoder_string[ENCODER_ACTIONS] = { "CW FREQUENCY", "PANADAPTER HIGH", "PANADAPTER LOW", + "PANADAPTER STEP", + "WATERFALL HIGH", + "WATERFALL LOW", "SQUELCH", + "SQUELCH RX1", + "SQUELCH RX2", "COMP", "DIVERSITY GAIN", "DIVERSITY PHASE"}; char *sw_string[SWITCH_ACTIONS] = { - "NO ACTION", + "", "TUNE", "MOX", "PS", @@ -318,17 +245,17 @@ char *sw_string[SWITCH_ACTIONS] = { "NB", "SNB", "RIT", - "RIT Clear", + "RIT CL", "XIT", - "XIT Clear", - "BAND PLUS", - "BAND MINUS", - "BANDSTACK PLUS", - "BANDSTACK MINUS", - "MODE PLUS", - "MODE MINUS", - "FILTER PLUS", - "FILTER MINUS", + "XIT CL", + "BAND +", + "BAND -", + "BSTACK +", + "BSTACK -", + "MODE +", + "MODE -", + "FILTER +", + "FILTER -", "A TO B", "B TO A", "A SWAP B", @@ -336,23 +263,20 @@ char *sw_string[SWITCH_ACTIONS] = { "CTUN", "AGC", "SPLIT", - "DIVERSITY", + "DIV", "SAT", - "BAND MENU", - "BANDSTACK MENU", - "MODE MENU", - "FILTER MENU", - "FREQUENCY MENU", - "MEMORY MENU", - "DIVERSITY MENU", -#if !defined (CONTROLLER2_V2) && !defined (CONTROLLER2_V1) + "BAND", + "BSTACK", + "MODE", + "FILTER", + "FREQUENCY", + "MEMORY", + "DIV MENU", + "PS MENU", "FUNCTION", -#endif }; -#if defined (CONTROLLER2_V2) || defined (CONTROLLER2_V1) -int sw_action[SWITCHES] = {TUNE,MOX,PS,TWO_TONE,NR,A_TO_B,B_TO_A,MODE_MINUS,BAND_MINUS,MODE_PLUS,BAND_PLUS,XIT,NB,SNB,LOCK,CTUN}; -#endif +int *sw_action=NULL; static int mox_pressed(void *data) { if(running) sim_mox_cb(NULL,NULL); @@ -555,11 +479,14 @@ static int e_function_pressed(void *data) { case MENU_DIVERSITY: g_idle_add(ext_diversity_update,GINT_TO_POINTER(1)); break; -#if !defined (CONTROLLER2_V1) && !defined (CONTROLLER2_V2) +#ifdef PURESIGNAL + case MENU_PS: + g_idle_add(ext_start_ps,NULL); + break; +#endif case FUNCTION: g_idle_add(ext_function_update,NULL); break; -#endif } return 0; } @@ -591,7 +518,6 @@ static void e4FunctionAlert() { } } -#if defined (CONTROLLER2_V2) || defined (CONTROLLER2_V1) static unsigned long e5debounce=0; static void e5FunctionAlert() { @@ -600,9 +526,7 @@ static void e5FunctionAlert() { if(running) g_idle_add(e_function_pressed,(gpointer)e5_sw_action); } } -#endif -#if !defined (CONTROLLER2_V2) && !defined (CONTROLLER2_V1) static int function_level=1; static unsigned long function_debounce=0; @@ -758,7 +682,7 @@ static void moxAlert() { mox_debounce=t+settle_time; } } -#endif + #ifdef VFO_HAS_FUNCTION @@ -801,7 +725,6 @@ static void e2EncoderInt() { } } -#if defined (CONTROLLER2_V2) static void e2TopEncoderInt() { static int e2TopCurrentA=1; int levelA=digitalRead(E2_TOP_ENCODER_A); @@ -813,7 +736,6 @@ static void e2TopEncoderInt() { e2TopCurrentA=levelA; } } -#endif static void e3EncoderInt() { static int e3CurrentA=1; @@ -827,7 +749,6 @@ static void e3EncoderInt() { } } -#if defined (CONTROLLER2_V2) static void e3TopEncoderInt() { static int e3TopCurrentA=1; int levelA=digitalRead(E3_TOP_ENCODER_A); @@ -840,7 +761,6 @@ static void e3TopEncoderInt() { e3TopCurrentA=levelA; } } -#endif static void e4EncoderInt() { static int e4CurrentA=1; @@ -854,7 +774,6 @@ static void e4EncoderInt() { } } -#if defined (CONTROLLER2_V2) static void e4TopEncoderInt() { static int e4TopCurrentA=1; int levelA=digitalRead(E4_TOP_ENCODER_A); @@ -866,10 +785,7 @@ static void e4TopEncoderInt() { e4TopCurrentA=levelA; } } -#endif - -#if defined (CONTROLLER2_V2) || defined (CONTROLLER2_V1) static void e5EncoderInt() { static int e5CurrentA=1; int levelA=digitalRead(E5_ENCODER_A); @@ -882,9 +798,7 @@ static void e5EncoderInt() { e5CurrentA=levelA; } } -#endif -#if defined (CONTROLLER2_V2) static void e5TopEncoderInt() { static int e5TopCurrentA=1; int levelA=digitalRead(E5_TOP_ENCODER_A); @@ -896,27 +810,273 @@ static void e5TopEncoderInt() { e5TopCurrentA=levelA; } } -#endif -#if defined (CONTROLLER2_V2) || defined (CONTROLLER2_V1) static void pI2CInterrupt() { int level=digitalRead(I2C_INTERRUPT); if(level==0) { i2c_interrupt(); } } -#endif + +void gpio_set_defaults(int ctrlr) { +g_print("gpio_set_defaults: %d\n",ctrlr); + if(sw_action!=NULL) { + g_free(sw_action); + sw_action=NULL; + } + switch(ctrlr) { + case NO_CONTROLLER: + ENABLE_VFO_ENCODER=0; + ENABLE_E2_ENCODER=0; + ENABLE_E3_ENCODER=0; + ENABLE_E4_ENCODER=0; + ENABLE_S1_BUTTON=0; + ENABLE_S2_BUTTON=0; + ENABLE_S3_BUTTON=0; + ENABLE_S4_BUTTON=0; + ENABLE_S5_BUTTON=0; + ENABLE_S6_BUTTON=0; + ENABLE_MOX_BUTTON=0; + ENABLE_FUNCTION_BUTTON=0; + ENABLE_E2_BUTTON=0; + ENABLE_E3_BUTTON=0; + ENABLE_E4_BUTTON=0; + ENABLE_E5_BUTTON=0; + ENABLE_E5_ENCODER=0; + ENABLE_E2_TOP_ENCODER=0; + ENABLE_E3_TOP_ENCODER=0; + ENABLE_E4_TOP_ENCODER=0; + ENABLE_E5_TOP_ENCODER=0; + break; + case CONTROLLER1: + sw_action=g_new(int,CONTROLLER1_SWITCHES); + ENABLE_VFO_ENCODER=1; + ENABLE_VFO_PULLUP=1; + VFO_ENCODER_A=1; + VFO_ENCODER_B=0; + ENABLE_E2_ENCODER=1; + ENABLE_E2_PULLUP=0; + E2_ENCODER_A=28; + E2_ENCODER_B=25; + E2_FUNCTION=6; + ENABLE_E3_ENCODER=1; + ENABLE_E3_PULLUP=0; + E3_ENCODER_A=27; + E3_ENCODER_B=24; + E3_FUNCTION=10; + ENABLE_E4_ENCODER=1; + ENABLE_E4_PULLUP=0; + E4_ENCODER_A=7; + E4_ENCODER_B=29; + E4_FUNCTION=11; + ENABLE_S1_BUTTON=1; + S1_BUTTON=23; + ENABLE_S2_BUTTON=1; + S2_BUTTON=26; + ENABLE_S3_BUTTON=1; + S3_BUTTON=22; + ENABLE_S4_BUTTON=1; + S4_BUTTON=21; + ENABLE_S5_BUTTON=1; + S5_BUTTON=5; + ENABLE_S6_BUTTON=1; + S6_BUTTON=4; + ENABLE_MOX_BUTTON=1; + MOX_BUTTON=2; + ENABLE_FUNCTION_BUTTON=1; + FUNCTION_BUTTON=3; + ENABLE_E2_BUTTON=1; + ENABLE_E3_BUTTON=1; + ENABLE_E4_BUTTON=1; + ENABLE_E5_BUTTON=0; + ENABLE_E5_ENCODER=0; + ENABLE_E2_TOP_ENCODER=0; + ENABLE_E3_TOP_ENCODER=0; + ENABLE_E4_TOP_ENCODER=0; + ENABLE_E5_TOP_ENCODER=0; + e2_sw_action=MENU_BAND; + e2_encoder_action=ENCODER_AF_GAIN; + e3_sw_action=MENU_BANDSTACK; + e3_encoder_action=ENCODER_AGC_GAIN; + e4_sw_action=MENU_MODE; + e4_encoder_action=ENCODER_DRIVE; + e2_top_encoder_action=ENCODER_NO_ACTION; + e3_top_encoder_action=ENCODER_NO_ACTION; + e4_top_encoder_action=ENCODER_NO_ACTION; + e5_encoder_action=ENCODER_NO_ACTION; + e5_top_encoder_action=ENCODER_NO_ACTION; + break; + case CONTROLLER2_V1: + // uses wiringpi pin numbers + ENABLE_VFO_ENCODER=1; + ENABLE_VFO_PULLUP=1; + VFO_ENCODER_A=1; + VFO_ENCODER_B=0; + ENABLE_E2_ENCODER=1; + ENABLE_E2_PULLUP=1; + E2_ENCODER_A=28; + E2_ENCODER_B=25; + E2_FUNCTION=3; + ENABLE_E3_ENCODER=1; + ENABLE_E3_PULLUP=1; + E3_ENCODER_A=7; + E3_ENCODER_B=29; + E3_FUNCTION=2; + ENABLE_E4_ENCODER=1; + ENABLE_E4_PULLUP=1; + E4_ENCODER_A=27; + E4_ENCODER_B=24; + E4_FUNCTION=4; + ENABLE_E5_ENCODER=1; + ENABLE_E5_PULLUP=1; + E5_ENCODER_A=6; + E5_ENCODER_B=10; + E5_FUNCTION=5; + ENABLE_E2_BUTTON=1; + ENABLE_E3_BUTTON=1; + ENABLE_E4_BUTTON=1; + ENABLE_E5_BUTTON=1; + ENABLE_S1_BUTTON=0; + ENABLE_S2_BUTTON=0; + ENABLE_S3_BUTTON=0; + ENABLE_S4_BUTTON=0; + ENABLE_S5_BUTTON=0; + ENABLE_S6_BUTTON=0; + ENABLE_E2_TOP_ENCODER=0; + ENABLE_E3_TOP_ENCODER=0; + ENABLE_E4_TOP_ENCODER=0; + ENABLE_E5_TOP_ENCODER=0; + sw_action=g_new(int,CONTROLLER2_SWITCHES); + sw_action[0]=MOX; + sw_action[1]=TUNE; + sw_action[2]=PS; + sw_action[3]=TWO_TONE; + sw_action[4]=NR; + sw_action[5]=A_TO_B; + sw_action[6]=B_TO_A; + sw_action[7]=MODE_MINUS; + sw_action[8]=BAND_MINUS; + sw_action[9]=MODE_PLUS; + sw_action[10]=BAND_PLUS; + sw_action[11]=XIT; + sw_action[12]=NB; + sw_action[13]=SNB; + sw_action[14]=LOCK; + sw_action[15]=CTUN; + e2_sw_action=MENU_BAND; + e2_encoder_action=ENCODER_AF_GAIN; + e3_sw_action=MENU_BANDSTACK; + e3_encoder_action=ENCODER_AGC_GAIN; + e4_sw_action=MENU_MODE; + e4_encoder_action=ENCODER_IF_WIDTH; + e5_sw_action=MENU_FREQUENCY; + e5_encoder_action=ENCODER_RIT; + e2_top_encoder_action=ENCODER_NO_ACTION; + e3_top_encoder_action=ENCODER_NO_ACTION; + e4_top_encoder_action=ENCODER_NO_ACTION; + e5_top_encoder_action=ENCODER_NO_ACTION; + break; + case CONTROLLER2_V2: + // uses wiringpi pin numbers + ENABLE_VFO_ENCODER=1; + ENABLE_VFO_PULLUP=0; + VFO_ENCODER_A=1; + VFO_ENCODER_B=0; + ENABLE_E2_ENCODER=1; + ENABLE_E2_PULLUP=1; + E2_ENCODER_A=21; + E2_ENCODER_B=22; + ENABLE_E2_TOP_ENCODER=1; + E2_TOP_ENCODER_A=25; + E2_TOP_ENCODER_B=28; + E2_FUNCTION=3; + ENABLE_E3_ENCODER=1; + ENABLE_E3_PULLUP=1; + E3_ENCODER_A=13; + E3_ENCODER_B=11; + ENABLE_E3_TOP_ENCODER=1; + E3_TOP_ENCODER_A=29; + E3_TOP_ENCODER_B=7; + E3_FUNCTION=2; + ENABLE_E4_ENCODER=1; + ENABLE_E4_PULLUP=1; + E4_ENCODER_A=14; + E4_ENCODER_B=12; + ENABLE_E4_TOP_ENCODER=1; + E4_TOP_ENCODER_A=24; + E4_TOP_ENCODER_B=27; + E4_FUNCTION=4; + ENABLE_E5_ENCODER=1; + ENABLE_E5_PULLUP=1; + E5_ENCODER_A=23; + E5_ENCODER_B=26; + ENABLE_E5_TOP_ENCODER=1; + E5_TOP_ENCODER_A=10; + E5_TOP_ENCODER_B=6; + E5_FUNCTION=5; + ENABLE_E2_BUTTON=1; + ENABLE_E3_BUTTON=1; + ENABLE_E4_BUTTON=1; + ENABLE_E5_BUTTON=1; + ENABLE_S1_BUTTON=0; + ENABLE_S2_BUTTON=0; + ENABLE_S3_BUTTON=0; + ENABLE_S4_BUTTON=0; + ENABLE_S5_BUTTON=0; + ENABLE_S6_BUTTON=0; + sw_action=g_new(int,CONTROLLER2_SWITCHES); + sw_action[0]=MOX; + sw_action[1]=TUNE; + sw_action[2]=PS; + sw_action[3]=TWO_TONE; + sw_action[4]=NR; + sw_action[5]=A_TO_B; + sw_action[6]=B_TO_A; + sw_action[7]=MODE_MINUS; + sw_action[8]=BAND_MINUS; + sw_action[9]=MODE_PLUS; + sw_action[10]=BAND_PLUS; + sw_action[11]=XIT; + sw_action[12]=NB; + sw_action[13]=SNB; + sw_action[14]=LOCK; + sw_action[15]=CTUN; + e2_sw_action=MENU_BAND; + e2_top_encoder_action=ENCODER_AF_GAIN; + e2_encoder_action=ENCODER_RF_GAIN; + e3_sw_action=MENU_MODE; + e3_top_encoder_action=ENCODER_AGC_GAIN; + e3_encoder_action=ENCODER_ATTENUATION; + e4_sw_action=MENU_FILTER; + e4_top_encoder_action=ENCODER_IF_SHIFT; + e4_encoder_action=ENCODER_IF_WIDTH; + e5_sw_action=MENU_FREQUENCY; + e5_top_encoder_action=ENCODER_RIT; + e5_encoder_action=ENCODER_XIT; + break; + default: + break; + } +g_print("controller=%d e2_encoder_action: %d\n",ctrlr,e2_encoder_action); +} void gpio_restore_actions() { char* value; -#if defined (CONTROLLER2_V2) || defined (CONTROLLER2_V1) char name[80]; int i; -#endif +g_print("gpio_restore_actions: controller=%d\n",controller); + if(sw_action!=NULL) { + g_free(sw_action); + sw_action=NULL; + } + + gpio_set_defaults(controller); + value=getProperty("settle_time"); if(value) settle_time=atoi(value); + value=getProperty("e2_encoder_action"); if(value) e2_encoder_action=atoi(value); value=getProperty("e2_sw_action"); @@ -929,38 +1089,48 @@ void gpio_restore_actions() { if(value) e4_encoder_action=atoi(value); value=getProperty("e4_sw_action"); if(value) e4_sw_action=atoi(value); - -#if defined (CONTROLLER2_V2) value=getProperty("e2_top_encoder_action"); if(value) e2_top_encoder_action=atoi(value); value=getProperty("e3_top_encoder_action"); if(value) e3_top_encoder_action=atoi(value); value=getProperty("e4_top_encoder_action"); if(value) e4_top_encoder_action=atoi(value); -#endif - -#if defined (CONTROLLER2_V2) || defined (CONTROLLER2_V1) value=getProperty("e5_encoder_action"); if(value) e5_encoder_action=atoi(value); -#if defined (CONTROLLER2_V2) value=getProperty("e5_top_encoder_action"); if(value) e5_top_encoder_action=atoi(value); -#endif value=getProperty("e5_sw_action"); if(value) e5_sw_action=atoi(value); - for(i=0;iid].mode]; + FILTER *band_filter; + FILTER *filter; + int new_val; switch(action) { + case ENCODER_AF_GAIN: + value=active_receiver->volume; + value+=(double)pos/100.0; + if(value<0.0) { + value=0.0; + } else if(value>1.0) { + value=1.0; + } + set_af_gain(active_receiver->id,value); + break; case ENCODER_AF_GAIN_RX1: value=receiver[0]->volume; value+=(double)pos/100.0; @@ -1610,6 +1802,16 @@ static void encoder_changed(int action,int pos) { } set_af_gain(1,value); break; + case ENCODER_RF_GAIN: + value=active_receiver->rf_gain; + value+=(double)pos; + if(value<0.0) { + value=0.0; + } else if(value>100.0) { + value=100.0; + } + set_rf_gain(active_receiver->id,value); + break; case ENCODER_RF_GAIN_RX1: value=receiver[0]->rf_gain; value+=(double)pos; @@ -1630,6 +1832,16 @@ static void encoder_changed(int action,int pos) { } set_rf_gain(1,value); break; + case ENCODER_AGC_GAIN: + value=active_receiver->agc_gain; + value+=(double)pos; + if(value<-20.0) { + value=-20.0; + } else if(value>120.0) { + value=120.0; + } + set_agc_gain(active_receiver->id,value); + break; case ENCODER_AGC_GAIN_RX1: value=receiver[0]->agc_gain; value+=(double)pos; @@ -1650,26 +1862,40 @@ static void encoder_changed(int action,int pos) { } set_agc_gain(1,value); break; + case ENCODER_IF_WIDTH: + filter_width_changed(active_receiver->id,pos); + break; case ENCODER_IF_WIDTH_RX1: filter_width_changed(0,pos); break; case ENCODER_IF_WIDTH_RX2: filter_width_changed(1,pos); break; + case ENCODER_IF_SHIFT: + filter_shift_changed(active_receiver->id,pos); + break; + case ENCODER_IF_SHIFT_RX1: + filter_shift_changed(0,pos); + break; + case ENCODER_IF_SHIFT_RX2: + filter_shift_changed(1,pos); + break; case ENCODER_ATTENUATION: value=(double)adc_attenuation[active_receiver->adc]; value+=(double)pos; - if(value<0.0) { - value=0.0; -#ifdef RADIOBERRY - } else if (value>60.0) { - value=60.0; + if(have_rx_gain) { + if(value<-12.0) { + value=-12.0; + } else if(value>48.0) { + value=48.0; + } + } else { + if(value<0.0) { + value=0.0; + } else if (value>31.0) { + value=31.0; + } } -#else - } else if (value>31.0) { - value=31.0; - } -#endif set_attenuation_value(value); break; case ENCODER_MIC_GAIN: @@ -1692,6 +1918,18 @@ static void encoder_changed(int action,int pos) { } set_drive(value); break; + case ENCODER_RIT: + value=(double)vfo[active_receiver->id].rit; + value+=(double)(pos*rit_increment); + if(value<-10000.0) { + value=-10000.0; + } else if(value>10000.0) { + value=10000.0; + } + vfo[active_receiver->id].rit=(int)value; + receiver_frequency_changed(active_receiver); + g_idle_add(ext_vfo_update,NULL); + break; case ENCODER_RIT_RX1: value=(double)vfo[receiver[0]->id].rit; value+=(double)(pos*rit_increment); @@ -1762,6 +2000,21 @@ static void encoder_changed(int action,int pos) { value+=(double)pos; active_receiver->panadapter_low=(int)value; break; + case ENCODER_PANADAPTER_STEP: + value=(double)active_receiver->panadapter_step; + value+=(double)pos; + active_receiver->panadapter_step=(int)value; + break; + case ENCODER_WATERFALL_HIGH: + value=(double)active_receiver->waterfall_high; + value+=(double)pos; + active_receiver->waterfall_high=(int)value; + break; + case ENCODER_WATERFALL_LOW: + value=(double)active_receiver->waterfall_low; + value+=(double)pos; + active_receiver->waterfall_low=(int)value; + break; case ENCODER_SQUELCH: value=active_receiver->squelch; value+=(double)pos; @@ -1771,7 +2024,29 @@ static void encoder_changed(int action,int pos) { value=100.0; } active_receiver->squelch=value; - set_squelch(); + set_squelch(active_receiver); + break; + case ENCODER_SQUELCH_RX1: + value=receiver[0]->squelch; + value+=(double)pos; + if(value<0.0) { + value=0.0; + } else if(value>100.0) { + value=100.0; + } + receiver[0]->squelch=value; + set_squelch(receiver[0]); + break; + case ENCODER_SQUELCH_RX2: + value=receiver[1]->squelch; + value+=(double)pos; + if(value<0.0) { + value=0.0; + } else if(value>100.0) { + value=100.0; + } + receiver[1]->squelch=value; + set_squelch(receiver[1]); break; case ENCODER_COMP: value=(double)transmitter->compressor_level; @@ -1823,7 +2098,6 @@ static int e4_encoder_changed(void *data) { return 0; } -#if defined (CONTROLLER2_V2) || defined (CONTROLLER2_V1) static int e5_encoder_changed(void *data) { int pos=(int)data; if(active_menu==E5_MENU) { @@ -1833,10 +2107,8 @@ static int e5_encoder_changed(void *data) { } return 0; } -#endif -#ifdef CONTROLLER2_V2 static int e2_top_encoder_changed(void *data) { int pos=(int)data; if(active_menu==E2_MENU) { @@ -1876,7 +2148,6 @@ static int e5_top_encoder_changed(void *data) { } return 0; } -#endif static gpointer rotary_encoder_thread(gpointer data) { int pos; @@ -1906,34 +2177,35 @@ static gpointer rotary_encoder_thread(gpointer data) { g_idle_add(e4_encoder_changed,(gpointer)pos); } -#if defined (CONTROLLER2_V2) || defined (CONTROLLER2_V1) - pos=e5_encoder_get_pos(); - if(pos!=0) { - g_idle_add(e5_encoder_changed,(gpointer)pos); - } -#endif - -#if defined (CONTROLLER2_V2) - pos=e2_top_encoder_get_pos(); - if(pos!=0) { - g_idle_add(e2_top_encoder_changed,(gpointer)pos); - } - - pos=e3_top_encoder_get_pos(); - if(pos!=0) { - g_idle_add(e3_top_encoder_changed,(gpointer)pos); - } - - pos=e4_top_encoder_get_pos(); - if(pos!=0) { - g_idle_add(e4_top_encoder_changed,(gpointer)pos); + if(controller==CONTROLLER2_V1 || controller==CONTROLLER2_V2) { + pos=e5_encoder_get_pos(); + if(pos!=0) { + g_idle_add(e5_encoder_changed,(gpointer)pos); + } } - pos=e5_top_encoder_get_pos(); - if(pos!=0) { + + if(controller==CONTROLLER2_V2) { + pos=e2_top_encoder_get_pos(); + if(pos!=0) { + g_idle_add(e2_top_encoder_changed,(gpointer)pos); + } + + pos=e3_top_encoder_get_pos(); + if(pos!=0) { + g_idle_add(e3_top_encoder_changed,(gpointer)pos); + } + + pos=e4_top_encoder_get_pos(); + if(pos!=0) { + g_idle_add(e4_top_encoder_changed,(gpointer)pos); + } + + pos=e5_top_encoder_get_pos(); + if(pos!=0) { g_idle_add(e5_top_encoder_changed,(gpointer)pos); + } } -#endif #ifdef sx1509 // buttons only generate interrupt when diff --git a/gpio.h b/gpio.h index c146579..a0fec51 100644 --- a/gpio.h +++ b/gpio.h @@ -21,7 +21,23 @@ #define _GPIO_H enum { - ENCODER_AF_GAIN_RX1=0, + NO_CONTROLLER=0, + CONTROLLER1, + CONTROLLER2_V1, + CONTROLLER2_V2, + CUSTOM_CONTROLLER +}; + +extern int controller; + +enum { + ENCODER_NO_ACTION=0, + ENCODER_AF_GAIN, + ENCODER_RF_GAIN, + ENCODER_AGC_GAIN, + ENCODER_IF_WIDTH, + ENCODER_IF_SHIFT, + ENCODER_AF_GAIN_RX1, ENCODER_RF_GAIN_RX1, ENCODER_AF_GAIN_RX2, ENCODER_RF_GAIN_RX2, @@ -29,10 +45,13 @@ enum { ENCODER_AGC_GAIN_RX2, ENCODER_IF_WIDTH_RX1, ENCODER_IF_WIDTH_RX2, + ENCODER_IF_SHIFT_RX1, + ENCODER_IF_SHIFT_RX2, ENCODER_ATTENUATION, ENCODER_MIC_GAIN, ENCODER_DRIVE, ENCODER_TUNE_DRIVE, + ENCODER_RIT, ENCODER_RIT_RX1, ENCODER_RIT_RX2, ENCODER_XIT, @@ -40,7 +59,12 @@ enum { ENCODER_CW_FREQUENCY, ENCODER_PANADAPTER_HIGH, ENCODER_PANADAPTER_LOW, + ENCODER_PANADAPTER_STEP, + ENCODER_WATERFALL_HIGH, + ENCODER_WATERFALL_LOW, ENCODER_SQUELCH, + ENCODER_SQUELCH_RX1, + ENCODER_SQUELCH_RX2, ENCODER_COMP, ENCODER_DIVERSITY_GAIN, ENCODER_DIVERSITY_PHASE, @@ -86,6 +110,7 @@ enum { MENU_FREQUENCY, MENU_MEMORY, MENU_DIVERSITY, + MENU_PS, FUNCTION, SWITCH_ACTIONS }; @@ -93,44 +118,39 @@ enum { extern char *sw_string[SWITCH_ACTIONS]; -#if !defined (CONTROLLER2_V2) && !defined (CONTROLLER2_V1) -#define SWITCHES 8 enum { - SW1=0, - SW2, - SW3, - SW4, - SW5, - SW6, - SW7, - SW8 + CONTROLLER1_SW1=0, + CONTROLLER1_SW2, + CONTROLLER1_SW3, + CONTROLLER1_SW4, + CONTROLLER1_SW5, + CONTROLLER1_SW6, + CONTROLLER1_SW7, + CONTROLLER1_SW8, + CONTROLLER1_SWITCHES }; -#endif -#if defined (CONTROLLER2_V2) || defined (CONTROLLER2_V1) -#define SWITCHES 16 enum { - SW2=0, - SW3, - SW4, - SW5, - SW6, - SW7, - SW8, - SW9, - SW10, - SW11, - SW12, - SW13, - SW14, - SW15, - SW16, - SW17 + CONTROLLER2_SW2=0, + CONTROLLER2_SW3, + CONTROLLER2_SW4, + CONTROLLER2_SW5, + CONTROLLER2_SW6, + CONTROLLER2_SW7, + CONTROLLER2_SW8, + CONTROLLER2_SW9, + CONTROLLER2_SW10, + CONTROLLER2_SW11, + CONTROLLER2_SW12, + CONTROLLER2_SW13, + CONTROLLER2_SW14, + CONTROLLER2_SW15, + CONTROLLER2_SW16, + CONTROLLER2_SW17, + CONTROLLER2_SWITCHES }; -#endif - -extern int sw_action[SWITCHES]; +extern int *sw_action; extern int settle_time; @@ -150,30 +170,49 @@ extern int e3_sw_action; extern int e4_sw_action; extern int e5_sw_action; +// uses wiringpi pin numbers extern int ENABLE_VFO_ENCODER; extern int ENABLE_VFO_PULLUP; extern int VFO_ENCODER_A; extern int VFO_ENCODER_B; -extern int VFO_ENCODER_A_PIN; -extern int VFO_ENCODER_B_PIN; extern int ENABLE_E2_ENCODER; extern int ENABLE_E2_PULLUP; extern int E2_ENCODER_A; extern int E2_ENCODER_B; +extern int ENABLE_E2_TOP_ENCODER; +extern int E2_TOP_ENCODER_A; +extern int E2_TOP_ENCODER_B; +extern int E2_FUNCTION; extern int ENABLE_E3_ENCODER; extern int ENABLE_E3_PULLUP; extern int E3_ENCODER_A; extern int E3_ENCODER_B; +extern int ENABLE_E3_TOP_ENCODER; +extern int E3_TOP_ENCODER_A; +extern int E3_TOP_ENCODER_B; +extern int E3_FUNCTION; extern int ENABLE_E4_ENCODER; extern int ENABLE_E4_PULLUP; extern int E4_ENCODER_A; extern int E4_ENCODER_B; -#if defined (CONTROLLER2_V2) || defined (CONTROLLER2_V1) +extern int ENABLE_E4_TOP_ENCODER; +extern int E4_TOP_ENCODER_A; +extern int E4_TOP_ENCODER_B; +extern int E4_FUNCTION; extern int ENABLE_E5_ENCODER; extern int ENABLE_E5_PULLUP; extern int E5_ENCODER_A; extern int E5_ENCODER_B; -#endif +extern int ENABLE_E5_TOP_ENCODER; +extern int E5_TOP_ENCODER_A; +extern int E5_TOP_ENCODER_B; +extern int E5_FUNCTION; + +extern int ENABLE_E2_BUTTON; +extern int ENABLE_E3_BUTTON; +extern int ENABLE_E4_BUTTON; +extern int ENABLE_E5_BUTTON; + extern int ENABLE_S1_BUTTON; extern int S1_BUTTON; extern int ENABLE_S2_BUTTON; @@ -186,6 +225,7 @@ extern int ENABLE_S5_BUTTON; extern int S5_BUTTON; extern int ENABLE_S6_BUTTON; extern int S6_BUTTON; + extern int ENABLE_MOX_BUTTON; extern int MOX_BUTTON; extern int ENABLE_FUNCTION_BUTTON; @@ -197,28 +237,29 @@ extern int SIDETONE_GPIO; extern int ENABLE_GPIO_SIDETONE; extern int ENABLE_CW_BUTTONS; extern int CW_ACTIVE_LOW; -void gpio_cw_sidetone_set(int level); -int gpio_left_cw_key(); -int gpio_right_cw_key(); -int gpio_cw_sidetone_enabled(); +extern void gpio_cw_sidetone_set(int level); +extern int gpio_left_cw_key(); +extern int gpio_right_cw_key(); +extern int gpio_cw_sidetone_enabled(); #endif -void gpio_restore_actions(); -void gpio_restore_state(); -void gpio_save_state(); -void gpio_save_actions(); -int gpio_init(); -void gpio_close(); -int vfo_encoder_get_pos(); -int af_encoder_get_pos(); -int af_function_get_state(); -int rf_encoder_get_pos(); -int rf_function_get_state(); -int function_get_state(); -int band_get_state(); -int mode_get_state(); -int filter_get_state(); -int noise_get_state(); -int mox_get_state(); +extern void gpio_set_defaults(int ctrlr); +extern void gpio_restore_actions(); +extern void gpio_restore_state(); +extern void gpio_save_state(); +extern void gpio_save_actions(); +extern int gpio_init(); +extern void gpio_close(); +extern int vfo_encoder_get_pos(); +extern int af_encoder_get_pos(); +extern int af_function_get_state(); +extern int rf_encoder_get_pos(); +extern int rf_function_get_state(); +extern int function_get_state(); +extern int band_get_state(); +extern int mode_get_state(); +extern int filter_get_state(); +extern int noise_get_state(); +extern int mox_get_state(); #endif diff --git a/i2c.c b/i2c.c index 67f52ee..1dc7b1e 100644 --- a/i2c.c +++ b/i2c.c @@ -133,55 +133,53 @@ void i2c_interrupt() { int i=-1; switch(ints) { case SW_2: - i=SW2; + i=CONTROLLER2_SW2; break; case SW_3: - i=SW3; + i=CONTROLLER2_SW3; break; case SW_4: - i=SW4; + i=CONTROLLER2_SW4; break; case SW_5: - i=SW5; + i=CONTROLLER2_SW5; break; case SW_6: - i=SW6; + i=CONTROLLER2_SW6; break; case SW_7: - i=SW7; + i=CONTROLLER2_SW7; break; case SW_8: - i=SW8; + i=CONTROLLER2_SW8; break; -#if defined (CONTROLLER2_V2) || defined (CONTROLLER2_V1) case SW_9: - i=SW9; + i=CONTROLLER2_SW9; break; case SW_10: - i=SW10; + i=CONTROLLER2_SW10; break; case SW_11: - i=SW11; + i=CONTROLLER2_SW11; break; case SW_12: - i=SW12; + i=CONTROLLER2_SW12; break; case SW_13: - i=SW13; + i=CONTROLLER2_SW13; break; case SW_14: - i=SW14; + i=CONTROLLER2_SW14; break; case SW_15: - i=SW15; + i=CONTROLLER2_SW15; break; case SW_16: - i=SW16; + i=CONTROLLER2_SW16; break; case SW_17: - i=SW17; + i=CONTROLLER2_SW17; break; -#endif } //g_print("i1c_interrupt: sw=%d action=%d\n",i,sw_action[i]); switch(sw_action[i]) { diff --git a/iambic.c b/iambic.c index 9a405b9..7f58ebf 100644 --- a/iambic.c +++ b/iambic.c @@ -72,36 +72,21 @@ * * - cw_keyer_spacing can now be set/un-set in the CW menu (cw_menu.c) * - * - changing the scheduling policy now becomes only effective for the keyer thread, because - * sched_setscheduler() is called at the beginning and the end of the keyer thread with - * pid argument 0 (even better: use gettid() return value). - * NOTE: this is Linux-specific. Better switch to POSIX calls (e.g. pthread_setschedparam). - * mlockall and munlockall still apply process-wide and are therefore executed in - * keyer_init/keyer_close. - * - * APPLE MacOS: if we run this in MacOS, most likely we are not "root". Therefore no locking/scheduling. - * * b) SIDE TONE GENERATION * ======================= * - * There is a possibility to generate a side tone on one of the GPIO ports. This is necessary at - * speeds greater than 20 wpm since there is a 50 msec delay (due to the LINUX sound system) between - * generating the side tone and when it finally appears in the head-phone. The GPIO side tone comes - * without a delay. + * Getting a delay-free side tone is absolutely necessary at elevated CW speed (say, > 20 wpm). + * The LINUX sound system produces a delay of up to 50 msec which is more than a dot length. + * Therefore we offer delay-free side tone information on the GPIO. * - * The volume of the CW side tone in the standard audio channel is reduced to zero while producing - * a square wave on the GPIO pin. The idea is to low-pass this signal and combine it with the audio - * output (hardware mixer). + * However, LINUX is not a real-time operating system, and producing a square wave with exactly + * the side tone frequency is not possible (the tone is not very stable). Therefore we just + * give the tone information (output high = tone on, output low = tone off), and one has to + * build a tone generator connected to a buzzer or small speaker, and use the GPIO output line + * to switch the tone on and off. * - * In the previous version, the side tone was generate using the softTone functionality of wiringPI - * within the GPIO module. However, this has a drawback: - * one creates two high-priority threads (the tone generator and the keyer) - * both firing at high speed (once a milli-sec and faster). This made the frequency of the tone quite - * unstable. Instead, the side tone is now explicitly generated within the keyer (if GPIO side tone is activated) - * by periodically writing "1" and "0" to the GPIO output while waiting for the end of the just-being-sent - * dot or dash. Furthermore, the frequency of the side tone has been stabilized by "sleeping" UNTIL the - * pre-calculated output-switching time (and not FOR the calculated amount, this is, using TIMER_ABSTIME - * in clock_nanosleep). + * The volume of the CW side tone in the standard audio channel is reduced to zero while + * using the "GPIO side tone" feature. * * c) CW VOX * ========= @@ -112,8 +97,7 @@ * * - cw_keyer_spacing can now be set/un-set in the CW menu (cw_menu.c) * - * - during a dot or dash when no GPIO side tone is produced, the keyer thread simply waits and - * does no busy spinning. + * - during a dot or dash the keyer thread simply waits and does no busy spinning. * * d) DOT/DASH MEMORY * ================== @@ -343,14 +327,19 @@ void set_keyer_out(int state) { } else { cw_hold_key(0); // this stops a CW pulse in transmitter.c } + // + // If GPIO sidetone information is requested, + // set GPIO pin to the state + // + if (gpio_cw_sidetone_enabled()) { + gpio_cw_sidetone_set(state); + } } static void* keyer_thread(void *arg) { int pos; struct timespec loop_delay; int interval = 1000000; // 1 ms - int sidewait; - int sideloop; int i; int kdelay; int old_volume; @@ -359,14 +348,6 @@ static void* keyer_thread(void *arg) { struct timespec now; #endif -#ifndef __APPLE__ - struct sched_param param; - param.sched_priority = MY_PRIORITY; - if(sched_setscheduler((pid_t)0, SCHED_FIFO, ¶m) == -1) { - perror("sched_setscheduler failed"); - } -#endif - fprintf(stderr,"keyer_thread state running= %d\n", running); while(running) { enforce_cw_vox=0; @@ -376,6 +357,14 @@ static void* keyer_thread(void *arg) { sem_wait(&cw_event); #endif + // + // If using GPIO side tone information, mute CW side tone + // as long as the keyer thread is active + // + if (gpio_cw_sidetone_enabled()) { + old_volume=cw_keyer_sidetone_volume; + } + // swallow any cw_events posted during the last "cw hang" time. if (!kcwl && !kcwr) continue; @@ -430,108 +419,31 @@ static void* keyer_thread(void *arg) { if (*kdash) { // send manual dashes set_keyer_out(1); clock_gettime(CLOCK_MONOTONIC, &loop_delay); - // wait until dash is released - if (gpio_cw_sidetone_enabled()) { - // produce tone - // Note. Using clock_nanosleep with ABSTIME is absolutely - // necessary to produce a stable frequency. - // You still may painfully recognize that LINUX - // e.g. on a RaspberryPi is not a real-time - // operating system. - // Mute "normal" CW side tone, it will be reactivated - // at the end of the following delay. - old_volume=cw_keyer_sidetone_volume; - cw_keyer_sidetone_volume=0; - sidewait=500000000/cw_keyer_sidetone_frequency; - for (;;) { - gpio_cw_sidetone_set(1); - loop_delay.tv_nsec += sidewait; - while (loop_delay.tv_nsec >= NSEC_PER_SEC) { - loop_delay.tv_nsec -= NSEC_PER_SEC; - loop_delay.tv_sec++; - } -#ifdef __APPLE__ - clock_gettime(CLOCK_MONOTONIC, &now); - now.tv_sec =loop_delay.tv_sec - now.tv_sec; - now.tv_nsec=loop_delay.tv_nsec - now.tv_nsec; - while (now.tv_nsec < 0) { - now.tv_nsec += 1000000000; - now.tv_sec--; - } - nanosleep(&now, NULL); -#else - clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &loop_delay, NULL); -#endif - gpio_cw_sidetone_set(0); - loop_delay.tv_nsec += sidewait; - while (loop_delay.tv_nsec >= NSEC_PER_SEC) { - loop_delay.tv_nsec -= NSEC_PER_SEC; - loop_delay.tv_sec++; - } - if (!*kdash) break; -#ifdef __APPLE__ - clock_gettime(CLOCK_MONOTONIC, &now); - now.tv_sec =loop_delay.tv_sec - now.tv_sec; - now.tv_nsec=loop_delay.tv_nsec - now.tv_nsec; - while (now.tv_nsec < 0) { - now.tv_nsec += 1000000000; - now.tv_sec--; - } - nanosleep(&now, NULL); -#else - clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &loop_delay, NULL); -#endif - } - } else { - // No-GPIO-sidetone case: - // wait until dash is released. Check once a milli-sec - for (;;) { - loop_delay.tv_nsec += interval; - while (loop_delay.tv_nsec >= NSEC_PER_SEC) { - loop_delay.tv_nsec -= NSEC_PER_SEC; - loop_delay.tv_sec++; - } - if (!*kdash) break; + // wait until dash is released. Check once a milli-sec + for (;;) { + loop_delay.tv_nsec += interval; + while (loop_delay.tv_nsec >= NSEC_PER_SEC) { + loop_delay.tv_nsec -= NSEC_PER_SEC; + loop_delay.tv_sec++; + } + if (!*kdash) break; #ifdef __APPLE__ - clock_gettime(CLOCK_MONOTONIC, &now); - now.tv_sec =loop_delay.tv_sec - now.tv_sec; - now.tv_nsec=loop_delay.tv_nsec - now.tv_nsec; - while (now.tv_nsec < 0) { - now.tv_nsec += 1000000000; - now.tv_sec--; - } - nanosleep(&now, NULL); + clock_gettime(CLOCK_MONOTONIC, &now); + now.tv_sec =loop_delay.tv_sec - now.tv_sec; + now.tv_nsec=loop_delay.tv_nsec - now.tv_nsec; + while (now.tv_nsec < 0) { + now.tv_nsec += 1000000000; + now.tv_sec--; + } + nanosleep(&now, NULL); #else - clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &loop_delay, NULL); + clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &loop_delay, NULL); #endif - } - } + } // dash released. set_keyer_out(0); // since we stay in CHECK mode, re-trigger cwvox here cwvox=cw_keyer_hang_time; - // wait at least 10ms before re-activating sidetone, - // to allow the envelope of the side tone reaching zero - if (gpio_cw_sidetone_enabled()) { - loop_delay.tv_nsec += 10*interval; - while (loop_delay.tv_nsec >= NSEC_PER_SEC) { - loop_delay.tv_nsec -= NSEC_PER_SEC; - loop_delay.tv_sec++; - } -#ifdef __APPLE__ - clock_gettime(CLOCK_MONOTONIC, &now); - now.tv_sec =loop_delay.tv_sec - now.tv_sec; - now.tv_nsec=loop_delay.tv_nsec - now.tv_nsec; - while (now.tv_nsec < 0) { - now.tv_nsec += 1000000000; - now.tv_sec--; - } - nanosleep(&now, NULL); -#else - clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &loop_delay, NULL); -#endif - cw_keyer_sidetone_volume=old_volume; - } } if (*kdot) { // "bug" mode: dot key activates automatic dots @@ -553,69 +465,24 @@ static void* keyer_thread(void *arg) { dash_held = *kdash; set_keyer_out(1); clock_gettime(CLOCK_MONOTONIC, &loop_delay); - if (gpio_cw_sidetone_enabled()) { - old_volume=cw_keyer_sidetone_volume; - cw_keyer_sidetone_volume=0; - sidewait=500000000/cw_keyer_sidetone_frequency; - sideloop=(500000*dot_length)/sidewait; - for (i=0; i= NSEC_PER_SEC) { - loop_delay.tv_nsec -= NSEC_PER_SEC; - loop_delay.tv_sec++; - } -#ifdef __APPLE__ - clock_gettime(CLOCK_MONOTONIC, &now); - now.tv_sec =loop_delay.tv_sec - now.tv_sec; - now.tv_nsec=loop_delay.tv_nsec - now.tv_nsec; - while (now.tv_nsec < 0) { - now.tv_nsec += 1000000000; - now.tv_sec--; - } - nanosleep(&now, NULL); -#else - clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &loop_delay, NULL); -#endif - gpio_cw_sidetone_set(0); - loop_delay.tv_nsec += sidewait; - while (loop_delay.tv_nsec >= NSEC_PER_SEC) { - loop_delay.tv_nsec -= NSEC_PER_SEC; - loop_delay.tv_sec++; - } -#ifdef __APPLE__ - clock_gettime(CLOCK_MONOTONIC, &now); - now.tv_sec =loop_delay.tv_sec - now.tv_sec; - now.tv_nsec=loop_delay.tv_nsec - now.tv_nsec; - while (now.tv_nsec < 0) { - now.tv_nsec += 1000000000; - now.tv_sec--; - } - nanosleep(&now, NULL); -#else - clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &loop_delay, NULL); -#endif - } - } else { - // No-GPIO-sidetone case: just wait - loop_delay.tv_nsec += 1000000 * dot_length; - while (loop_delay.tv_nsec >= NSEC_PER_SEC) { - loop_delay.tv_nsec -= NSEC_PER_SEC; - loop_delay.tv_sec++; - } + // Wait one dot length, then key-up + loop_delay.tv_nsec += 1000000 * dot_length; + while (loop_delay.tv_nsec >= NSEC_PER_SEC) { + loop_delay.tv_nsec -= NSEC_PER_SEC; + loop_delay.tv_sec++; + } #ifdef __APPLE__ - clock_gettime(CLOCK_MONOTONIC, &now); - now.tv_sec =loop_delay.tv_sec - now.tv_sec; - now.tv_nsec=loop_delay.tv_nsec - now.tv_nsec; - while (now.tv_nsec < 0) { - now.tv_nsec += 1000000000; - now.tv_sec--; - } - nanosleep(&now, NULL); + clock_gettime(CLOCK_MONOTONIC, &now); + now.tv_sec =loop_delay.tv_sec - now.tv_sec; + now.tv_nsec=loop_delay.tv_nsec - now.tv_nsec; + while (now.tv_nsec < 0) { + now.tv_nsec += 1000000000; + now.tv_sec--; + } + nanosleep(&now, NULL); #else - clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &loop_delay, NULL); + clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &loop_delay, NULL); #endif - } set_keyer_out(0); key_state = DOTDELAY; // add inter-character spacing of one dot length kdelay=0; @@ -624,9 +491,6 @@ static void* keyer_thread(void *arg) { case DOTDELAY: kdelay++; if (kdelay > dot_length) { - if (gpio_cw_sidetone_enabled()) { - cw_keyer_sidetone_volume=old_volume; - } if (cw_keyer_mode == KEYER_STRAIGHT) { // bug mode: continue sending dots or exit, depending on current dot key status key_state = EXITLOOP; @@ -663,69 +527,24 @@ static void* keyer_thread(void *arg) { dot_held = *kdot; // remember if dot is still held at beginning of the dash set_keyer_out(1); clock_gettime(CLOCK_MONOTONIC, &loop_delay); - if (gpio_cw_sidetone_enabled()) { - old_volume=cw_keyer_sidetone_volume; - cw_keyer_sidetone_volume=0; - sidewait=500000000/cw_keyer_sidetone_frequency; - sideloop=(500000*dash_length)/sidewait; - for (i=0; i= NSEC_PER_SEC) { - loop_delay.tv_nsec -= NSEC_PER_SEC; - loop_delay.tv_sec++; - } -#ifdef __APPLE__ - clock_gettime(CLOCK_MONOTONIC, &now); - now.tv_sec =loop_delay.tv_sec - now.tv_sec; - now.tv_nsec=loop_delay.tv_nsec - now.tv_nsec; - while (now.tv_nsec < 0) { - now.tv_nsec += 1000000000; - now.tv_sec--; - } - nanosleep(&now, NULL); -#else - clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &loop_delay, NULL); -#endif - gpio_cw_sidetone_set(0); - loop_delay.tv_nsec += sidewait; - while (loop_delay.tv_nsec >= NSEC_PER_SEC) { - loop_delay.tv_nsec -= NSEC_PER_SEC; - loop_delay.tv_sec++; - } -#ifdef __APPLE__ - clock_gettime(CLOCK_MONOTONIC, &now); - now.tv_sec =loop_delay.tv_sec - now.tv_sec; - now.tv_nsec=loop_delay.tv_nsec - now.tv_nsec; - while (now.tv_nsec < 0) { - now.tv_nsec += 1000000000; - now.tv_sec--; - } - nanosleep(&now, NULL); -#else - clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &loop_delay, NULL); -#endif - } - } else { - // No-GPIO-sidetone case: just wait - loop_delay.tv_nsec += 1000000L * dash_length; - while (loop_delay.tv_nsec >= NSEC_PER_SEC) { - loop_delay.tv_nsec -= NSEC_PER_SEC; - loop_delay.tv_sec++; - } + // Wait one dash length and then key-up + loop_delay.tv_nsec += 1000000L * dash_length; + while (loop_delay.tv_nsec >= NSEC_PER_SEC) { + loop_delay.tv_nsec -= NSEC_PER_SEC; + loop_delay.tv_sec++; + } #ifdef __APPLE__ - clock_gettime(CLOCK_MONOTONIC, &now); - now.tv_sec =loop_delay.tv_sec - now.tv_sec; - now.tv_nsec=loop_delay.tv_nsec - now.tv_nsec; - while (now.tv_nsec < 0) { - now.tv_nsec += 1000000000; - now.tv_sec--; - } - nanosleep(&now, NULL); + clock_gettime(CLOCK_MONOTONIC, &now); + now.tv_sec =loop_delay.tv_sec - now.tv_sec; + now.tv_nsec=loop_delay.tv_nsec - now.tv_nsec; + while (now.tv_nsec < 0) { + now.tv_nsec += 1000000000; + now.tv_sec--; + } + nanosleep(&now, NULL); #else - clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &loop_delay, NULL); + clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &loop_delay, NULL); #endif - } set_keyer_out(0); key_state = DASHDELAY; // add inter-character spacing of one dot length kdelay=0; @@ -736,9 +555,6 @@ static void* keyer_thread(void *arg) { // we never arrive here in STRAIGHT/BUG mode kdelay++; if (kdelay > dot_length) { - if (gpio_cw_sidetone_enabled()) { - cw_keyer_sidetone_volume=old_volume; - } // // DL1YCF: // This is my understanding where MODE A comes in: @@ -779,8 +595,8 @@ static void* keyer_thread(void *arg) { } // time stamp in loop_delay is either the last time stamp from the - // top of the loop, or the last time stamp from tone generation - // NOTE: we are using ABSTIME here to produce accurate delays. + // top of the loop, or the time stamp from the last key-down/key-up transition. + // wait another milli-second before cycling the outer loop loop_delay.tv_nsec += interval; while (loop_delay.tv_nsec >= NSEC_PER_SEC) { loop_delay.tv_nsec -= NSEC_PER_SEC; @@ -798,14 +614,16 @@ static void* keyer_thread(void *arg) { #else clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &loop_delay, NULL); #endif + // + // If we have reduced the side tone volume, restore it! + // + if (gpio_cw_sidetone_enabled()) { + cw_keyer_sidetone_volume = old_volume; + } } } fprintf(stderr,"keyer_thread: EXIT\n"); -#ifndef __APPLE__ - param.sched_priority = 0; - sched_setscheduler((pid_t) 0, SCHED_OTHER, ¶m); -#endif return NULL; } @@ -825,9 +643,6 @@ void keyer_close() { sem_close(&cw_event); #endif -#ifndef __APPLE__ - munlockall(); -#endif } int keyer_init() { @@ -835,12 +650,6 @@ int keyer_init() { fprintf(stderr,".... starting keyer thread.\n"); -#ifndef __APPLE__ - if(mlockall(MCL_CURRENT|MCL_FUTURE) == -1) { - perror("mlockall failed"); - } -#endif - #ifdef __APPLE__ sem_unlink("CW"); cw_event=sem_open("CW", O_CREAT | O_EXCL, 0700, 0); diff --git a/main.c b/main.c index 37a5807..6fa9c13 100644 --- a/main.c +++ b/main.c @@ -57,7 +57,6 @@ #ifdef SOAPYSDR #include "soapy_protocol.h" #endif -#include "frequency.h" // for canTransmit #include "ext.h" struct utsname unameData; diff --git a/meter.c b/meter.c index 01a60eb..01f365d 100644 --- a/meter.c +++ b/meter.c @@ -26,18 +26,12 @@ #include "receiver.h" #include "meter.h" +#include "radio.h" #include "wdsp.h" #include "radio.h" #include "version.h" #include "mode.h" #include "vox.h" -#ifdef FREEDV -#include "freedv.h" -#include "vfo.h" -#endif -#ifdef PSK -#include "psk.h" -#endif #include "new_menu.h" static GtkWidget *parent_window; @@ -48,7 +42,7 @@ static cairo_surface_t *meter_surface = NULL; static int meter_width; static int meter_height; static int last_meter_type=SMETER; -static int max_level=-200; +static double max_level=-200.0; static int max_count=0; static int max_reverse=0; @@ -116,68 +110,6 @@ meter_press_event_cb (GtkWidget *widget, gpointer data) { start_meter(); -/* - GtkWidget *dialog=gtk_dialog_new_with_buttons("Meter",GTK_WINDOW(parent_window),GTK_DIALOG_DESTROY_WITH_PARENT,NULL,NULL); - //gtk_window_set_decorated(GTK_WINDOW(dialog),FALSE); - - 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_homogeneous(GTK_GRID(grid),TRUE); - gtk_grid_set_row_homogeneous(GTK_GRID(grid),TRUE); - - - GtkWidget *smeter_peak=gtk_radio_button_new_with_label(NULL,"S Meter Peak"); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (smeter_peak), smeter==RXA_S_PK); - gtk_widget_show(smeter_peak); - gtk_grid_attach(GTK_GRID(grid),smeter_peak,0,1,1,1); - g_signal_connect(smeter_peak,"toggled",G_CALLBACK(smeter_select_cb),(gpointer *)RXA_S_PK); - - GtkWidget *smeter_average=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(smeter_peak),"S Meter Average"); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (smeter_average), smeter==RXA_S_AV); - gtk_widget_show(smeter_average); - gtk_grid_attach(GTK_GRID(grid),smeter_average,0,2,1,1); - g_signal_connect(smeter_average,"toggled",G_CALLBACK(smeter_select_cb),(gpointer *)RXA_S_AV); - - GtkWidget *alc_peak=gtk_radio_button_new_with_label(NULL,"ALC Peak"); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (alc_peak), alc==TXA_ALC_PK); - gtk_widget_show(alc_peak); - gtk_grid_attach(GTK_GRID(grid),alc_peak,1,1,1,1); - g_signal_connect(alc_peak,"toggled",G_CALLBACK(alc_meter_select_cb),(gpointer *)TXA_ALC_PK); - - GtkWidget *alc_average=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(alc_peak),"ALC Average"); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (alc_average), alc==TXA_ALC_AV); - gtk_widget_show(alc_average); - gtk_grid_attach(GTK_GRID(grid),alc_average,1,2,1,1); - g_signal_connect(alc_average,"toggled",G_CALLBACK(alc_meter_select_cb),(gpointer *)TXA_ALC_AV); - - GtkWidget *alc_gain=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(alc_peak),"ALC Gain"); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (alc_gain), alc==TXA_ALC_GAIN); - gtk_widget_show(alc_gain); - gtk_grid_attach(GTK_GRID(grid),alc_gain,1,3,1,1); - g_signal_connect(alc_gain,"toggled",G_CALLBACK(alc_meter_select_cb),(gpointer *)TXA_ALC_GAIN); - - - gtk_container_add(GTK_CONTAINER(content),grid); - - GtkWidget *close_button=gtk_dialog_add_button(GTK_DIALOG(dialog),"Close",GTK_RESPONSE_OK); - gtk_widget_override_font(close_button, pango_font_description_from_string("FreeMono 18")); - gtk_widget_show_all(dialog); - - g_signal_connect_swapped (dialog, - "response", - G_CALLBACK (gtk_widget_destroy), - dialog); - - int result=gtk_dialog_run(GTK_DIALOG(dialog)); -*/ return TRUE; } @@ -210,11 +142,54 @@ fprintf(stderr,"meter_init: width=%d height=%d\n",width,height); void meter_update(RECEIVER *rx,int meter_type,double value,double reverse,double exciter,double alc) { + double level; char sf[32]; int text_location; double offset; - cairo_t *cr; - cr = cairo_create (meter_surface); + int max_power=100; + char *units="W"; + double interval=10.0; + cairo_t *cr = cairo_create (meter_surface); + + if(meter_type==POWER) { + level=value; + if(level==0.0) { + level=exciter; + } + switch(pa_power) { + case PA_1W: + max_power=1000; + units="mW"; + interval=100.0; + level=level*1000.0; + break; + case PA_10W: + max_power=10; + interval=1.0; + break; + case PA_30W: + max_power=30; + interval=3.0; + break; + case PA_50W: + max_power=50; + interval=5.0; + break; + case PA_100W: + max_power=100; + interval=10.0; + break; + case PA_200W: + max_power=200; + interval=20.0; + break; + case PA_500W: + max_power=500; + interval=50.0; + break; + } + } + if(analog_meter) { cairo_set_source_rgb (cr, 0.0, 0.0, 0.0); cairo_paint (cr); @@ -224,7 +199,11 @@ if(analog_meter) { switch(meter_type) { case SMETER: { - double level=value+(double)adc_attenuation[rx->adc]; + if(have_rx_gain) { + level=value+40.0-(adc_attenuation[rx->adc]+12.0); + } else { + level=value+(double)adc_attenuation[rx->adc]; + } #ifdef SOAPYSDR if(protocol==SOAPYSDR_PROTOCOL) { level-=rx->rf_gain; @@ -249,8 +228,8 @@ if(analog_meter) { double y; double angle; double radians; - double cx=(double)meter_width/2.0; // cx == cy throughout - double cy=(double)meter_width/2.0; // cx == cy throughout + double cx=(double)meter_width/2.0; + double cy=(double)meter_width/2.0; double radius=cy-20.0; cairo_set_line_width(cr, 1.0); @@ -329,25 +308,10 @@ if(analog_meter) { cairo_move_to(cr, 80, meter_height-2); cairo_show_text(cr, sf); -#ifdef FREEDV - if(active_receiver->freedv) { - if(freedv_sync) { - cairo_set_source_rgb(cr, 0.0, 1.0, 0.0); - } else { - cairo_set_source_rgb(cr, 1.0, 0.0, 0.0); - } - sprintf(sf,"SNR: %3.2f",freedv_snr); - cairo_move_to(cr, 70, meter_height-12); - cairo_show_text(cr, sf); - } -#endif - - } break; case POWER: { - double level=value; offset=220.0; int i; @@ -355,8 +319,8 @@ if(analog_meter) { double y; double angle; double radians; - double cx=(double)meter_width/2.0; // cx == cy throughout - double cy=(double)meter_width/2.0; // cx == cy throughout + double cx=(double)meter_width/2.0; + double cy=(double)meter_width/2.0; double radius=cy-20.0; cairo_set_line_width(cr, 1.0); @@ -367,6 +331,65 @@ if(analog_meter) { cairo_set_line_width(cr, 1.0); cairo_set_source_rgb(cr, 1.0, 1.0, 1.0); + int max_power=100; + char *units="W"; + double interval=10.0; + switch(pa_power) { + case PA_1W: + max_power=1000; + units="mW"; + interval=100.0; + break; + case PA_10W: + max_power=10; + interval=1.0; + break; + case PA_30W: + max_power=30; + interval=3.0; + break; + case PA_50W: + max_power=50; + interval=5.0; + break; + case PA_100W: + max_power=100; + interval=10.0; + break; + case PA_200W: + max_power=200; + interval=20.0; + break; + case PA_500W: + max_power=500; + interval=50.0; + break; + } + + for(i=0;i<=100;i++) { + angle=(double)i+offset; + radians=angle*M_PI/180.0; + if((i%10)==0) { + cairo_arc(cr, cx, cy, radius+4, radians, radians); + cairo_get_current_point(cr, &x, &y); + cairo_arc(cr, cx, cy, radius, radians, radians); + cairo_line_to(cr, x, y); + cairo_stroke(cr); + + if((i%20)==0) { + sprintf(sf,"%d",(i/10)*(int)interval); + cairo_arc(cr, cx, cy, radius+5, radians, radians); + cairo_get_current_point(cr, &x, &y); + cairo_new_path(cr); + x-=6.0; + cairo_move_to(cr, x, y); + cairo_show_text(cr, sf); + } + } + cairo_new_path(cr); + } + +/* for(i=0;i<=100;i++) { angle=(double)i+offset; radians=angle*M_PI/180.0; @@ -404,17 +427,19 @@ if(analog_meter) { } cairo_new_path(cr); } +*/ cairo_set_line_width(cr, 1.0); cairo_set_source_rgb(cr, 1.0, 1.0, 1.0); - if((int)value>max_level || max_count==10) { - max_level=(int)value; + if(level>max_level || max_count==10) { + max_level=level; max_count=0; } max_count++; - angle=(max_level/2.0)+offset; + //angle=(max_level/2.0)+offset; + angle=(max_level*10.0*interval)+offset; radians=angle*M_PI/180.0; cairo_arc(cr, cx, cy, radius+8, radians, radians); cairo_line_to(cr, cx, cy); @@ -422,7 +447,7 @@ if(analog_meter) { cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); - sprintf(sf,"%d W",(int)max_level); + sprintf(sf,"%0.1f %s",max_level,units); cairo_move_to(cr, 80, meter_height-22); cairo_show_text(cr, sf); @@ -544,7 +569,11 @@ if(analog_meter) { // value is dBm text_location=10; offset=5.0; - double level=value+(double)adc_attenuation[rx->adc]; + if(have_rx_gain) { + level=value+40.0-(adc_attenuation[rx->adc]+12.0); + } else { + level=value+(double)adc_attenuation[rx->adc]; + } #ifdef SOAPYSDR if(protocol==SOAPYSDR_PROTOCOL) { level-=rx->rf_gain; @@ -632,69 +661,22 @@ if(analog_meter) { cairo_set_font_size(cr, 12); sprintf(sf,"%d dBm",(int)level); - cairo_move_to(cr, text_location, meter_height-30); + cairo_move_to(cr, text_location, meter_height-12); cairo_show_text(cr, sf); - -#ifdef FREEDV - if(active_receiver->freedv) { - if(freedv_sync) { - cairo_set_source_rgb(cr, 0.0, 1.0, 0.0); - } else { - cairo_set_source_rgb(cr, 1.0, 0.0, 0.0); - } - cairo_set_font_size(cr, 12); - sprintf(sf,"SNR: %3.2f",freedv_snr); - cairo_move_to(cr, text_location, meter_height-10); - cairo_show_text(cr, sf); - } -#endif break; -#ifdef PSK - case PSKMETER: - { - int i; - offset=5.0; - cairo_set_line_width(cr, 1.0); - cairo_set_source_rgb(cr, 1.0, 1.0, 1.0); - for(i=0;i<11;i++) { - cairo_move_to(cr,offset+(double)(i*20),(double)meter_height-10); - if((i%2)==0) { - cairo_line_to(cr,offset+(double)(i*20),(double)(meter_height-20)); - cairo_move_to(cr,offset+(double)(i*20),(double)meter_height); - sprintf(sf,"%d",i*10); - cairo_show_text(cr, sf); - } else { - cairo_line_to(cr,offset+(double)(i*20),(double)(meter_height-15)); - } - } - cairo_stroke(cr); - - cairo_set_source_rgb(cr, 0.0, 1.0, 0.0); - cairo_rectangle(cr, offset+0.0, (double)(meter_height-40), value*2, 20.0); - cairo_fill(cr); - - cairo_set_source_rgb(cr, 0.0, 1.0, 0.0); - cairo_set_font_size(cr, 12); - sprintf(sf,"Level: %d",(int)value); - cairo_move_to(cr, 210, 45); - cairo_show_text(cr, sf); - } - break; -#endif case POWER: - // value is Watts cairo_select_font_face(cr, "FreeMono", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD); cairo_set_font_size(cr, 12); - if((int)value>max_level || max_count==10) { - max_level=(int)value; + if(level>max_level || max_count==10) { + max_level=level; max_count=0; } max_count++; - sprintf(sf,"FWD: %d W",(int)max_level); + sprintf(sf,"FWD: %0.1f %s",max_level,units); cairo_move_to(cr, 10, 35); cairo_show_text(cr, sf); @@ -715,12 +697,6 @@ if(analog_meter) { sprintf(sf,"ALC: %2.1f dB",alc); cairo_move_to(cr, meter_width/2, 35); cairo_show_text(cr, sf); - -/* - sprintf(sf,"REV: %3.2f W",reverse); - cairo_move_to(cr, 10, 45); - cairo_show_text(cr, sf); -*/ break; } diff --git a/meter.h b/meter.h index 720a49a..7c3bfd2 100644 --- a/meter.h +++ b/meter.h @@ -24,10 +24,6 @@ #define SMETER 0 #define POWER 1 -#ifdef PSK -#define PSKMETER 2 -#endif - extern GtkWidget* meter_init(int width,int height,GtkWidget *parent); extern void meter_update(RECEIVER *rx,int meter_type,double value,double reverse,double exciter,double alc); diff --git a/meter_menu.c b/meter_menu.c index 7552e39..bb98f69 100644 --- a/meter_menu.c +++ b/meter_menu.c @@ -66,7 +66,6 @@ static void analog_cb(GtkToggleButton *widget, gpointer data) { analog_meter=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); } - void meter_menu (GtkWidget *parent) { parent_window=parent; @@ -86,47 +85,65 @@ void meter_menu (GtkWidget *parent) { GtkWidget *content=gtk_dialog_get_content_area(GTK_DIALOG(dialog)); GtkWidget *grid=gtk_grid_new(); + int row=0; + int col=0; + gtk_grid_set_column_homogeneous(GTK_GRID(grid),TRUE); gtk_grid_set_row_homogeneous(GTK_GRID(grid),TRUE); GtkWidget *close_b=gtk_button_new_with_label("Close"); g_signal_connect (close_b, "pressed", G_CALLBACK(close_cb), NULL); - gtk_grid_attach(GTK_GRID(grid),close_b,0,0,1,1); + gtk_grid_attach(GTK_GRID(grid),close_b,col,row,1,1); + + col++; GtkWidget *analog_b=gtk_check_button_new_with_label("Analog Meter"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (analog_b), analog_meter); - gtk_grid_attach(GTK_GRID(grid),analog_b,1,0,1,1); + gtk_grid_attach(GTK_GRID(grid),analog_b,col,row,1,1); g_signal_connect(analog_b,"toggled",G_CALLBACK(analog_cb),NULL); + row++; + col=0; + GtkWidget *smeter_peak=gtk_radio_button_new_with_label(NULL,"S Meter Peak"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (smeter_peak), smeter==RXA_S_PK); gtk_widget_show(smeter_peak); - gtk_grid_attach(GTK_GRID(grid),smeter_peak,0,1,1,1); - g_signal_connect(smeter_peak,"toggled",G_CALLBACK(smeter_select_cb),(gpointer)(long)RXA_S_PK); + gtk_grid_attach(GTK_GRID(grid),smeter_peak,col,row,1,1); + g_signal_connect(smeter_peak,"toggled",G_CALLBACK(smeter_select_cb),GINT_TO_POINTER(RXA_S_PK)); - GtkWidget *smeter_average=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(smeter_peak),"S Meter Average"); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (smeter_average), smeter==RXA_S_AV); - gtk_widget_show(smeter_average); - gtk_grid_attach(GTK_GRID(grid),smeter_average,0,2,1,1); - g_signal_connect(smeter_average,"toggled",G_CALLBACK(smeter_select_cb),(gpointer)(long)RXA_S_AV); + col++; GtkWidget *alc_peak=gtk_radio_button_new_with_label(NULL,"ALC Peak"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (alc_peak), alc==TXA_ALC_PK); gtk_widget_show(alc_peak); - gtk_grid_attach(GTK_GRID(grid),alc_peak,1,1,1,1); - g_signal_connect(alc_peak,"toggled",G_CALLBACK(alc_meter_select_cb),(gpointer)(long)TXA_ALC_PK); + gtk_grid_attach(GTK_GRID(grid),alc_peak,col,row,1,1); + g_signal_connect(alc_peak,"toggled",G_CALLBACK(alc_meter_select_cb),GINT_TO_POINTER(TXA_ALC_PK)); + + row++; + col=0; + + GtkWidget *smeter_average=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(smeter_peak),"S Meter Average"); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (smeter_average), smeter==RXA_S_AV); + gtk_widget_show(smeter_average); + gtk_grid_attach(GTK_GRID(grid),smeter_average,col,row,1,1); + g_signal_connect(smeter_average,"toggled",G_CALLBACK(smeter_select_cb),GINT_TO_POINTER(RXA_S_AV)); + + col++; GtkWidget *alc_average=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(alc_peak),"ALC Average"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (alc_average), alc==TXA_ALC_AV); gtk_widget_show(alc_average); - gtk_grid_attach(GTK_GRID(grid),alc_average,1,2,1,1); - g_signal_connect(alc_average,"toggled",G_CALLBACK(alc_meter_select_cb),(gpointer)(long)TXA_ALC_AV); + gtk_grid_attach(GTK_GRID(grid),alc_average,col,row,1,1); + g_signal_connect(alc_average,"toggled",G_CALLBACK(alc_meter_select_cb),GINT_TO_POINTER(TXA_ALC_AV)); + + row++; + col=0; GtkWidget *alc_gain=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(alc_peak),"ALC Gain"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (alc_gain), alc==TXA_ALC_GAIN); gtk_widget_show(alc_gain); - gtk_grid_attach(GTK_GRID(grid),alc_gain,1,3,1,1); - g_signal_connect(alc_gain,"toggled",G_CALLBACK(alc_meter_select_cb),(gpointer)(long)TXA_ALC_GAIN); + gtk_grid_attach(GTK_GRID(grid),alc_gain,col,row,1,1); + g_signal_connect(alc_gain,"toggled",G_CALLBACK(alc_meter_select_cb),GINT_TO_POINTER(TXA_ALC_GAIN)); gtk_container_add(GTK_CONTAINER(content),grid); diff --git a/mode.c b/mode.c index 349d7ca..3497d1a 100644 --- a/mode.c +++ b/mode.c @@ -30,8 +30,5 @@ char *mode_string[]={ ,"DIGL" ,"SAM" ,"DRM" -#ifdef PSK - ,"PSK" -#endif }; diff --git a/mode.h b/mode.h index 22ca810..e566eee 100644 --- a/mode.h +++ b/mode.h @@ -32,12 +32,7 @@ #define modeDIGL 9 #define modeSAM 10 #define modeDRM 11 -#ifdef PSK -#define modePSK 12 -#define MODES 13 -#else #define MODES 12 -#endif char *mode_string[MODES]; diff --git a/new_discovery.c b/new_discovery.c index 45b2a60..d6c3d46 100644 --- a/new_discovery.c +++ b/new_discovery.c @@ -71,7 +71,6 @@ void new_discovery() { struct ifaddrs *addrs,*ifa; getifaddrs(&addrs); ifa = addrs; - while (ifa) { g_main_context_iteration(NULL, 0); if (ifa->ifa_addr) { diff --git a/new_menu.c b/new_menu.c index 9ce2c77..d354574 100644 --- a/new_menu.c +++ b/new_menu.c @@ -36,9 +36,6 @@ #include "oc_menu.h" #include "cw_menu.h" #include "store_menu.h" -#ifdef FREEDV -#include "freedv_menu.h" -#endif #include "xvtr_menu.h" #include "equalizer_menu.h" #include "radio.h" @@ -56,12 +53,11 @@ #include "tx_menu.h" #include "ps_menu.h" #include "encoder_menu.h" -#if defined (CONTROLLER2_V2) || defined (CONTROLLER2_V1) #include "switch_menu.h" -#endif #include "vfo_menu.h" #include "fft_menu.h" #include "main.h" +#include "gpio.h" static GtkWidget *menu_b=NULL; @@ -157,7 +153,6 @@ static gboolean rigctl_cb (GtkWidget *widget, GdkEventButton *event, gpointer da return TRUE; } -#ifdef GPIO static gboolean encoder_cb (GtkWidget *widget, GdkEventButton *event, gpointer data) { cleanup(); fprintf(stderr, "new_menu: calling encoder_menu\n"); @@ -165,15 +160,12 @@ static gboolean encoder_cb (GtkWidget *widget, GdkEventButton *event, gpointer d return TRUE; } -#if defined (CONTROLLER2_V2) || defined (CONTROLLER2_V1) static gboolean switch_cb (GtkWidget *widget, GdkEventButton *event, gpointer data) { cleanup(); fprintf(stderr, "new_menu: calling switch_menu\n"); switch_menu(top_window); return TRUE; } -#endif -#endif static gboolean cw_cb (GtkWidget *widget, GdkEventButton *event, gpointer data) { cleanup(); @@ -187,14 +179,6 @@ static gboolean oc_cb (GtkWidget *widget, GdkEventButton *event, gpointer data) return TRUE; } -#ifdef FREEDV -static gboolean freedv_cb (GtkWidget *widget, GdkEventButton *event, gpointer data) { - cleanup(); - freedv_menu(top_window); - return TRUE; -} -#endif - static gboolean xvtr_cb (GtkWidget *widget, GdkEventButton *event, gpointer data) { cleanup(); xvtr_menu(top_window); @@ -531,13 +515,6 @@ void new_menu() gtk_grid_attach(GTK_GRID(grid),oc_b,(i%5),i/5,1,1); i++; -#ifdef FREEDV - GtkWidget *freedv_b=gtk_button_new_with_label("FreeDV"); - g_signal_connect (freedv_b, "button-press-event", G_CALLBACK(freedv_cb), NULL); - gtk_grid_attach(GTK_GRID(grid),freedv_b,(i%5),i/5,1,1); - i++; -#endif - GtkWidget *display_b=gtk_button_new_with_label("Display"); g_signal_connect (display_b, "button-press-event", G_CALLBACK(display_cb), NULL); gtk_grid_attach(GTK_GRID(grid),display_b,(i%5),i/5,1,1); @@ -586,12 +563,12 @@ void new_menu() gtk_grid_attach(GTK_GRID(grid),encoders_b,(i%5),i/5,1,1); i++; -#if defined (CONTROLLER2_V2) || defined (CONTROLLER2_V1) - GtkWidget *switches_b=gtk_button_new_with_label("Switches"); - g_signal_connect (switches_b, "button-press-event", G_CALLBACK(switch_cb), NULL); - gtk_grid_attach(GTK_GRID(grid),switches_b,(i%5),i/5,1,1); - i++; -#endif + if(controller==CONTROLLER2_V1 || controller==CONTROLLER2_V2) { + GtkWidget *switches_b=gtk_button_new_with_label("Switches"); + g_signal_connect (switches_b, "button-press-event", G_CALLBACK(switch_cb), NULL); + gtk_grid_attach(GTK_GRID(grid),switches_b,(i%5),i/5,1,1); + i++; + } #endif // diff --git a/new_menu.h b/new_menu.h index 3983531..0d8bdc0 100644 --- a/new_menu.h +++ b/new_menu.h @@ -19,6 +19,9 @@ extern void start_store(); extern void start_rx(); extern void start_tx(); extern void start_diversity(); +#ifdef PURESIGNAL +extern void start_ps(); +#endif extern void encoder_step(int encoder,int step); diff --git a/new_protocol.c b/new_protocol.c index bcf293a..c679567 100644 --- a/new_protocol.c +++ b/new_protocol.c @@ -56,9 +56,6 @@ #include "signal.h" #include "vfo.h" #include "toolbar.h" -#ifdef FREEDV -#include "freedv.h" -#endif #include "vox.h" #include "ext.h" #include "iambic.h" @@ -201,11 +198,6 @@ static long audiosequence; static unsigned char audiobuffer[260]; // was 1444 static int audioindex; -#ifdef PSK -static int psk_samples=0; -static int psk_resample=6; // convert from 48000 to 8000 -#endif - // Use this to determine the source port of messages received static struct sockaddr_in addr; static socklen_t length=sizeof(addr); @@ -387,7 +379,7 @@ void update_action_table() { } break; default: - fprintf(stderr,"ACTION TABLE: case not handled: %d\n", flag); + g_print("ACTION TABLE: case not handled: %d\n", flag); break; } } @@ -397,7 +389,7 @@ void new_protocol_init(int pixels) { int rc; spectrumWIDTH=pixels; - fprintf(stderr,"new_protocol_init: MIC_SAMPLES=%d\n",MIC_SAMPLES); + g_print("new_protocol_init: MIC_SAMPLES=%d\n",MIC_SAMPLES); memset(rxcase , 0, MAX_DDC*sizeof(int)); memset(rxid , 0, MAX_DDC*sizeof(int)); @@ -412,7 +404,7 @@ void new_protocol_init(int pixels) { #ifdef OLD_AUDIO if(local_audio) { if(audio_open_output()!=0) { - fprintf(stderr,"audio_open_output failed\n"); + g_print("audio_open_output failed\n"); local_audio=0; } } @@ -420,7 +412,7 @@ void new_protocol_init(int pixels) { if(transmitter->local_microphone) { if(audio_open_input()!=0) { - fprintf(stderr,"audio_open_input failed\n"); + g_print("audio_open_input failed\n"); transmitter->local_microphone=0; } } @@ -452,10 +444,10 @@ void new_protocol_init(int pixels) { #endif command_response_thread_id = g_thread_new( "command_response thread",command_response_thread, NULL); if( ! command_response_thread_id ) { - fprintf(stderr,"g_thread_new failed on command_response_thread\n"); + g_print("g_thread_new failed on command_response_thread\n"); exit( -1 ); } - fprintf(stderr, "command_response_thread: id=%p\n",command_response_thread_id); + g_print( "command_response_thread: id=%p\n",command_response_thread_id); #ifdef __APPLE__ sem_unlink("HIGHREADY"); high_priority_sem_ready=sem_open("HIGHREADY", O_CREAT | O_EXCL, 0700, 0); @@ -469,10 +461,10 @@ void new_protocol_init(int pixels) { #endif high_priority_thread_id = g_thread_new( "high_priority thread", high_priority_thread, NULL); if( ! high_priority_thread_id ) { - fprintf(stderr,"g_thread_new failed on high_priority_thread\n"); + g_print("g_thread_new failed on high_priority_thread\n"); exit( -1 ); } - fprintf(stderr, "high_priority_thread: id=%p\n",high_priority_thread_id); + g_print( "high_priority_thread: id=%p\n",high_priority_thread_id); #ifdef __APPLE__ sem_unlink("MICREADY"); mic_line_sem_ready=sem_open("MICREADY", O_CREAT | O_EXCL, 0700, 0); @@ -486,10 +478,10 @@ void new_protocol_init(int pixels) { #endif mic_line_thread_id = g_thread_new( "mic_line thread", mic_line_thread, NULL); if( ! mic_line_thread_id ) { - fprintf(stderr,"g_thread_new failed on mic_line_thread\n"); + g_print("g_thread_new failed on mic_line_thread\n"); exit( -1 ); } - fprintf(stderr, "mic_line_thread: id=%p\n",mic_line_thread_id); + g_print( "mic_line_thread: id=%p\n",mic_line_thread_id); // // Spawn off one IQ reading thread for each DDC to be used @@ -503,14 +495,14 @@ void new_protocol_init(int pixels) { sem_unlink(sname); iq_sem_ready[i]=sem_open(sname, O_CREAT | O_EXCL, 0700, 0); if (iq_sem_ready[i] == SEM_FAILED) { - fprintf(stderr,"SEM=%s, ",sname); + g_print("SEM=%s, ",sname); perror("IQreadySemaphore"); } sprintf(sname,"IQBUF%03d", i); sem_unlink(sname); iq_sem_buffer[i]=sem_open(sname, O_CREAT| O_EXCL, 0700, 0); if (iq_sem_buffer[i] == SEM_FAILED) { - fprintf(stderr,"SEM=%s, ",sname); + g_print("SEM=%s, ",sname); perror("IQbufferSemaphore"); } #else @@ -522,7 +514,7 @@ void new_protocol_init(int pixels) { data_socket=socket(PF_INET,SOCK_DGRAM,IPPROTO_UDP); if(data_socket<0) { - fprintf(stderr,"NewProtocol: create socket failed for data_socket\n"); + g_print("NewProtocol: create socket failed for data_socket\n"); exit(-1); } @@ -532,44 +524,44 @@ void new_protocol_init(int pixels) { // bind to the interface if(bind(data_socket,(struct sockaddr*)&radio->info.network.interface_address,radio->info.network.interface_length)<0) { - fprintf(stderr,"metis: bind socket failed for data_socket\n"); + g_print("metis: bind socket failed for data_socket\n"); exit(-1); } -fprintf(stderr,"new_protocol_init: data_socket %d bound to interface %s:%d\n",data_socket,inet_ntoa(radio->info.network.interface_address.sin_addr),ntohs(radio->info.network.interface_address.sin_port)); +g_print("new_protocol_init: data_socket %d bound to interface %s:%d\n",data_socket,inet_ntoa(radio->info.network.interface_address.sin_addr),ntohs(radio->info.network.interface_address.sin_port)); memcpy(&base_addr,&radio->info.network.address,radio->info.network.address_length); base_addr_length=radio->info.network.address_length; base_addr.sin_port=htons(GENERAL_REGISTERS_FROM_HOST_PORT); -g_print("base_addr=%s\n",inet_ntoa(radio->info.network.address.sin_addr)); +//g_print("base_addr=%s\n",inet_ntoa(radio->info.network.address.sin_addr)); memcpy(&receiver_addr,&radio->info.network.address,radio->info.network.address_length); receiver_addr_length=radio->info.network.address_length; receiver_addr.sin_port=htons(RECEIVER_SPECIFIC_REGISTERS_FROM_HOST_PORT); -g_print("receive_addr=%s\n",inet_ntoa(radio->info.network.address.sin_addr)); +//g_print("receive_addr=%s\n",inet_ntoa(radio->info.network.address.sin_addr)); memcpy(&transmitter_addr,&radio->info.network.address,radio->info.network.address_length); transmitter_addr_length=radio->info.network.address_length; transmitter_addr.sin_port=htons(TRANSMITTER_SPECIFIC_REGISTERS_FROM_HOST_PORT); -g_print("transmit_addr=%s\n",inet_ntoa(radio->info.network.address.sin_addr)); +//g_print("transmit_addr=%s\n",inet_ntoa(radio->info.network.address.sin_addr)); memcpy(&high_priority_addr,&radio->info.network.address,radio->info.network.address_length); high_priority_addr_length=radio->info.network.address_length; high_priority_addr.sin_port=htons(HIGH_PRIORITY_FROM_HOST_PORT); -g_print("high_priority_addr=%s\n",inet_ntoa(radio->info.network.address.sin_addr)); +//g_print("high_priority_addr=%s\n",inet_ntoa(radio->info.network.address.sin_addr)); -fprintf(stderr,"new_protocol_thread: high_priority_addr setup for port %d\n",HIGH_PRIORITY_FROM_HOST_PORT); +//g_print("new_protocol_thread: high_priority_addr setup for port %d\n",HIGH_PRIORITY_FROM_HOST_PORT); memcpy(&audio_addr,&radio->info.network.address,radio->info.network.address_length); audio_addr_length=radio->info.network.address_length; audio_addr.sin_port=htons(AUDIO_FROM_HOST_PORT); -g_print("audio_addr=%s\n",inet_ntoa(radio->info.network.address.sin_addr)); +//g_print("audio_addr=%s\n",inet_ntoa(radio->info.network.address.sin_addr)); memcpy(&iq_addr,&radio->info.network.address,radio->info.network.address_length); iq_addr_length=radio->info.network.address_length; iq_addr.sin_port=htons(TX_IQ_FROM_HOST_PORT); -g_print("iq_addr=%s\n",inet_ntoa(radio->info.network.address.sin_addr)); +//g_print("iq_addr=%s\n",inet_ntoa(radio->info.network.address.sin_addr)); for(i=0;iinfo.network.address.sin_addr)); new_protocol_thread_id = g_thread_new( "new protocol", new_protocol_thread, NULL); if( ! new_protocol_thread_id ) { - fprintf(stderr,"g_thread_new failed on new_protocol_thread\n"); + g_print("g_thread_new failed on new_protocol_thread\n"); exit( -1 ); } - fprintf(stderr, "new_protocol_thread: id=%p\n",new_protocol_thread_id); + g_print( "new_protocol_thread: id=%p\n",new_protocol_thread_id); new_protocol_general(); new_protocol_start(); @@ -616,7 +608,7 @@ static void new_protocol_general() { general_buffer[58]=0x01; // enable PA } -// fprintf(stderr,"new_protocol_general: PA Enable=%02X\n",general_buffer[58]); +// g_print("new_protocol_general: PA Enable=%02X\n",general_buffer[58]); if(filter_board==APOLLO) { general_buffer[58]|=0x02; // enable APOLLO tuner @@ -630,16 +622,16 @@ static void new_protocol_general() { } } -//fprintf(stderr,"Alex Enable=%02X\n",general_buffer[59]); +//g_print("Alex Enable=%02X\n",general_buffer[59]); //g_print("new_protocol_general: %s:%d\n",inet_ntoa(base_addr.sin_addr),ntohs(base_addr.sin_port)); if((rc=sendto(data_socket,general_buffer,sizeof(general_buffer),0,(struct sockaddr*)&base_addr,base_addr_length))<0) { - fprintf(stderr,"sendto socket failed for general\n"); + g_print("sendto socket failed for general\n"); exit(1); } if(rc!=sizeof(general_buffer)) { - fprintf(stderr,"sendto socket for general: %d rather than %ld",rc,(long)sizeof(general_buffer)); + g_print("sendto socket for general: %d rather than %ld",rc,(long)sizeof(general_buffer)); } general_sequence++; @@ -667,7 +659,6 @@ static void new_protocol_high_priority() { high_priority_buffer_to_radio[1]=high_priority_sequence>>16; high_priority_buffer_to_radio[2]=high_priority_sequence>>8; high_priority_buffer_to_radio[3]=high_priority_sequence; - high_priority_buffer_to_radio[4]=running; // // We need not set PTT of doing internal CW with break-in @@ -1024,7 +1015,7 @@ static void new_protocol_high_priority() { // Out of paranoia: print warning and choose ANT1 // if (i<0 || i>2) { - fprintf(stderr,"WARNING: illegal TX antenna chosen, using ANT1\n"); + g_print("WARNING: illegal TX antenna chosen, using ANT1\n"); transmitter->alex_antenna=0; i=0; } @@ -1052,7 +1043,7 @@ static void new_protocol_high_priority() { high_priority_buffer_to_radio[1434]=(alex0>>8)&0xFF; high_priority_buffer_to_radio[1435]=alex0&0xFF; -//fprintf(stderr,"ALEX0 bits: %02X %02X %02X %02X for rx=%lld tx=%lld\n",high_priority_buffer_to_radio[1432],high_priority_buffer_to_radio[1433],high_priority_buffer_to_radio[1434],high_priority_buffer_to_radio[1435],rxFrequency,txFrequency); +//g_print("ALEX0 bits: %02X %02X %02X %02X for rx=%lld tx=%lld\n",high_priority_buffer_to_radio[1432],high_priority_buffer_to_radio[1433],high_priority_buffer_to_radio[1434],high_priority_buffer_to_radio[1435],rxFrequency,txFrequency); // // Orion2 boards: set RX2 filters according ro VFOB frequency @@ -1096,7 +1087,7 @@ static void new_protocol_high_priority() { high_priority_buffer_to_radio[1430]=(alex1>>8)&0xFF; high_priority_buffer_to_radio[1431]=alex1&0xFF; -//fprintf(stderr,"ALEX1 bits: rx1: %02X %02X for rx=%lld\n",high_priority_buffer_to_radio[1430],high_priority_buffer_to_radio[1431],rxFrequency); +//g_print("ALEX1 bits: rx1: %02X %02X for rx=%lld\n",high_priority_buffer_to_radio[1430],high_priority_buffer_to_radio[1431],rxFrequency); } @@ -1124,13 +1115,13 @@ static void new_protocol_high_priority() { //g_print("new_protocol_high_priority: %s:%d\n",inet_ntoa(high_priority_addr.sin_addr),ntohs(high_priority_addr.sin_port)); int rc; if((rc=sendto(data_socket,high_priority_buffer_to_radio,sizeof(high_priority_buffer_to_radio),0,(struct sockaddr*)&high_priority_addr,high_priority_addr_length))<0) { - fprintf(stderr,"sendto socket failed for high priority: rc=%d errno=%d\n",rc,errno); + g_print("sendto socket failed for high priority: rc=%d errno=%d\n",rc,errno); abort(); //exit(1); } if(rc!=sizeof(high_priority_buffer_to_radio)) { - fprintf(stderr,"sendto socket for high_priority: %d rather than %ld",rc,(long)sizeof(high_priority_buffer_to_radio)); + g_print("sendto socket for high_priority: %d rather than %ld",rc,(long)sizeof(high_priority_buffer_to_radio)); } high_priority_sequence++; @@ -1138,7 +1129,7 @@ static void new_protocol_high_priority() { pthread_mutex_unlock(&hi_prio_mutex); } -static unsigned char last_50=0; // debug code +static unsigned char last_50=0; static void new_protocol_transmit_specific() { int txmode=get_tx_mode(); @@ -1206,10 +1197,10 @@ static void new_protocol_transmit_specific() { transmit_specific_buffer[50]|=0x10; } - if(last_50!=transmit_specific_buffer[50]) { //debug - last_50=transmit_specific_buffer[50]; //debug -//fprintf(stderr,"tx_specific: 50=%02X\n",transmit_specific_buffer[50]);//debug - } //debug + if(last_50!=transmit_specific_buffer[50]) { + last_50=transmit_specific_buffer[50]; +//g_print("tx_specific: 50=%02X\n",transmit_specific_buffer[50]); + } // 0..31 transmit_specific_buffer[51]=linein_gain; @@ -1220,12 +1211,12 @@ static void new_protocol_transmit_specific() { //g_print("new_protocol_transmit_specific: %s:%d\n",inet_ntoa(transmitter_addr.sin_addr),ntohs(transmitter_addr.sin_port)); if((rc=sendto(data_socket,transmit_specific_buffer,sizeof(transmit_specific_buffer),0,(struct sockaddr*)&transmitter_addr,transmitter_addr_length))<0) { - fprintf(stderr,"sendto socket failed for tx specific: %d\n",rc); + g_print("sendto socket failed for tx specific: %d\n",rc); exit(1); } if(rc!=sizeof(transmit_specific_buffer)) { - fprintf(stderr,"sendto socket for transmit_specific: %d rather than %ld",rc,(long)sizeof(transmit_specific_buffer)); + g_print("sendto socket for transmit_specific: %d rather than %ld",rc,(long)sizeof(transmit_specific_buffer)); } tx_specific_sequence++; @@ -1320,12 +1311,12 @@ static void new_protocol_receive_specific() { //g_print("new_protocol_receive_specific: %s:%d enable=%02X\n",inet_ntoa(receiver_addr.sin_addr),ntohs(receiver_addr.sin_port),receive_specific_buffer[7]); if((rc=sendto(data_socket,receive_specific_buffer,sizeof(receive_specific_buffer),0,(struct sockaddr*)&receiver_addr,receiver_addr_length))<0) { - fprintf(stderr,"sendto socket failed for receive_specific: %d\n",rc); + g_print("sendto socket failed for receive_specific: %d\n",rc); exit(1); } if(rc!=sizeof(receive_specific_buffer)) { - fprintf(stderr,"sendto socket for receive_specific: %d rather than %ld",rc,(long)sizeof(receive_specific_buffer)); + g_print("sendto socket for receive_specific: %d rather than %ld",rc,(long)sizeof(receive_specific_buffer)); } rx_specific_sequence++; @@ -1339,10 +1330,10 @@ static void new_protocol_start() { new_protocol_timer_thread_id = g_thread_new( "new protocol timer", new_protocol_timer_thread, NULL); if( ! new_protocol_timer_thread_id ) { - fprintf(stderr,"g_thread_new failed on new_protocol_timer_thread\n"); + g_print("g_thread_new failed on new_protocol_timer_thread\n"); exit( -1 ); } - fprintf(stderr, "new_protocol_timer_thread: id=%p\n",new_protocol_timer_thread_id); + g_print( "new_protocol_timer_thread: id=%p\n",new_protocol_timer_thread_id); } @@ -1372,7 +1363,7 @@ static gpointer new_protocol_thread(gpointer data) { unsigned char *buffer; int bytesread; -fprintf(stderr,"new_protocol_thread\n"); +g_print("new_protocol_thread\n"); micsamples=0; iqindex=4; @@ -1387,7 +1378,7 @@ fprintf(stderr,"new_protocol_thread\n"); buffer=malloc(NET_BUFFER_SIZE); bytesread=recvfrom(data_socket,buffer,NET_BUFFER_SIZE,0,(struct sockaddr*)&addr,&length); if(bytesread<0) { - fprintf(stderr,"recvfrom socket failed for new_protocol_thread"); + g_print("recvfrom socket failed for new_protocol_thread"); exit(-1); } @@ -1407,7 +1398,7 @@ fprintf(stderr,"new_protocol_thread\n"); ddc=sourceport-RX_IQ_TO_HOST_PORT_0; //g_print("iq packet from port=%d ddc=%d\n",sourceport,ddc); if(ddc>=MAX_DDC) { - fprintf(stderr,"unexpected iq data from ddc %d\n",ddc); + g_print("unexpected iq data from ddc %d\n",ddc); } else { #ifdef __APPLE__ sem_wait(iq_sem_ready[ddc]); @@ -1465,7 +1456,7 @@ fprintf(stderr,"new_protocol_thread\n"); #endif break; default: -fprintf(stderr,"new_protocol_thread: Unknown port %d\n",sourceport); +g_print("new_protocol_thread: Unknown port %d\n",sourceport); free(buffer); break; } @@ -1475,7 +1466,7 @@ fprintf(stderr,"new_protocol_thread: Unknown port %d\n",sourceport); } static gpointer command_response_thread(gpointer data) { - fprintf(stderr,"command_response_thread\n"); + g_print("command_response_thread\n"); while(1) { #ifdef __APPLE__ sem_post(command_response_sem_ready); @@ -1490,7 +1481,7 @@ static gpointer command_response_thread(gpointer data) { } static gpointer high_priority_thread(gpointer data) { -fprintf(stderr,"high_priority_thread\n"); +g_print("high_priority_thread\n"); while(1) { #ifdef __APPLE__ sem_post(high_priority_sem_ready); @@ -1505,7 +1496,7 @@ fprintf(stderr,"high_priority_thread\n"); } static gpointer mic_line_thread(gpointer data) { -fprintf(stderr,"mic_line_thread\n"); +g_print("mic_line_thread\n"); while(1) { #ifdef __APPLE__ sem_post(mic_line_sem_ready); @@ -1527,7 +1518,7 @@ static gpointer iq_thread(gpointer data) { int ddc=GPOINTER_TO_INT(data); long sequence; unsigned char *buffer; - fprintf(stderr,"iq_thread: ddc=%d\n",ddc); + g_print("iq_thread: ddc=%d\n",ddc); while(1) { #ifdef __APPLE__ sem_post(iq_sem_ready[ddc]); @@ -1543,7 +1534,7 @@ static gpointer iq_thread(gpointer data) { // sequence=((buffer[0]&0xFF)<<24)+((buffer[1]&0xFF)<<16)+((buffer[2]&0xFF)<<8)+(buffer[3]&0xFF); if(ddc_sequence[ddc] !=sequence) { - fprintf(stderr,"DDC %d sequence error: expected %ld got %ld\n",ddc,ddc_sequence[ddc],sequence); + g_print("DDC %d sequence error: expected %ld got %ld\n",ddc,ddc_sequence[ddc],sequence); ddc_sequence[ddc]=sequence; } ddc_sequence[ddc]++; @@ -1699,7 +1690,7 @@ static void process_ps_iq_data(unsigned char *buffer) { bitspersample=((buffer[12]&0xFF)<<8)+(buffer[13]&0xFF); // used in debug code samplesperframe=((buffer[14]&0xFF)<<8)+(buffer[15]&0xFF); -//fprintf(stderr,"process_ps_iq_data: bitspersample=%d samplesperframe=%d\n", bitspersample,samplesperframe); +//g_print("process_ps_iq_data: bitspersample=%d samplesperframe=%d\n", bitspersample,samplesperframe); b=16; int i; for(i=0;ilocal_microphone ? audio_get_next_mic_sample() : (float) sample * 0.00003051; -#ifdef FREEDV - if(active_receiver->freedv) { - add_freedv_mic_sample(transmitter,fsample); - } else { -#endif - add_mic_sample(transmitter,fsample); -#ifdef FREEDV - } -#endif + add_mic_sample(transmitter,fsample); } } @@ -1847,7 +1830,7 @@ void new_protocol_cw_audio_samples(short left_audio_sample,short right_audio_sam rc=sendto(data_socket,audiobuffer,sizeof(audiobuffer),0,(struct sockaddr*)&audio_addr,audio_addr_length); if(rc!=sizeof(audiobuffer)) { - fprintf(stderr,"sendto socket failed for %ld bytes of audio: %d\n",(long)sizeof(audiobuffer),rc); + g_print("sendto socket failed for %ld bytes of audio: %d\n",(long)sizeof(audiobuffer),rc); } audioindex=4; audiosequence++; @@ -1881,7 +1864,7 @@ void new_protocol_audio_samples(RECEIVER *rx,short left_audio_sample,short right rc=sendto(data_socket,audiobuffer,sizeof(audiobuffer),0,(struct sockaddr*)&audio_addr,audio_addr_length); if(rc!=sizeof(audiobuffer)) { - fprintf(stderr,"sendto socket failed for %ld bytes of audio: %d\n",(long)sizeof(audiobuffer),rc); + g_print("sendto socket failed for %ld bytes of audio: %d\n",(long)sizeof(audiobuffer),rc); } audioindex=4; audiosequence++; @@ -1904,7 +1887,7 @@ void new_protocol_flush_iq_samples() { // send the buffer if(sendto(data_socket,iqbuffer,sizeof(iqbuffer),0,(struct sockaddr*)&iq_addr,iq_addr_length)<0) { - fprintf(stderr,"sendto socket failed for iq\n"); + g_print("sendto socket failed for iq\n"); exit(1); } iqindex=4; @@ -1927,7 +1910,7 @@ void new_protocol_iq_samples(int isample,int qsample) { // send the buffer if(sendto(data_socket,iqbuffer,sizeof(iqbuffer),0,(struct sockaddr*)&iq_addr,iq_addr_length)<0) { - fprintf(stderr,"sendto socket failed for iq\n"); + g_print("sendto socket failed for iq\n"); exit(1); } iqindex=4; diff --git a/oc_menu.c b/oc_menu.c index 2cbb610..6ae650d 100644 --- a/oc_menu.c +++ b/oc_menu.c @@ -140,30 +140,35 @@ void oc_menu(GtkWidget *parent) { g_signal_connect (close_b, "pressed", G_CALLBACK(close_cb), NULL); gtk_grid_attach(GTK_GRID(grid),close_b,0,0,1,1); - GtkWidget *band_title=gtk_label_new("Band"); + GtkWidget *band_title=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(band_title), "Band"); //gtk_widget_override_font(band_title, pango_font_description_from_string("Arial 18")); gtk_widget_show(band_title); gtk_grid_attach(GTK_GRID(grid),band_title,0,1,1,1); - GtkWidget *rx_title=gtk_label_new("Rx"); + GtkWidget *rx_title=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(rx_title), "Rx"); //gtk_widget_override_font(rx_title, pango_font_description_from_string("Arial 18")); gtk_widget_show(rx_title); gtk_grid_attach(GTK_GRID(grid),rx_title,4,1,1,1); - GtkWidget *tx_title=gtk_label_new("Tx"); + GtkWidget *tx_title=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(tx_title), "Tx"); //gtk_widget_override_font(tx_title, pango_font_description_from_string("Arial 18")); gtk_widget_show(tx_title); gtk_grid_attach(GTK_GRID(grid),tx_title,11,1,1,1); - GtkWidget *tune_title=gtk_label_new("Tune (ORed with TX)"); + GtkWidget *tune_title=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(tune_title), "Tune (ORed with TX)"); //gtk_widget_override_font(tune_title, pango_font_description_from_string("Arial 18")); gtk_widget_show(tune_title); gtk_grid_attach(GTK_GRID(grid),tune_title,18,1,2,1); for(i=1;i<8;i++) { - char oc_id[8]; - sprintf(oc_id,"%d",i); - GtkWidget *oc_rx_title=gtk_label_new(oc_id); + char oc_id[16]; + sprintf(oc_id,"%d",i); + GtkWidget *oc_rx_title=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(oc_rx_title), oc_id); //gtk_widget_override_font(oc_rx_title, pango_font_description_from_string("Arial 18")); gtk_widget_show(oc_rx_title); gtk_grid_attach(GTK_GRID(grid),oc_rx_title,i,2,1,1); @@ -173,33 +178,95 @@ void oc_menu(GtkWidget *parent) { gtk_grid_attach(GTK_GRID(grid),oc_tx_title,i+7,2,1,1); } - for(i=0;ititle)>0) { - GtkWidget *band_label=gtk_label_new(band->title); - //gtk_widget_override_font(band_label, pango_font_description_from_string("Arial 18")); - gtk_widget_show(band_label); - gtk_grid_attach(GTK_GRID(grid),band_label,0,i+3,1,1); - - int mask; - for(j=1;j<8;j++) { - mask=0x01<<(j-1); - GtkWidget *oc_rx_b=gtk_check_button_new(); - //gtk_widget_override_font(oc_rx_b, pango_font_description_from_string("Arial 18")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (oc_rx_b), (band->OCrx&mask)==mask); - gtk_widget_show(oc_rx_b); - gtk_grid_attach(GTK_GRID(grid),oc_rx_b,j,i+3,1,1); - g_signal_connect(oc_rx_b,"toggled",G_CALLBACK(oc_rx_cb),(gpointer)(long)(j+(i<<4))); - - GtkWidget *oc_tx_b=gtk_check_button_new(); - //gtk_widget_override_font(oc_tx_b, pango_font_description_from_string("Arial 18")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (oc_tx_b), (band->OCtx&mask)==mask); - gtk_widget_show(oc_tx_b); - gtk_grid_attach(GTK_GRID(grid),oc_tx_b,j+7,i+3,1,1); - g_signal_connect(oc_tx_b,"toggled",G_CALLBACK(oc_tx_cb),(gpointer)(long)(j+(i<<4))); - + GtkWidget *band_label=gtk_label_new(NULL); + char band_text[16]; + sprintf(band_text,"%s",band->title); + gtk_label_set_markup(GTK_LABEL(band_label), band_text); + //gtk_widget_override_font(band_label, pango_font_description_from_string("Arial 18")); + gtk_widget_show(band_label); + gtk_grid_attach(GTK_GRID(grid),band_label,0,row,1,1); + + int mask; + for(j=1;j<8;j++) { + mask=0x01<<(j-1); + GtkWidget *oc_rx_b=gtk_check_button_new(); + //gtk_widget_override_font(oc_rx_b, pango_font_description_from_string("Arial 18")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (oc_rx_b), (band->OCrx&mask)==mask); + gtk_widget_show(oc_rx_b); + gtk_grid_attach(GTK_GRID(grid),oc_rx_b,j,row,1,1); + g_signal_connect(oc_rx_b,"toggled",G_CALLBACK(oc_rx_cb),(gpointer)(long)(j+(i<<4))); + + GtkWidget *oc_tx_b=gtk_check_button_new(); + //gtk_widget_override_font(oc_tx_b, pango_font_description_from_string("Arial 18")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (oc_tx_b), (band->OCtx&mask)==mask); + gtk_widget_show(oc_tx_b); + gtk_grid_attach(GTK_GRID(grid),oc_tx_b,j+7,row,1,1); + g_signal_connect(oc_tx_b,"toggled",G_CALLBACK(oc_tx_cb),(gpointer)(long)(j+(i<<4))); + + } + row++; } } + + for(i=BANDS;ititle)>0) { + GtkWidget *band_label=gtk_label_new(band->title); + //gtk_widget_override_font(band_label, pango_font_description_from_string("Arial 18")); + gtk_widget_show(band_label); + gtk_grid_attach(GTK_GRID(grid),band_label,0,row,1,1); + + int mask; + for(j=1;j<8;j++) { + mask=0x01<<(j-1); + GtkWidget *oc_rx_b=gtk_check_button_new(); + //gtk_widget_override_font(oc_rx_b, pango_font_description_from_string("Arial 18")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (oc_rx_b), (band->OCrx&mask)==mask); + gtk_widget_show(oc_rx_b); + gtk_grid_attach(GTK_GRID(grid),oc_rx_b,j,row,1,1); + g_signal_connect(oc_rx_b,"toggled",G_CALLBACK(oc_rx_cb),(gpointer)(long)(j+(i<<4))); + + GtkWidget *oc_tx_b=gtk_check_button_new(); + //gtk_widget_override_font(oc_tx_b, pango_font_description_from_string("Arial 18")); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (oc_tx_b), (band->OCtx&mask)==mask); + gtk_widget_show(oc_tx_b); + gtk_grid_attach(GTK_GRID(grid),oc_tx_b,j+7,row,1,1); + g_signal_connect(oc_tx_b,"toggled",G_CALLBACK(oc_tx_cb),(gpointer)(long)(j+(i<<4))); + + } + row++; + } } int mask; @@ -220,7 +287,8 @@ void oc_menu(GtkWidget *parent) { g_signal_connect(oc_tune_b,"toggled",G_CALLBACK(oc_tune_cb),(gpointer)(long)j); } - GtkWidget *oc_full_tune_time_title=gtk_label_new("Full Tune(ms):"); + GtkWidget *oc_full_tune_time_title=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(oc_full_tune_time_title), "Full Tune(ms):"); //gtk_widget_override_font(oc_full_tune_time_title, pango_font_description_from_string("Arial 18")); gtk_widget_show(oc_full_tune_time_title); gtk_grid_attach(GTK_GRID(grid),oc_full_tune_time_title,18,j+1,2,1); @@ -234,7 +302,8 @@ void oc_menu(GtkWidget *parent) { g_signal_connect(oc_full_tune_time_b,"value_changed",G_CALLBACK(oc_full_tune_time_cb),NULL); j++; - GtkWidget *oc_memory_tune_time_title=gtk_label_new("Memory Tune(ms):"); + GtkWidget *oc_memory_tune_time_title=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(oc_memory_tune_time_title), "Memory Tune(ms):"); //gtk_widget_override_font(oc_memory_tune_time_title, pango_font_description_from_string("Arial 18")); gtk_widget_show(oc_memory_tune_time_title); gtk_grid_attach(GTK_GRID(grid),oc_memory_tune_time_title,18,j+1,2,1); diff --git a/old_discovery.c b/old_discovery.c index 694053b..f28e313 100644 --- a/old_discovery.c +++ b/old_discovery.c @@ -515,20 +515,22 @@ void old_discovery() { fprintf(stderr,"old_discovery\n"); getifaddrs(&addrs); ifa = addrs; - while (ifa) { g_main_context_iteration(NULL, 0); - if (ifa->ifa_addr) { - if(ifa->ifa_addr->sa_family == AF_INET && - (ifa->ifa_flags&IFF_UP)==IFF_UP && - (ifa->ifa_flags&IFF_RUNNING)==IFF_RUNNING) { - discover(ifa); - } + if (ifa->ifa_addr && ifa->ifa_addr->sa_family == AF_INET) { + if((ifa->ifa_flags&IFF_UP)==IFF_UP + && (ifa->ifa_flags&IFF_RUNNING)==IFF_RUNNING) { + //&& (ifa->ifa_flags&IFF_LOOPBACK)!=IFF_LOOPBACK) { + discover(ifa); + } } ifa = ifa->ifa_next; } freeifaddrs(addrs); + // Do one additional "discover" for a fixed TCP address + discover(NULL); + fprintf(stderr, "discovery found %d devices\n",devices); int i; diff --git a/old_protocol.c b/old_protocol.c index 1c20de6..1ed2aae 100644 --- a/old_protocol.c +++ b/old_protocol.c @@ -49,12 +49,6 @@ #include "signal.h" #include "toolbar.h" #include "vfo.h" -#ifdef FREEDV -#include "freedv.h" -#endif -#ifdef PSK -#include "psk.h" -#endif #include "ext.h" #include "iambic.h" #include "error_handler.h" @@ -165,13 +159,6 @@ static int current_rx=0; static int samples=0; static int mic_samples=0; static int mic_sample_divisor=1; -#ifdef FREEDV -static int freedv_divisor=6; -#endif -#ifdef PSK -static int psk_samples=0; -static int psk_divisor=6; -#endif static int local_ptt=0; static int dash=0; @@ -266,13 +253,13 @@ void old_protocol_set_mic_sample_rate(int rate) { void old_protocol_init(int rx,int pixels,int rate) { int i; - fprintf(stderr,"old_protocol_init: num_hpsdr_receivers=%d\n",how_many_receivers()); + g_print("old_protocol_init: num_hpsdr_receivers=%d\n",how_many_receivers()); old_protocol_set_mic_sample_rate(rate); if(transmitter->local_microphone) { if(audio_open_input()!=0) { - fprintf(stderr,"audio_open_input failed\n"); + g_print("audio_open_input failed\n"); transmitter->local_microphone=0; } } @@ -284,14 +271,14 @@ void old_protocol_init(int rx,int pixels,int rate) { // if we have a USB interfaced Ozy device: // if (device == DEVICE_OZY) { - fprintf(stderr,"old_protocol_init: initialise ozy on USB\n"); + g_print("old_protocol_init: initialise ozy on USB\n"); ozy_initialise(); start_usb_receive_threads(); } else #endif { - fprintf(stderr,"old_protocol starting receive thread: buffer_size=%d output_buffer_size=%d\n",buffer_size,output_buffer_size); + g_print("old_protocol starting receive thread: buffer_size=%d output_buffer_size=%d\n",buffer_size,output_buffer_size); if (radio->use_tcp) { open_tcp_socket(); } else { @@ -300,14 +287,14 @@ void old_protocol_init(int rx,int pixels,int rate) { receive_thread_id = g_thread_new( "old protocol", receive_thread, NULL); if( ! receive_thread_id ) { - fprintf(stderr,"g_thread_new failed on receive_thread\n"); + g_print("g_thread_new failed on receive_thread\n"); exit( -1 ); } - fprintf(stderr, "receive_thread: id=%p\n",receive_thread_id); + g_print( "receive_thread: id=%p\n",receive_thread_id); } - fprintf(stderr,"old_protocol_init: prime radio\n"); + g_print("old_protocol_init: prime radio\n"); for(i=8;iinfo.network.interface_address.sin_addr),ntohs(radio->info.network.interface_address.sin_port)); if(bind(tmp,(struct sockaddr*)&radio->info.network.interface_address,radio->info.network.interface_length)<0) { perror("old_protocol: bind socket failed for data_socket\n"); exit(-1); @@ -433,7 +422,7 @@ static void open_udp_socket() { memcpy(&data_addr,&radio->info.network.address,radio->info.network.address_length); data_addr.sin_port=htons(DATA_PORT); data_socket=tmp; - fprintf(stderr,"UDP socket established: %d\n", data_socket); + g_print("UDP socket established: %d\n", data_socket); } static void open_tcp_socket() { @@ -448,7 +437,7 @@ static void open_tcp_socket() { memcpy(&data_addr,&radio->info.network.address,radio->info.network.address_length); data_addr.sin_port=htons(DATA_PORT); data_addr.sin_family = AF_INET; - fprintf(stderr,"Trying to open TCP connection to %s\n", inet_ntoa(radio->info.network.address.sin_addr)); + g_print("Trying to open TCP connection to %s\n", inet_ntoa(radio->info.network.address.sin_addr)); tmp=socket(AF_INET, SOCK_STREAM, 0); if (tmp < 0) { @@ -473,7 +462,7 @@ static void open_tcp_socket() { perror("tcp_socket: SO_RCVBUF"); } tcp_socket=tmp; - fprintf(stderr,"TCP socket established: %d\n", tcp_socket); + g_print("TCP socket established: %d\n", tcp_socket); } static gpointer receive_thread(gpointer arg) { @@ -485,7 +474,7 @@ static gpointer receive_thread(gpointer arg) { int ep; uint32_t sequence; - fprintf(stderr, "old_protocol: receive_thread\n"); + g_print( "old_protocol: receive_thread\n"); running=1; length=sizeof(addr); @@ -542,7 +531,7 @@ static gpointer receive_thread(gpointer arg) { // A sequence error with a seqnum of zero usually indicates a METIS restart // and is no error condition if (sequence != 0 && sequence != last_seq_num+1) { - fprintf(stderr,"SEQ ERROR: last %ld, recvd %ld\n", (long) last_seq_num, (long) sequence); + g_print("SEQ ERROR: last %ld, recvd %ld\n", (long) last_seq_num, (long) sequence); } last_seq_num=sequence; switch(ep) { @@ -567,19 +556,19 @@ static gpointer receive_thread(gpointer arg) { */ break; default: - fprintf(stderr,"unexpected EP %d length=%d\n",ep,bytes_read); + g_print("unexpected EP %d length=%d\n",ep,bytes_read); break; } break; case 2: // response to a discovery packet - fprintf(stderr,"unexepected discovery response when not in discovery mode\n"); + g_print("unexepected discovery response when not in discovery mode\n"); break; default: - fprintf(stderr,"unexpected packet type: 0x%02X\n",buffer[2]); + g_print("unexpected packet type: 0x%02X\n",buffer[2]); break; } } else { - fprintf(stderr,"received bad header bytes on data port %02X,%02X\n",buffer[0],buffer[1]); + g_print("received bad header bytes on data port %02X,%02X\n",buffer[0],buffer[1]); } break; } @@ -699,7 +688,6 @@ static long long channel_freq(int chan) { vfonum=-1; break; } - // // Radios with small FPGAs use RX1/RX2 for feedback while transmitting, // if (isTransmitting() && transmitter->puresignal && (chan == rx_feedback_channel() || chan == tx_feedback_channel())) { @@ -778,7 +766,7 @@ static int how_many_receivers() { } } #endif - return ret; + return ret; } static void process_ozy_input_buffer(unsigned char *buffer) { @@ -856,15 +844,15 @@ static void process_ozy_input_buffer(unsigned char *buffer) { IO3=(control_in[1]&0x08)?0:1; if(mercury_software_version!=control_in[2]) { mercury_software_version=control_in[2]; - fprintf(stderr," Mercury Software version: %d (0x%0X)\n",mercury_software_version,mercury_software_version); + g_print(" Mercury Software version: %d (0x%0X)\n",mercury_software_version,mercury_software_version); } if(penelope_software_version!=control_in[3]) { penelope_software_version=control_in[3]; - fprintf(stderr," Penelope Software version: %d (0x%0X)\n",penelope_software_version,penelope_software_version); + g_print(" Penelope Software version: %d (0x%0X)\n",penelope_software_version,penelope_software_version); } if(ozy_software_version!=control_in[4]) { ozy_software_version=control_in[4]; - fprintf(stderr,"FPGA firmware version: %d.%d\n",ozy_software_version/10,ozy_software_version%10); + g_print("FPGA firmware version: %d.%d\n",ozy_software_version/10,ozy_software_version%10); } break; case 1: @@ -953,15 +941,7 @@ static void process_ozy_input_buffer(unsigned char *buffer) { mic_samples++; if(mic_samples>=mic_sample_divisor) { // reduce to 48000 fsample = transmitter->local_microphone ? audio_get_next_mic_sample() : (float) mic_sample * 0.00003051; -#ifdef FREEDV - if(active_receiver->freedv) { - add_freedv_mic_sample(transmitter,fsample); - } else { -#endif - add_mic_sample(transmitter,fsample); -#ifdef FREEDV - } -#endif + add_mic_sample(transmitter,fsample); mic_samples=0; } @@ -972,7 +952,7 @@ static void process_ozy_input_buffer(unsigned char *buffer) { time(&t); gmt=gmtime(&t); - fprintf(stderr,"%s: process_ozy_input_buffer: did not find sync: restarting\n", + g_print("%s: process_ozy_input_buffer: did not find sync: restarting\n", asctime(gmt)); @@ -1221,7 +1201,7 @@ void ozy_send_buffer() { // Out of paranoia: print warning and choose ANT1 // if (i<0 || i>2) { - fprintf(stderr,"WARNING: illegal TX antenna chosen, using ANT1\n"); + g_print("WARNING: illegal TX antenna chosen, using ANT1\n"); transmitter->alex_antenna=0; i=0; } @@ -1287,6 +1267,7 @@ void ozy_send_buffer() { { BAND *band=band_get_current_band(); int power=0; +static int last_power=0; // // Some HPSDR apps for the RedPitaya generate CW inside the FPGA, but while // doing this, DriveLevel changes are processed by the server, but do not become effective. @@ -1304,7 +1285,14 @@ void ozy_send_buffer() { power=transmitter->drive_level; } } - + +if(last_power!=power) { + g_print("power=%d\n",power); + last_power=power; +} + + + output_buffer[C0]=0x12; output_buffer[C1]=power&0xFF; output_buffer[C2]=0x00; @@ -1316,12 +1304,15 @@ void ozy_send_buffer() { if(mic_linein) { output_buffer[C2]|=0x02; } - if(filter_board==APOLLO) { + if(filter_board==APOLLO || device==DEVICE_HERMES_LITE2) { output_buffer[C2]|=0x2C; } if((filter_board==APOLLO) && tune) { output_buffer[C2]|=0x10; } + if((device==DEVICE_HERMES_LITE2) && pa_enabled) { + output_buffer[C2]|=0x10; // Enable PA + } if(band_get_current()==band6) { output_buffer[C3]=output_buffer[C3]|0x40; // Alex 6M low noise amplifier } @@ -1409,7 +1400,7 @@ void ozy_send_buffer() { // to behave differently and stores bit5 of the gain in the // dither bit (see above) and a 5-bit attenuation value here. // - int rxgain = rx_gain_calibration - adc_attenuation[active_receiver->adc]; + int rxgain = - adc_attenuation[active_receiver->adc]+12; // -12..48 to 0..60 if (rxgain < 0) rxgain=0; if (rxgain > 60) rxgain=60; // encode all 6 bits of RXgain in ATT value and set bit6 @@ -1551,7 +1542,7 @@ void ozy_send_buffer() { * ship out line after each complete run */ if (proto_mod && command == 1) { - fprintf(stderr,"DIS=%d DRIVE=%3d PTT=%d i1=%4d RXout=%d RXant=%d i2=%d TXrel=%d FB=%d BP=%d LNA=%d HPF=%02x LPF=%02x\n", + g_print("DIS=%d DRIVE=%3d PTT=%d i1=%4d RXout=%d RXant=%d i2=%d TXrel=%d FB=%d BP=%d LNA=%d HPF=%02x LPF=%02x\n", C3_TXDIS, C1_DRIVE, PC_PTT, CASE1, C3_RX1_OUT, C3_RX1_ANT, CASE2, C4_TX_REL, C2_FB, C3_BP, C3_LNA, C3_HPF, C4_LPF); proto_mod=0; @@ -1569,7 +1560,7 @@ void ozy_send_buffer() { #endif metis_write(0x02,output_buffer,OZY_BUFFER_SIZE); - //fprintf(stderr,"C0=%02X C1=%02X C2=%02X C3=%02X C4=%02X\n", + //g_print("C0=%02X C1=%02X C2=%02X C3=%02X C4=%02X\n", // output_buffer[C0],output_buffer[C1],output_buffer[C2],output_buffer[C3],output_buffer[C4]); } @@ -1682,7 +1673,7 @@ static void metis_restart() { ozy_send_buffer(); } - usleep(250000L); + usleep(250000); // start the data flowing metis_start_stop(1); @@ -1735,7 +1726,7 @@ static void metis_start_stop(int command) { tcp_socket=-1; usleep(100000); // give some time to swallow incoming TCP packets close(tmp); - fprintf(stderr,"TCP socket closed\n"); + g_print("TCP socket closed\n"); } #ifdef USBOZY @@ -1751,7 +1742,7 @@ static void metis_send_buffer(unsigned char* buffer,int length) { if (tcp_socket >= 0) { if (length != 1032) { - fprintf(stderr,"PROGRAMMING ERROR: TCP LENGTH != 1032\n"); + g_print("PROGRAMMING ERROR: TCP LENGTH != 1032\n"); exit(-1); } if(sendto(tcp_socket,buffer,length,0,NULL, 0) != length) { @@ -1763,7 +1754,7 @@ static void metis_send_buffer(unsigned char* buffer,int length) { } } else { // This should not happen - fprintf(stderr,"METIS send: neither UDP nor TCP socket available!\n"); + g_print("METIS send: neither UDP nor TCP socket available!\n"); exit(-1); } } diff --git a/pa_menu.c b/pa_menu.c index f9601ed..868ec19 100644 --- a/pa_menu.c +++ b/pa_menu.c @@ -34,6 +34,8 @@ static GtkWidget *menu_b=NULL; static GtkWidget *dialog=NULL; +static GtkWidget *grid2; + static void cleanup() { if(dialog!=NULL) { gtk_widget_destroy(dialog); @@ -67,6 +69,94 @@ static void tx_out_of_band_cb(GtkWidget *widget, gpointer data) { tx_out_of_band=tx_out_of_band==1?0:1; } +static void trim_changed_cb(GtkWidget *widget, gpointer data) { + int i=GPOINTER_TO_INT(data); + pa_trim[i]=gtk_spin_button_get_value(GTK_SPIN_BUTTON(widget)); +} + +static void show_1W(gboolean reset) { + int i; + char text[16]; + + if(reset) { + for(i=0;i<11;i++) { + pa_trim[i]=i*100; + } + } + for(i=1;i<11;i++) { + sprintf(text,"%dmW",pa_trim[i]); + GtkWidget *label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(label), text); + gtk_grid_attach(GTK_GRID(grid2),label,0,i,1,1); + + GtkWidget *spin=gtk_spin_button_new_with_range(0.0,(double)((i+2)*100),1.0); + gtk_grid_attach(GTK_GRID(grid2),spin,1,i,1,1); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin),(double)pa_trim[i]); + g_signal_connect(spin,"value_changed",G_CALLBACK(trim_changed_cb),GINT_TO_POINTER(i)); + } +} + +static void show_W(int watts,gboolean reset) { + int i; + char text[16]; + int increment=watts/10; + + if(reset) { + for(i=0;i<11;i++) { + pa_trim[i]=i*increment; + } + } + + for(i=1;i<11;i++) { + sprintf(text,"%dW",pa_trim[i]); + GtkWidget *label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(label), text); + gtk_grid_attach(GTK_GRID(grid2),label,0,i,1,1); + + GtkWidget *spin=gtk_spin_button_new_with_range(0.0,(double)((i+2)*increment),1.0); + gtk_grid_attach(GTK_GRID(grid2),spin,1,i,1,1); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin),(double)pa_trim[i]); + g_signal_connect(spin,"value_changed",G_CALLBACK(trim_changed_cb),GINT_TO_POINTER(i)); + } +} + +static void clear_W() { + int i; + for(i=0;i<10;i++) { + gtk_grid_remove_row(GTK_GRID(grid2),1); + } +} + +static void max_power_changed_cb(GtkWidget *widget, gpointer data) { + pa_power = gtk_combo_box_get_active(GTK_COMBO_BOX(widget)); +g_print("max_power_changed_cb: %d\n",pa_power); + clear_W(); + switch(pa_power) { + case PA_1W: + show_1W(TRUE); + break; + case PA_10W: + show_W(10,TRUE); + break; + case PA_30W: + show_W(30,TRUE); + break; + case PA_50W: + show_W(50,TRUE); + break; + case PA_100W: + show_W(100,TRUE); + break; + case PA_200W: + show_W(200,TRUE); + break; + case PA_500W: + show_W(500,TRUE); + break; + } + gtk_widget_show_all(grid2); +} + void pa_menu(GtkWidget *parent) { int i; @@ -87,41 +177,120 @@ void pa_menu(GtkWidget *parent) { 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 *notebook=gtk_notebook_new(); + + GtkWidget *grid0=gtk_grid_new(); + gtk_grid_set_column_spacing (GTK_GRID(grid0),10); GtkWidget *close_b=gtk_button_new_with_label("Close"); g_signal_connect (close_b, "pressed", G_CALLBACK(close_cb), NULL); - gtk_grid_attach(GTK_GRID(grid),close_b,0,0,1,1); + gtk_grid_attach(GTK_GRID(grid0),close_b,0,0,1,1); + + GtkWidget *max_power_label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(max_power_label), "MAX Power"); + gtk_grid_attach(GTK_GRID(grid0),max_power_label,1,0,1,1); + + GtkWidget *max_power_b=gtk_combo_box_text_new(); + gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(max_power_b),NULL,"1W"); + gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(max_power_b),NULL,"10W"); + gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(max_power_b),NULL,"30W"); + gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(max_power_b),NULL,"50W"); + gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(max_power_b),NULL,"100W"); + gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(max_power_b),NULL,"200W"); + gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(max_power_b),NULL,"500W"); + gtk_combo_box_set_active(GTK_COMBO_BOX(max_power_b),pa_power); + gtk_grid_attach(GTK_GRID(grid0),max_power_b,2,0,1,1); + g_signal_connect(max_power_b,"changed",G_CALLBACK(max_power_changed_cb),NULL); + + GtkWidget *tx_out_of_band_b=gtk_check_button_new_with_label("Transmit out of band"); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tx_out_of_band_b), tx_out_of_band); + gtk_widget_show(tx_out_of_band_b); + gtk_grid_attach(GTK_GRID(grid0),tx_out_of_band_b,3,0,1,1); + g_signal_connect(tx_out_of_band_b,"toggled",G_CALLBACK(tx_out_of_band_cb),NULL); + + GtkWidget *grid1=gtk_grid_new(); + gtk_grid_set_column_spacing (GTK_GRID(grid1),10); - for(i=0;ititle); + GtkWidget *band_label=gtk_label_new(NULL); + char band_text[32]; + sprintf(band_text,"%s",band->title); + gtk_label_set_markup(GTK_LABEL(band_label), band_text); //gtk_widget_override_font(band_label, pango_font_description_from_string("Arial 18")); gtk_widget_show(band_label); - gtk_grid_attach(GTK_GRID(grid),band_label,(i/6)*2,(i%6)+1,1,1); + gtk_grid_attach(GTK_GRID(grid1),band_label,(i/6)*2,(i%6)+1,1,1); GtkWidget *pa_r=gtk_spin_button_new_with_range(38.8,100.0,0.1); //gtk_widget_override_font(pa_r, pango_font_description_from_string("Arial 18")); gtk_spin_button_set_value(GTK_SPIN_BUTTON(pa_r),(double)band->pa_calibration); gtk_widget_show(pa_r); - gtk_grid_attach(GTK_GRID(grid),pa_r,((i/6)*2)+1,(i%6)+1,1,1); + gtk_grid_attach(GTK_GRID(grid1),pa_r,((i/6)*2)+1,(i%6)+1,1,1); g_signal_connect(pa_r,"value_changed",G_CALLBACK(pa_value_changed_cb),band); } - GtkWidget *tx_out_of_band_b=gtk_check_button_new_with_label("Transmit out of band"); - //gtk_widget_override_font(tx_out_of_band_b, pango_font_description_from_string("Arial 18")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tx_out_of_band_b), tx_out_of_band); - gtk_widget_show(tx_out_of_band_b); - gtk_grid_attach(GTK_GRID(grid),tx_out_of_band_b,0,7,4,1); - g_signal_connect(tx_out_of_band_b,"toggled",G_CALLBACK(tx_out_of_band_cb),NULL); - - gtk_container_add(GTK_CONTAINER(content),grid); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook),grid1,gtk_label_new("Calibrate")); + + grid2=gtk_grid_new(); + gtk_grid_set_column_spacing (GTK_GRID(grid2),10); + + switch(pa_power) { + case PA_1W: + show_1W(FALSE); + break; + case PA_10W: + show_W(10,FALSE); + break; + case PA_30W: + show_W(30,FALSE); + break; + case PA_50W: + show_W(50,FALSE); + break; + case PA_100W: + show_W(100,FALSE); + break; + case PA_200W: + show_W(200,FALSE); + break; + case PA_500W: + show_W(500,FALSE); + break; + } + + gtk_notebook_append_page(GTK_NOTEBOOK(notebook),grid2,gtk_label_new("Watt Meter Calibrate")); + + gtk_grid_attach(GTK_GRID(grid0),notebook,0,1,6,1); + gtk_container_add(GTK_CONTAINER(content),grid0); sub_menu=dialog; diff --git a/property.c b/property.c index 0b95c69..923daba 100644 --- a/property.c +++ b/property.c @@ -17,15 +17,30 @@ * */ +#include + #include #include #include #include "property.h" -PROPERTY* properties; +PROPERTY* properties=NULL; static double version=0.0; +void clearProperties() { +g_print("clearProperties\n"); + if(properties!=NULL) { + // free all the properties + PROPERTY *next; + while(properties!=NULL) { + next=properties->next_property; + free(properties); + properties=next; + } + } +} + /* --------------------------------------------------------------------------*/ /** * @brief Load Properties @@ -37,11 +52,10 @@ void loadProperties(char* filename) { char* name; char* value; FILE* f=fopen(filename,"r"); - properties=NULL; PROPERTY* property; fprintf(stderr,"loadProperties: %s\n",filename); - + clearProperties(); if(f) { while(fgets(string,sizeof(string),f)) { if(string[0]!='#') { diff --git a/property.h b/property.h index 89c8cea..ae41979 100644 --- a/property.h +++ b/property.h @@ -34,10 +34,10 @@ struct _PROPERTY { PROPERTY* next_property; }; +extern void clearProperties(); extern void loadProperties(char* filename); extern char* getProperty(char* name); extern void setProperty(char* name,char* value); - extern void saveProperties(char* filename); #endif diff --git a/ps_menu.c b/ps_menu.c index a303497..5cbf8e7 100644 --- a/ps_menu.c +++ b/ps_menu.c @@ -43,7 +43,7 @@ static GtkWidget *tx_att; * PureSignal 2.0 parameters and declarations */ -static double ampdelay = 150e-9; // 150 nsec +static double ampdelay = 150e-9; // 150 nsec static int ints = 16; static int spi = 256; // ints=16/spi=256 corresponds to "TINT=0.5 dB" static int stbl = 0; // "Stbl" un-checked @@ -219,7 +219,7 @@ static int info_thread(gpointer arg) { old5_2=info[5]; switch(state) { case 0: - // + // // A value of 175 means 1.2 dB too strong // A value of 132 means 1.2 dB too weak // diff --git a/radio.c b/radio.c index e169379..45dc928 100644 --- a/radio.c +++ b/radio.c @@ -51,10 +51,6 @@ #ifdef SOAPYSDR #include "soapy_protocol.h" #endif -#ifdef FREEDV -#include "freedv.h" -#endif -#include "audio_waterfall.h" #ifdef GPIO #include "gpio.h" #endif @@ -88,14 +84,6 @@ #define SLIDERS_HEIGHT (100) #define TOOLBAR_HEIGHT (30) #define WATERFALL_HEIGHT (105) -#ifdef PSK -#define PSK_WATERFALL_HEIGHT (90) -#define PSK_HEIGHT (display_height-(VFO_HEIGHT+PSK_WATERFALL_HEIGHT+SLIDERS_HEIGHT+TOOLBAR_HEIGHT)) -#endif - -#ifdef FREEDV -#define FREEDV_WATERFALL_HEIGHT (105) -#endif GtkWidget *fixed; static GtkWidget *vfo_panel; @@ -105,39 +93,30 @@ static GtkWidget *sliders; static GtkWidget *toolbar; static GtkWidget *panadapter; static GtkWidget *waterfall; -#ifdef PSK -static GtkWidget *psk; -static GtkWidget *psk_waterfall; -#endif static GtkWidget *audio_waterfall; #ifdef GPIO static GtkWidget *encoders; static cairo_surface_t *encoders_surface = NULL; #endif -#ifdef WIRIINGPI -static GtkWidget *encoders; -static cairo_surface_t *encoders_surface = NULL; -#endif - -gint sat_mode; + gint sat_mode; -int region=REGION_OTHER; + int region=REGION_OTHER; -int echo=0; + int echo=0; -int radio_sample_rate; -gboolean iqswap; + int radio_sample_rate; + gboolean iqswap; -static gint save_timer_id; + static gint save_timer_id; -DISCOVERED *radio=NULL; + DISCOVERED *radio=NULL; -char property_path[128]; + char property_path[128]; #ifdef __APPLE__ -sem_t *property_sem; + sem_t *property_sem; #else -sem_t property_sem; + sem_t property_sem; #endif RECEIVER *receiver[MAX_RECEIVERS]; @@ -164,8 +143,9 @@ int alc=TXA_ALC_AV; double tone_level=0.2; int filter_board=ALEX; -//int pa=PA_ENABLED; -//int apollo_tuner=0; +int pa_enabled=PA_ENABLED; +int pa_power=0; +int pa_trim[11]; int updates_per_second=10; @@ -341,7 +321,7 @@ g_print("radio_stop: RX1: CloseChannel: %d\n",receiver[1]->id); void reconfigure_radio() { int i; int y; -//fprintf(stderr,"reconfigure_radio: receivers=%d\n",receivers); +//g_print("reconfigure_radio: receivers=%d\n",receivers); rx_height=display_height-VFO_HEIGHT; if(display_sliders) { rx_height-=SLIDERS_HEIGHT; @@ -416,7 +396,7 @@ static gboolean menu_cb (GtkWidget *widget, GdkEventButton *event, gpointer data void start_radio() { int i; int y; -//fprintf(stderr,"start_radio: selected radio=%p device=%d\n",radio,radio->device); +//g_print("start_radio: selected radio=%p device=%d\n",radio,radio->device); gdk_window_set_cursor(gtk_widget_get_window(top_window),gdk_cursor_new(GDK_WATCH)); int rc; @@ -424,6 +404,113 @@ void start_radio() { protocol=radio->protocol; device=radio->device; + // set the default power output + switch(protocol) { + case ORIGINAL_PROTOCOL: + switch(device) { + case DEVICE_METIS: + pa_power=PA_1W; + break; + case DEVICE_HERMES: + pa_power=PA_100W; + break; + case DEVICE_GRIFFIN: + pa_power=PA_100W; + break; + case DEVICE_ANGELIA: + pa_power=PA_100W; + break; + case DEVICE_ORION: + pa_power=PA_100W; + break; + case DEVICE_HERMES_LITE: + pa_power=PA_1W; + break; + case DEVICE_HERMES_LITE2: + pa_power=PA_10W; + break; + case DEVICE_ORION2: + pa_power=PA_200W; + break; + case DEVICE_STEMLAB: + pa_power=PA_100W; + break; + } + break; + case NEW_PROTOCOL: + switch(device) { + case NEW_DEVICE_ATLAS: + pa_power=PA_1W; + break; + case NEW_DEVICE_HERMES: + case NEW_DEVICE_HERMES2: + pa_power=PA_100W; + break; + case NEW_DEVICE_ANGELIA: + pa_power=PA_100W; + break; + case NEW_DEVICE_ORION: + pa_power=PA_100W; + break; + case NEW_DEVICE_HERMES_LITE: + pa_power=PA_1W; + break; + case NEW_DEVICE_HERMES_LITE2: + pa_power=PA_10W; + break; + case NEW_DEVICE_ORION2: + pa_power=PA_200W; + break; + case DEVICE_STEMLAB: + pa_power=PA_100W; + break; + } + break; +#ifdef SOAPYSDR + case SOAPYSDR_PROTOCOL: + pa_power=PA_1W; + break; +#endif + } + + switch(pa_power) { + case PA_1W: + for(i=0;i<11;i++) { + pa_trim[i]=i*100; + } + break; + case PA_10W: + for(i=0;i<11;i++) { + pa_trim[i]=i; + } + break; + case PA_30W: + for(i=0;i<11;i++) { + pa_trim[i]=i*3; + } + break; + case PA_50W: + for(i=0;i<11;i++) { + pa_trim[i]=i*5; + } + break; + case PA_100W: + for(i=0;i<11;i++) { + pa_trim[i]=i*10; + } + break; + case PA_200W: + for(i=0;i<11;i++) { + pa_trim[i]=i*20; + } + break; + case PA_500W: + for(i=0;i<11;i++) { + pa_trim[i]=i*50; + } + break; + } + // // have_rx_gain determines whether we have "ATT" or "RX Gain" Sliders // It is set for HermesLite (and RadioBerry, for that matter) @@ -488,7 +575,7 @@ void start_radio() { rc=sem_init(&property_sem, 0, 0); #endif if(rc!=0) { - fprintf(stderr,"start_radio: sem_init failed for property_sem: %d\n", rc); + g_print("start_radio: sem_init failed for property_sem: %d\n", rc); exit(-1); } #ifdef __APPLE__ @@ -725,6 +812,11 @@ void start_radio() { adc_attenuation[0]=0; adc_attenuation[1]=0; + if(have_rx_gain) { + adc_attenuation[0]=25; + adc_attenuation[1]=25; + } + adc[0].antenna=ANTENNA_1; adc[0].filters=AUTOMATIC; adc[0].hpf=HPF_13; @@ -775,22 +867,27 @@ void start_radio() { radio_sample_rate=radio->info.soapy.sample_rate; #endif -//fprintf(stderr,"meter_calibration=%f display_calibration=%f\n", meter_calibration, display_calibration); +//g_print("meter_calibration=%f display_calibration=%f\n", meter_calibration, display_calibration); -#if defined (CONTROLLER2_V2) || defined (CONTROLLER2_V1) - display_sliders=0; - display_toolbar=0; +#ifdef GPIO + switch(controller) { + case CONTROLLER2_V1: + case CONTROLLER2_V2: + display_sliders=0; + display_toolbar=0; + break; + default: + display_sliders=1; + display_toolbar=1; + break; + } #else display_sliders=1; display_toolbar=1; #endif -#ifdef GPIO - gpio_restore_state(); -#endif radioRestoreState(); - // // It is possible that an option has been read in // which is not compatible with the hardware. @@ -828,11 +925,11 @@ void start_radio() { gtk_container_remove(GTK_CONTAINER(top_window),grid); gtk_container_add(GTK_CONTAINER(top_window), fixed); -//fprintf(stderr,"radio: vfo_init\n"); +//g_print("radio: vfo_init\n"); vfo_panel = vfo_init(VFO_WIDTH,VFO_HEIGHT,top_window); gtk_fixed_put(GTK_FIXED(fixed),vfo_panel,0,y); -//fprintf(stderr,"radio: meter_init\n"); +//g_print("radio: meter_init\n"); meter = meter_init(METER_WIDTH,METER_HEIGHT,top_window); gtk_fixed_put(GTK_FIXED(fixed),meter,VFO_WIDTH,y); @@ -859,7 +956,6 @@ void start_radio() { if(display_toolbar) { rx_height-=TOOLBAR_HEIGHT; } - //int tx_height=rx_height; // // To be on the safe side, we create ALL receiver panels here @@ -887,7 +983,7 @@ void start_radio() { active_receiver=receiver[0]; - //fprintf(stderr,"Create transmitter\n"); + //g_print("Create transmitter\n"); if(can_transmit) { if(duplex) { transmitter=create_transmitter(CHANNEL_TX, buffer_size, fft_size, updates_per_second, display_width/4, display_height/2); @@ -900,6 +996,8 @@ void start_radio() { transmitter->x=0; transmitter->y=VFO_HEIGHT; + calcDriveLevel(); + #ifdef PURESIGNAL tx_set_ps_sample_rate(transmitter,protocol==NEW_PROTOCOL?192000:active_receiver->sample_rate); receiver[PS_TX_FEEDBACK]=create_pure_signal_receiver(PS_TX_FEEDBACK, buffer_size,protocol==ORIGINAL_PROTOCOL?active_receiver->sample_rate:192000,display_width); @@ -915,14 +1013,16 @@ void start_radio() { #endif #ifdef GPIO - if(gpio_init()<0) { - fprintf(stderr,"GPIO failed to initialize\n"); + if(controller!=NO_CONTROLLER) { + if(gpio_init()<0) { + g_print("GPIO failed to initialize\n"); + } } #endif #ifdef LOCALCW // init local keyer if enabled if (cw_keyer_internal == 0) { - fprintf(stderr,"Initialize keyer.....\n"); + g_print("Initialize keyer.....\n"); keyer_update(); } #endif @@ -942,7 +1042,7 @@ void start_radio() { } if(display_sliders) { -//fprintf(stderr,"create sliders\n"); +//g_print("create sliders\n"); sliders = sliders_init(display_width,SLIDERS_HEIGHT); gtk_fixed_put(GTK_FIXED(fixed),sliders,0,y); y+=SLIDERS_HEIGHT; @@ -968,25 +1068,11 @@ void start_radio() { } gtk_widget_show_all (fixed); -//#ifdef FREEDV -// if(!active_receiver->freedv) { -// gtk_widget_hide(audio_waterfall); -// } -//#endif - // save every 30 seconds //save_timer_id=gdk_threads_add_timeout(30000, save_cb, NULL); -#ifdef PSK - if(vfo[active_receiver->id].mode==modePSK) { - show_psk(); - } else { - show_waterfall(); - } -#endif - if(rigctl_enable) { launch_rigctl(); } @@ -1059,7 +1145,7 @@ void start_radio() { } void disable_rigctl() { - fprintf(stderr,"RIGCTL: disable_rigctl()\n"); + g_print("RIGCTL: disable_rigctl()\n"); close_rigctl_ports(); } @@ -1068,7 +1154,7 @@ void radio_change_receivers(int r) { // The button in the radio menu will call this function even if the // number of receivers has not changed. if (receivers == r) return; - fprintf(stderr,"radio_change_receivers: from %d to %d\n",receivers,r); + g_print("radio_change_receivers: from %d to %d\n",receivers,r); // // When changing the number of receivers, restart the // old protocol @@ -1122,6 +1208,7 @@ void radio_change_sample_rate(int rate) { #ifdef SOAPYSDR case SOAPYSDR_PROTOCOL: soapy_protocol_change_sample_rate(receiver[0],rate); + soapy_protocol_set_mic_sample_rate(rate); break; #endif } @@ -1132,11 +1219,6 @@ static void rxtx(int state) { if(state) { // switch to tx -#ifdef FREEDV - if(active_receiver->freedv) { - freedv_reset_tx_text_index(); - } -#endif #ifdef PURESIGNAL RECEIVER *rx_feedback=receiver[PS_RX_FEEDBACK]; RECEIVER *tx_feedback=receiver[PS_TX_FEEDBACK]; @@ -1162,11 +1244,6 @@ static void rxtx(int state) { gtk_container_remove(GTK_CONTAINER(fixed),receiver[i]->panel); } } -//#ifdef FREEDV -// if(active_receiver->freedv) { -// gtk_widget_show(audio_waterfall); -// } -//#endif if(duplex) { gtk_widget_show_all(transmitter->dialog); @@ -1200,11 +1277,6 @@ static void rxtx(int state) { } else { gtk_container_remove(GTK_CONTAINER(fixed), transmitter->panel); } -//#ifdef FREEDV -// if(active_receiver->freedv) { -// gtk_widget_hide(audio_waterfall); -// } -//#endif if(!duplex) { for(i=0;ipanel,receiver[i]->x,receiver[i]->y); @@ -1212,11 +1284,6 @@ static void rxtx(int state) { set_displaying(receiver[i],1); } } -//#ifdef FREEDV -// if(active_receiver->freedv) { -// gtk_widget_show(audio_waterfall); -// } -//#endif } #ifdef PURESIGNAL @@ -1264,7 +1331,7 @@ void vox_changed(int state) { } void frequency_changed(RECEIVER *rx) { -//fprintf(stderr,"frequency_changed: channel=%d frequency=%ld lo=%ld error=%ld ctun=%d offset=%ld\n",rx->channel,rx->frequency_a,rx->lo_a,rx->error_a,rx->ctun,rx->offset); +//g_print("frequency_changed: channel=%d frequency=%ld lo=%ld error=%ld ctun=%d offset=%ld\n",rx->channel,rx->frequency_a,rx->lo_a,rx->error_a,rx->ctun,rx->offset); if(vfo[0].ctun) { SetRXAShiftFreq(rx->id, (double)vfo[0].offset); RXANBPSetShiftFrequency(rx->id, (double)vfo[0].offset); @@ -1485,7 +1552,6 @@ static int calcLevel(double d) { level=(int)(actual_volts*255.0); -//fprintf(stderr,"calcLevel: %f calib=%f level=%d\n",d, gbb, level); return level; } @@ -1494,7 +1560,7 @@ void calcDriveLevel() { if(isTransmitting() && protocol==NEW_PROTOCOL) { schedule_high_priority(); } -//fprintf(stderr,"calcDriveLevel: drive=%d drive_level=%d\n",transmitter->drive,transmitter->drive_level); +//g_print("calcDriveLevel: drive=%d drive_level=%d\n",transmitter->drive,transmitter->drive_level); } void setDrive(double value) { @@ -1532,11 +1598,6 @@ void set_attenuation(int value) { case NEW_PROTOCOL: schedule_high_priority(); break; -#ifdef SOAPYSDR - case SOAPYSDR_PROTOCOL: - //soapy_protocol_set_attenuation(value); - break; -#endif } } @@ -1580,16 +1641,18 @@ void set_alex_attenuation(int v) { } void radioRestoreState() { + char name[32]; char *value; + int i; -fprintf(stderr,"radioRestoreState: %s\n",property_path); -//fprintf(stderr,"sem_wait\n"); +g_print("radioRestoreState: %s\n",property_path); +//g_print("sem_wait\n"); #ifdef __APPLE__ sem_wait(property_sem); #else sem_wait(&property_sem); #endif -//fprintf(stderr,"sem_wait: returner\n"); +//g_print("sem_wait: returner\n"); loadProperties(property_path); value=getProperty("diversity_enabled"); @@ -1616,12 +1679,15 @@ fprintf(stderr,"radioRestoreState: %s\n",property_path); if(value) tx_out_of_band=atoi(value); value=getProperty("filter_board"); if(value) filter_board=atoi(value); -/* - value=getProperty("apollo_tuner"); - if(value) apollo_tuner=atoi(value); - value=getProperty("pa"); - if(value) pa=atoi(value); -*/ + value=getProperty("pa_enabled"); + if(value) pa_enabled=atoi(value); + value=getProperty("pa_power"); + if(value) pa_power=atoi(value); + for(i=0;i<11;i++) { + sprintf(name,"pa_trim[%d]",i); + value=getProperty(name); + if(value) pa_trim[i]=atoi(value); + } value=getProperty("updates_per_second"); if(value) updates_per_second=atoi(value); value=getProperty("display_filled"); @@ -1780,9 +1846,6 @@ fprintf(stderr,"radioRestoreState: %s\n",property_path); modesettings_restore_state(); #ifdef GPIO gpio_restore_actions(); -#endif -#ifdef FREEDV - freedv_restore_state(); #endif value=getProperty("rigctl_enable"); if(value) rigctl_enable=atoi(value); @@ -1825,7 +1888,7 @@ fprintf(stderr,"radioRestoreState: %s\n",property_path); #endif -//fprintf(stderr,"sem_post\n"); +//g_print("sem_post\n"); #ifdef __APPLE__ sem_post(property_sem); #else @@ -1836,15 +1899,15 @@ fprintf(stderr,"radioRestoreState: %s\n",property_path); void radioSaveState() { int i; char value[80]; + char name[32]; -fprintf(stderr,"radioSaveState: %s\n",property_path); -//fprintf(stderr,"sem_wait\n"); +g_print("radioSaveState: %s\n",property_path); #ifdef __APPLE__ sem_wait(property_sem); #else sem_wait(&property_sem); #endif -//fprintf(stderr,"sem_wait: returned\n"); + clearProperties(); sprintf(value,"%d",diversity_enabled); setProperty("diversity_enabled",value); sprintf(value,"%f",div_gain); @@ -1909,6 +1972,15 @@ fprintf(stderr,"radioSaveState: %s\n",property_path); setProperty("tx_filter_low",value); sprintf(value,"%d",tx_filter_high); setProperty("tx_filter_high",value); + sprintf(value,"%d",pa_enabled); + setProperty("pa_enabled",value); + sprintf(value,"%d",pa_power); + setProperty("pa_power",value); + for(i=0;i<11;i++) { + sprintf(name,"pa_trim[%d]",i); + sprintf(value,"%d",pa_trim[i]); + setProperty(name,value); + } sprintf(value,"%lld",step); setProperty("step",value); @@ -2088,16 +2160,14 @@ fprintf(stderr,"radioSaveState: %s\n",property_path); sprintf(value,"%d",sat_mode); setProperty("sat_mode",value); -#ifdef FREEDV - freedv_save_state(); -#endif - filterSaveState(); bandSaveState(); memSaveState(); #ifdef GPIO - gpio_save_actions(); + if(controller!=NO_CONTROLLER) { + gpio_save_actions(); + } #endif sprintf(value,"%d",rigctl_enable); @@ -2106,7 +2176,7 @@ fprintf(stderr,"radioSaveState: %s\n",property_path); setProperty("rigctl_port_base",value); saveProperties(property_path); -fprintf(stderr,"sem_post\n"); +g_print("sem_post\n"); #ifdef __APPLE__ sem_post(property_sem); #else @@ -2128,7 +2198,7 @@ void calculate_display_average(RECEIVER *rx) { void set_filter_type(int filter_type) { int i; - //fprintf(stderr,"set_filter_type: %d\n",filter_type); + //g_print("set_filter_type: %d\n",filter_type); for(i=0;ilow_latency=filter_type; RXASetMP(receiver[i]->id, filter_type); @@ -2140,7 +2210,7 @@ void set_filter_type(int filter_type) { void set_filter_size(int filter_size) { int i; - //fprintf(stderr,"set_filter_size: %d\n",filter_size); + //g_print("set_filter_size: %d\n",filter_size); for(i=0;ifft_size=filter_size; RXASetNC(receiver[i]->id, filter_size); @@ -2149,24 +2219,6 @@ void set_filter_size(int filter_size) { TXASetNC(transmitter->id, filter_size); } -#ifdef FREEDV -void set_freedv(int state) { -fprintf(stderr,"set_freedv: rx=%p state=%d\n",active_receiver,state); - g_mutex_lock(&active_receiver->freedv_mutex); - active_receiver->freedv=state; - if(active_receiver->freedv) { - SetRXAPanelRun(active_receiver->id, 0); - init_freedv(active_receiver); - transmitter->freedv_samples=0; - } else { - SetRXAPanelRun(active_receiver->id, 1); - close_freedv(active_receiver); - } - g_mutex_unlock(&active_receiver->freedv_mutex); - g_idle_add(ext_vfo_update,NULL); -} -#endif - void radio_change_region(int r) { region=r; switch (region) { diff --git a/radio.h b/radio.h index b91dd5e..cf79f01 100644 --- a/radio.h +++ b/radio.h @@ -46,6 +46,16 @@ #define OLD_ORION_MIC_BIAS_DISABLED 0x00 #define OLD_ORION_MIC_BIAS_ENABLED 0x20 +enum { + PA_1W=0, + PA_10W, + PA_30W, + PA_50W, + PA_100W, + PA_200W, + PA_500W +}; + extern DISCOVERED *radio; extern GtkWidget *fixed; @@ -81,12 +91,10 @@ extern RECEIVER *active_receiver; extern TRANSMITTER *transmitter; -/* + #define PA_DISABLED 0 #define PA_ENABLED 1 -#define APOLLO_TUNER 1 -*/ #define KEYER_STRAIGHT 0 #define KEYER_MODE_A 1 #define KEYER_MODE_B 2 @@ -125,7 +133,9 @@ extern int tx_leveler; extern double tone_level; extern int filter_board; -extern int pa; +extern int pa_enabled; +extern int pa_power; +extern int pa_trim[11]; extern int apollo_tuner; extern int updates_per_second; @@ -319,10 +329,6 @@ extern void calculate_display_average(); extern void set_filter_type(int filter_type); extern void set_filter_size(int filter_size); -#ifdef FREEDV -extern void set_freedv(int state); -#endif - extern void radio_change_region(int region); extern void disable_rigctl(); diff --git a/radio_menu.c b/radio_menu.c index 749065b..1e5c935 100644 --- a/radio_menu.c +++ b/radio_menu.c @@ -157,6 +157,10 @@ static void dac0_gain_value_changed_cb(GtkWidget *widget, gpointer data) { */ #endif +static void rx_gain_calibration_value_changed_cb(GtkWidget *widget, gpointer data) { + rx_gain_calibration=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget)); +} + static void vfo_divisor_value_changed_cb(GtkWidget *widget, gpointer data) { vfo_encoder_divisor=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget)); } @@ -397,7 +401,8 @@ void radio_menu(GtkWidget *parent) { col++; - GtkWidget *region_label=gtk_label_new("Region: "); + GtkWidget *region_label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(region_label), "Region:"); gtk_grid_attach(GTK_GRID(grid),region_label,col,row,1,1); col++; @@ -416,19 +421,21 @@ void radio_menu(GtkWidget *parent) { row++; col=0; - GtkWidget *receivers_label=gtk_label_new("Receivers: "); + GtkWidget *receivers_label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(receivers_label), "Receivers:"); + gtk_label_set_justify(GTK_LABEL(receivers_label),GTK_JUSTIFY_LEFT); gtk_grid_attach(GTK_GRID(grid),receivers_label,col,row,1,1); row++; - receivers_1=gtk_radio_button_new_with_label(NULL,"1"); + receivers_1=gtk_radio_button_new_with_label(NULL,"1"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (receivers_1), receivers==1); gtk_grid_attach(GTK_GRID(grid),receivers_1,col,row,1,1); g_signal_connect(receivers_1,"toggled",G_CALLBACK(receivers_cb),(gpointer *)1); row++; - receivers_2=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(receivers_1),"2"); + receivers_2=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(receivers_1),"2"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (receivers_2), receivers==2); gtk_grid_attach(GTK_GRID(grid),receivers_2,col,row,1,1); g_signal_connect(receivers_2,"toggled",G_CALLBACK(receivers_cb),(gpointer *)2); @@ -441,7 +448,8 @@ void radio_menu(GtkWidget *parent) { switch(protocol) { case ORIGINAL_PROTOCOL: { - GtkWidget *sample_rate_label=gtk_label_new("Sample Rate:"); + GtkWidget *sample_rate_label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(sample_rate_label), "Sample Rate:"); gtk_grid_attach(GTK_GRID(grid),sample_rate_label,col,row,1,1); row++; @@ -494,7 +502,8 @@ void radio_menu(GtkWidget *parent) { #ifdef SOAPYSDR case SOAPYSDR_PROTOCOL: { - GtkWidget *sample_rate_label=gtk_label_new("Sample Rate:"); + GtkWidget *sample_rate_label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(sample_rate_label), "Sample Rate:"); gtk_grid_attach(GTK_GRID(grid),sample_rate_label,col,row,1,1); row++; @@ -555,8 +564,9 @@ void radio_menu(GtkWidget *parent) { row=1; - GtkWidget *sample_rate_label=gtk_label_new("Filter Board:"); - gtk_grid_attach(GTK_GRID(grid),sample_rate_label,col,row,1,1); + GtkWidget *filter_board_label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(filter_board_label), "Filter Board:"); + gtk_grid_attach(GTK_GRID(grid),filter_board_label,col,row,1,1); row++; GtkWidget *none_b = gtk_radio_button_new_with_label(NULL, "NONE"); @@ -596,7 +606,8 @@ void radio_menu(GtkWidget *parent) { row=1; - GtkWidget *rit_label=gtk_label_new("R/XIT step (Hz): "); + GtkWidget *rit_label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(rit_label), "RIT/XIT step (Hz):"); gtk_grid_attach(GTK_GRID(grid),rit_label,col,row,1,1); row++; @@ -622,7 +633,8 @@ void radio_menu(GtkWidget *parent) { col++; row=1; - GtkWidget *vfo_divisor_label=gtk_label_new("VFO Encoder Divisor: "); + GtkWidget *vfo_divisor_label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(vfo_divisor_label), "VFO Encoder Divisor:"); gtk_grid_attach(GTK_GRID(grid),vfo_divisor_label,col,row,1,1); row++; @@ -649,7 +661,8 @@ void radio_menu(GtkWidget *parent) { #endif { row=1; - GtkWidget *atlas_label=gtk_label_new("Atlas bus: "); + GtkWidget *atlas_label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(atlas_label), "Atlas bus:"); gtk_grid_attach(GTK_GRID(grid),atlas_label,col,row,1,1); row++; @@ -702,7 +715,7 @@ void radio_menu(GtkWidget *parent) { col++; - duplex_b=gtk_check_button_new_with_label("Duplex"); + duplex_b=gtk_check_button_new_with_label("Duplex"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (duplex_b), duplex); gtk_grid_attach(GTK_GRID(grid),duplex_b,col,row,1,1); g_signal_connect(duplex_b,"toggled",G_CALLBACK(duplex_cb),NULL); @@ -719,6 +732,22 @@ void radio_menu(GtkWidget *parent) { g_signal_connect(sat_combo,"changed",G_CALLBACK(sat_cb),NULL); row++; + + if(have_rx_gain) { + col=0; + GtkWidget *rx_gain_label=gtk_label_new("RX Gain Calibration:"); + gtk_label_set_markup(GTK_LABEL(rx_gain_label), "RX Gain Calibration:"); + gtk_grid_attach(GTK_GRID(grid),rx_gain_label,col,row,1,1); + col++; + + GtkWidget *rx_gain_calibration_b=gtk_spin_button_new_with_range(-50.0,50.0,1.0); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(rx_gain_calibration_b),(double)rx_gain_calibration); + gtk_grid_attach(GTK_GRID(grid),rx_gain_calibration_b,col,row,1,1); + g_signal_connect(rx_gain_calibration_b,"value_changed",G_CALLBACK(rx_gain_calibration_value_changed_cb),NULL); + + row++; + } + if(row>temp_row) temp_row=row; #ifdef SOAPYSDR @@ -726,14 +755,17 @@ void radio_menu(GtkWidget *parent) { if(radio->device==SOAPYSDR_USB_DEVICE) { int i; if(radio->info.soapy.rx_gains>0) { - GtkWidget *rx_gain=gtk_label_new("Rx Gains:"); + GtkWidget *rx_gain=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(rx_gain), "RX Gains:"); + gtk_label_set_justify(GTK_LABEL(rx_gain),GTK_JUSTIFY_LEFT); gtk_grid_attach(GTK_GRID(grid),rx_gain,col,row,1,1); } if(can_transmit) { if(radio->info.soapy.tx_gains>0) { col=2; - GtkWidget *tx_gain=gtk_label_new("Tx Gains:"); + GtkWidget *tx_gain=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(tx_gain), "TX Gains:"); gtk_grid_attach(GTK_GRID(grid),tx_gain,col,row,1,1); } } diff --git a/receiver.c b/receiver.c index fb8ce25..ad0f5d3 100644 --- a/receiver.c +++ b/receiver.c @@ -48,10 +48,6 @@ #ifdef SOAPYSDR #include "soapy_protocol.h" #endif -#ifdef FREEDV -#include "freedv.h" -#endif -#include "audio_waterfall.h" #include "ext.h" #include "new_menu.h" @@ -59,11 +55,6 @@ #define min(x,y) (xbutton==3) { g_idle_add(ext_start_rx,NULL); } + + g_print("receiver: %d adc=%d attenuation=%d rx_gain_calibration=%d\n",rx->id,rx->adc,adc_attenuation[rx->adc],rx_gain_calibration); } else { //int display_width=gtk_widget_get_allocated_width (rx->panadapter); //int display_height=gtk_widget_get_allocated_height (rx->panadapter); @@ -315,11 +308,6 @@ void receiver_save_state(RECEIVER *rx) { sprintf(value,"%f",rx->squelch); setProperty(name,value); -#ifdef FREEDV - sprintf(name,"receiver.%d.freedv",rx->id); - sprintf(value,"%d",rx->freedv); - setProperty(name,value); -#endif } void receiver_restore_state(RECEIVER *rx) { @@ -500,11 +488,6 @@ fprintf(stderr,"receiver_restore_state: id=%d\n",rx->id); value=getProperty(name); if(value) rx->squelch=atof(value); -#ifdef FREEDV - sprintf(name,"receiver.%d.freedv",rx->id); - value=getProperty(name); - if(value) rx->freedv=atoi(value); -#endif } void reconfigure_receiver(RECEIVER *rx,int height) { @@ -572,32 +555,13 @@ static gint update_display(gpointer data) { GetPixels(rx->id,0,rx->pixel_samples,&rc); if(rc) { if(rx->display_panadapter) { - switch(vfo[rx->id].mode) { -#ifdef PSK - case modePSK: - psk_waterfall_update(rx); - break; -#endif - default: - rx_panadapter_update(rx); - break; - } + rx_panadapter_update(rx); } if(rx->display_waterfall) { waterfall_update(rx); } } -#ifdef AUDIO_SAMPLES - if(audio_samples!=NULL) { - GetPixels(CHANNEL_AUDIO,0,audio_samples,&rc); - if(rc) { - //audio_waterfall_update(); - } - } -#endif - - if(active_receiver==rx) { double m=GetRXAMeter(rx->id,smeter)+meter_calibration; meter_update(rx,SMETER,m,0.0,0.0,0.0); @@ -617,15 +581,6 @@ void set_displaying(RECEIVER *rx,int state) { } void set_mode(RECEIVER *rx,int m) { -#ifdef PSK - if(vfo[rx->id].mode!=modePSK && m==modePSK) { - //init_psk(); - show_psk(); - } else if(vfo[rx->id].mode==modePSK && m!=modePSK) { - //close_psk(); - show_waterfall(); - } -#endif vfo[rx->id].mode=m; SetRXAMode(rx->id, vfo[rx->id].mode); } @@ -1032,13 +987,6 @@ fprintf(stderr,"create_receiver: id=%d default adc=%d\n",rx->id, rx->adc); rx->filter_high=525; rx->filter_low=275; -#ifdef FREEDV - g_mutex_init(&rx->freedv_mutex); - rx->freedv=0; - rx->freedv_samples=0; - strcpy(rx->freedv_text_data,""); - rx->freedv_text_index=0; -#endif rx->deviation=2500; @@ -1111,15 +1059,7 @@ fprintf(stderr,"RXASetMP %d\n",rx->low_latency); SetRXAPanelGain1(rx->id, rx->volume); SetRXAPanelBinaural(rx->id, binaural); -#ifdef FREEDV - if(rx->freedv) { - SetRXAPanelRun(rx->id, 0); - } else { -#endif - SetRXAPanelRun(rx->id, 1); -#ifdef FREEDV - } -#endif + SetRXAPanelRun(rx->id, 1); if(enable_rx_equalizer) { SetRXAGrphEQ(rx->id, rx_equalizer); @@ -1142,12 +1082,6 @@ fprintf(stderr,"RXASetMP %d\n",rx->low_latency); SetDisplayDetectorMode(rx->id, 0, display_detector_mode); SetDisplayAverageMode(rx->id, 0, display_average_mode); -#ifdef FREEDV - if(rx->freedv) { - init_freedv(rx); - } -#endif - calculate_display_average(rx); create_visual(rx); @@ -1213,6 +1147,7 @@ g_print("receiver_change_sample_rate: id=%d rate=%d scale=%d buffer_size=%d outp if(protocol==SOAPYSDR_PROTOCOL) { rx->resample_step=radio_sample_rate/rx->sample_rate; g_print("receiver_change_sample_rate: resample_step=%d\n",rx->resample_step); + soapy_protocol_set_mic_sample_rate(rx->sample_rate); } #endif @@ -1287,78 +1222,6 @@ void receiver_vfo_changed(RECEIVER *rx) { //receiver_filter_changed(rx); } -#ifdef FREEDV -static void process_freedv_rx_buffer(RECEIVER *rx) { - short left_audio_sample; - short right_audio_sample; - int i; - int demod_samples; - for(i=0;ioutput_samples;i++) { - if(rx->freedv_samples==0) { - if(isTransmitting()) { - left_audio_sample=0; - right_audio_sample=0; - } else { - left_audio_sample=(short)(rx->audio_output_buffer[i*2]*32767.0); - right_audio_sample=(short)(rx->audio_output_buffer[(i*2)+1]*32767.0); - } - demod_samples=demod_sample_freedv((left_audio_sample+right_audio_sample)/2); - if(demod_samples!=0) { - int s; - int t; - for(s=0;svolume); - } else { - left_audio_sample=right_audio_sample=(short)((double)speech_out[s]*rx->volume); - //left_audio_sample=right_audio_sample=0; - } - for(t=0;tlocal_audio) { - if(rx!=active_receiver && rx->mute_when_not_active) { - audio_write(rx,0,0); - } else { - switch(rx->audio_channel) { - case STEREO: - audio_write(rx,left_audio_sample,right_audio_sample); - break; - case LEFT: - audio_write(rx,left_audio_sample,0); - break; - case RIGHT: - audio_write(rx,0,right_audio_sample); - break; - } - } - } - - if(rx==active_receiver) { - switch(protocol) { - case ORIGINAL_PROTOCOL: - old_protocol_audio_samples(rx,left_audio_sample,right_audio_sample); - break; - case NEW_PROTOCOL: - new_protocol_audio_samples(rx,left_audio_sample,right_audio_sample); - break; -#ifdef SOAPYSDR - case SOAPYSDR_PROTOCOL: - break; -#endif - } - } - } - } - } - } - rx->freedv_samples++; - if(rx->freedv_samples>=freedv_resample) { - rx->freedv_samples=0; - } - } -} -#endif - static void process_rx_buffer(RECEIVER *rx) { gdouble left_sample,right_sample; short left_audio_sample,right_audio_sample; @@ -1374,17 +1237,6 @@ static void process_rx_buffer(RECEIVER *rx) { right_sample=rx->audio_output_buffer[(i*2)+1]; left_audio_sample=(short)(left_sample*32767.0); right_audio_sample=(short)(right_sample*32767.0); -#ifdef PSK - if(vfo[rx->id].mode==modePSK) { - if(psk_samples==0) { - psk_demod((double)((left_audio_sample+right_audio_sample)/2)); - } - psk_samples++; - if(psk_samples==psk_resample) { - psk_samples=0; - } - } -#endif } if(rx->local_audio) { @@ -1473,18 +1325,8 @@ void full_rx_buffer(RECEIVER *rx) { Spectrum0(1, rx->id, 0, 0, rx->iq_input_buffer); } -#ifdef FREEDV - g_mutex_lock(&rx->freedv_mutex); - if(rx->freedv) { - process_freedv_rx_buffer(rx); - } else { -#endif //g_print("full_rx_buffer: rx=%d buffer_size=%d samples=%d\n",rx->id,rx->buffer_size,rx->samples); - process_rx_buffer(rx); -#ifdef FREEDV - } - g_mutex_unlock(&rx->freedv_mutex); -#endif + process_rx_buffer(rx); g_mutex_unlock(&rx->mutex); } diff --git a/receiver.h b/receiver.h index 2a5bd4f..220fec1 100644 --- a/receiver.h +++ b/receiver.h @@ -139,14 +139,6 @@ typedef struct _receiver { gdouble *buffer; gint resample_step; -#ifdef FREEDV - GMutex freedv_mutex; - gint freedv; - gint freedv_samples; - gchar freedv_text_data[64]; - gint freedv_text_index; -#endif - gint x; gint y; } RECEIVER; diff --git a/rigctl_menu.c b/rigctl_menu.c index 5bbf009..de45624 100644 --- a/rigctl_menu.c +++ b/rigctl_menu.c @@ -138,7 +138,8 @@ void rigctl_menu(GtkWidget *parent) { gtk_grid_attach(GTK_GRID(grid),rigctl_enable_b,0,1,1,1); g_signal_connect(rigctl_enable_b,"toggled",G_CALLBACK(rigctl_enable_cb),NULL); - GtkWidget *rigctl_port_label =gtk_label_new("RigCtl Port Number"); + GtkWidget *rigctl_port_label =gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(rigctl_port_label), "RigCtl Port Number"); //gtk_widget_override_font(band_label, pango_font_description_from_string("Arial 18")); gtk_widget_show(rigctl_port_label); gtk_grid_attach(GTK_GRID(grid),rigctl_port_label,0,2,1,1); @@ -157,7 +158,8 @@ void rigctl_menu(GtkWidget *parent) { gtk_grid_attach(GTK_GRID(grid),serial_enable_b,0,3,1,1); g_signal_connect(serial_enable_b,"toggled",G_CALLBACK(serial_enable_cb),NULL); - GtkWidget *serial_text_label=gtk_label_new("Serial Port: /dev/ttyUSB"); + GtkWidget *serial_text_label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(serial_text_label), "Serial Port: /dev/ttyUSB"); gtk_grid_attach(GTK_GRID(grid),serial_text_label,0,4,1,1); GtkWidget *serial_port_spinner =gtk_spin_button_new_with_range(0,7,1); @@ -167,7 +169,8 @@ void rigctl_menu(GtkWidget *parent) { g_signal_connect(serial_port_spinner,"value_changed",G_CALLBACK(serial_value_changed_cb),NULL); // Serial baud rate here - GtkWidget *baud_rate_label =gtk_label_new("Baud Rate:"); + GtkWidget *baud_rate_label =gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(baud_rate_label), "Baud Rate:"); gtk_widget_show(baud_rate_label); gtk_grid_attach(GTK_GRID(grid),baud_rate_label,0,5,1,1); diff --git a/rx_menu.c b/rx_menu.c index d6791df..84e937f 100644 --- a/rx_menu.c +++ b/rx_menu.c @@ -210,7 +210,8 @@ void rx_menu(GtkWidget *parent) { switch(protocol) { case NEW_PROTOCOL: { - GtkWidget *sample_rate_label=gtk_label_new("Sample Rate"); + GtkWidget *sample_rate_label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(sample_rate_label), "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"); @@ -252,7 +253,8 @@ void rx_menu(GtkWidget *parent) { case SOAPYSDR_PROTOCOL: { int row=1; - GtkWidget *sample_rate_label=gtk_label_new("Sample Rate"); + GtkWidget *sample_rate_label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(sample_rate_label), "Sample Rate"); gtk_grid_attach(GTK_GRID(grid),sample_rate_label,x,row,1,1); row++; @@ -306,7 +308,8 @@ void rx_menu(GtkWidget *parent) { if (filter_board == ALEX && active_receiver->adc == 0 && ((protocol==ORIGINAL_PROTOCOL && device != DEVICE_ORION2) || (protocol==NEW_PROTOCOL && device != NEW_DEVICE_ORION2))) { - GtkWidget *alex_att_label=gtk_label_new("Alex Attenuator"); + GtkWidget *alex_att_label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(alex_att_label), "Alex Attenuator"); gtk_grid_attach(GTK_GRID(grid), alex_att_label, x, 5, 1, 1); GtkWidget *last_alex_att_b = NULL; for (i = 0; i <= 3; i++) { diff --git a/rx_panadapter.c b/rx_panadapter.c index 14eb2b5..3db0fed 100644 --- a/rx_panadapter.c +++ b/rx_panadapter.c @@ -37,9 +37,6 @@ #include "rx_panadapter.h" #include "vfo.h" #include "mode.h" -#ifdef FREEDV -#include "freedv.h" -#endif #ifdef GPIO #include "gpio.h" #endif @@ -123,11 +120,6 @@ void rx_panadapter_update(RECEIVER *rx) { int display_width=gtk_widget_get_allocated_width (rx->panadapter); int display_height=gtk_widget_get_allocated_height (rx->panadapter); -#ifdef FREEDV - if(rx->freedv) { - display_height=display_height-20; - } -#endif samples=rx->pixel_samples; //clear_panadater_surface(); @@ -392,7 +384,11 @@ void rx_panadapter_update(RECEIVER *rx) { samples[0]=-200.0; samples[display_width-1]=-200.0; - s1=(double)samples[0]+(double)adc_attenuation[rx->adc]; + if(have_rx_gain) { + s1=(double)samples[0]+40.0-(adc_attenuation[rx->adc]+12.0); + } else { + s1=(double)samples[0]+(double)adc_attenuation[rx->adc]; + } if (filter_board == ALEX && rx->adc == 0) s1 += (double)(10*rx->alex_attenuation); if (filter_board == CHARLY25) { if (rx->preamp) s1 -= 18.0; @@ -409,7 +405,11 @@ void rx_panadapter_update(RECEIVER *rx) { / (rx->panadapter_high - rx->panadapter_low)); cairo_move_to(cr, 0.0, s1); for(i=1;iadc]; + if(have_rx_gain) { + s2=(double)samples[i]+40.0-(adc_attenuation[rx->adc]+12.0); + } else { + s2=(double)samples[i]+(double)adc_attenuation[rx->adc]; + } if (filter_board == ALEX && rx->adc == 0) s2 += (double)(10*rx->alex_attenuation); if (filter_board == CHARLY25) { if (rx->preamp) s2 -= 18.0; @@ -443,41 +443,32 @@ void rx_panadapter_update(RECEIVER *rx) { cairo_set_line_width(cr, 1.0); cairo_stroke(cr); -#ifdef FREEDV - if(rx->freedv) { - cairo_set_source_rgb (cr, 0.0, 0.0, 0.0); - cairo_rectangle(cr,0,display_height,display_width,display_height+20); - cairo_fill(cr); - - cairo_set_source_rgb(cr, 0.0, 1.0, 0.0); - cairo_set_font_size(cr, 18); - cairo_move_to(cr, 0.0, (double)display_height+20.0-2.0); - cairo_show_text(cr, rx->freedv_text_data); - } -#endif +#ifdef GPIO + if(active && controller==CONTROLLER1) { + char text[64]; -#if !defined (CONTROLLER2_V2) && !defined (CONTROLLER2_V1) && defined (GPIO) - if(active) { cairo_set_source_rgb(cr,1.0,1.0,0.0); cairo_set_font_size(cr,16); if(ENABLE_E2_ENCODER) { - cairo_move_to(cr, display_width-150,30); - cairo_show_text(cr, encoder_string[e2_encoder_action]); + cairo_move_to(cr, display_width-200,30); + sprintf(text,"%s (%s)",encoder_string[e2_encoder_action],sw_string[e2_sw_action]); + cairo_show_text(cr, text); } if(ENABLE_E3_ENCODER) { - cairo_move_to(cr, display_width-150,50); - cairo_show_text(cr, encoder_string[e3_encoder_action]); + cairo_move_to(cr, display_width-200,50); + sprintf(text,"%s (%s)",encoder_string[e3_encoder_action],sw_string[e3_sw_action]); + cairo_show_text(cr, text); } if(ENABLE_E4_ENCODER) { - cairo_move_to(cr, display_width-150,70); - cairo_show_text(cr, encoder_string[e4_encoder_action]); + cairo_move_to(cr, display_width-200,70); + sprintf(text,"%s (%s)",encoder_string[e4_encoder_action],sw_string[e4_sw_action]); + cairo_show_text(cr, text); } } #endif - cairo_destroy (cr); gtk_widget_queue_draw (rx->panadapter); diff --git a/sliders.c b/sliders.c index f53984c..f6ecfe6 100644 --- a/sliders.c +++ b/sliders.c @@ -39,7 +39,6 @@ #include "sliders.h" #include "mode.h" #include "filter.h" -#include "frequency.h" #include "bandstack.h" #include "band.h" #include "discovered.h" @@ -63,22 +62,26 @@ static int height; static GtkWidget *sliders; -#define NONE 0 -#define AF_GAIN 1 -#define RF_GAIN 2 -#define MIC_GAIN 3 -#define LINEIN_GAIN 4 -#define AGC_GAIN 5 -#define DRIVE 6 -#define ATTENUATION 7 -#define SQUELCH 8 -#define COMP 9 -#define FILTER_WIDTH 10 -#define DIVERSITY_GAIN 11 -#define DIVERSITY_PHASE 12 +enum { + NO_FUNCTION=0, + AF_GAIN, + RF_GAIN, + MIC_GAIN, + LINEIN_GAIN, + AGC_GAIN, + DRIVE, + ATTENUATION, + SQUELCH, + COMP, + FILTER_WIDTH, + FILTER_SHIFT, + DIVERSITY_GAIN, + DIVERSITY_PHASE, +}; static gint scale_timer; -static int scale_status=NONE; +static int scale_status=NO_FUNCTION; +static int scale_rx=0; static GtkWidget *scale_dialog; static GtkWidget *af_gain_label; static GtkWidget *af_gain_scale; @@ -103,6 +106,7 @@ static GtkWidget *comp_scale; static GtkWidget *comp_enable; static GtkWidget *dummy_label; static GtkWidget *filter_width_scale; +static GtkWidget *filter_shift_scale; static GtkWidget *diversity_gain_scale; static GtkWidget *diversity_phase_scale; @@ -136,9 +140,9 @@ int sliders_active_receiver_changed(void *data) { } char title[64]; if (have_rx_gain) { - sprintf(title,"RX GAIN"/*,active_receiver->adc*/); + sprintf(title,"RX GAIN"); } else { - sprintf(title,"ATT (dB)"/*,active_receiver->adc*/); + sprintf(title,"ATT (dB)"); } gtk_label_set_text(GTK_LABEL(attenuation_label),title); sliders_update(); @@ -148,7 +152,7 @@ int sliders_active_receiver_changed(void *data) { int scale_timeout_cb(gpointer data) { gtk_widget_destroy(scale_dialog); - scale_status=NONE; + scale_status=NO_FUNCTION; return FALSE; } @@ -160,7 +164,7 @@ static void attenuation_value_changed_cb(GtkWidget *widget, gpointer data) { //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)); - adc_attenuation[active_receiver->adc]= rx_gain_calibration - rx_gain_slider_value; + adc_attenuation[active_receiver->adc]= rx_gain_slider_value; set_attenuation(adc_attenuation[active_receiver->adc]); } else { adc_attenuation[active_receiver->adc]=(int)gtk_range_get_value(GTK_RANGE(attenuation_scale)); @@ -172,19 +176,19 @@ void set_attenuation_value(double value) { adc_attenuation[active_receiver->adc]=(int)value; if(display_sliders) { if (have_rx_gain) { - gtk_range_set_value (GTK_RANGE(attenuation_scale),(double)(rx_gain_calibration-adc_attenuation[active_receiver->adc])); + gtk_range_set_value (GTK_RANGE(attenuation_scale),(double)adc_attenuation[active_receiver->adc]); } else { gtk_range_set_value (GTK_RANGE(attenuation_scale),(double)adc_attenuation[active_receiver->adc]); } } else { if(scale_status!=ATTENUATION) { - if(scale_status!=NONE) { + if(scale_status!=NO_FUNCTION) { g_source_remove(scale_timer); gtk_widget_destroy(scale_dialog); - scale_status=NONE; + scale_status=NO_FUNCTION; } } - if(scale_status==NONE) { + if(scale_status==NO_FUNCTION) { char title[64]; if (have_rx_gain) { sprintf(title,"RX GAIN - ADC-%d (dB)",active_receiver->adc); @@ -194,7 +198,11 @@ void set_attenuation_value(double value) { 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); + if (have_rx_gain) { + attenuation_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,-12.0, 48.0, 1.00); + } else { + attenuation_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,0.0, 31.0, 1.00); + } gtk_widget_set_size_request (attenuation_scale, 400, 30); gtk_range_set_value (GTK_RANGE(attenuation_scale),(double)adc_attenuation[active_receiver->adc]); gtk_widget_show(attenuation_scale); @@ -294,16 +302,19 @@ void set_agc_gain(int rx,double value) { if(display_sliders) { gtk_range_set_value (GTK_RANGE(agc_scale),receiver[rx]->agc_gain); } else { - if(scale_status!=AGC_GAIN) { - if(scale_status!=NONE) { + if(scale_status!=AGC_GAIN || scale_rx!=rx) { + if(scale_status!=NO_FUNCTION) { g_source_remove(scale_timer); gtk_widget_destroy(scale_dialog); - scale_status=NONE; + scale_status=NO_FUNCTION; } } - if(scale_status==NONE) { + if(scale_status==NO_FUNCTION) { scale_status=AGC_GAIN; - scale_dialog=gtk_dialog_new_with_buttons("AGC Gain",GTK_WINDOW(top_window),GTK_DIALOG_DESTROY_WITH_PARENT,NULL,NULL); + scale_rx=rx; + char title[64]; + sprintf(title,"AGC Gain RX %d",rx); + 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)); agc_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,-20.0, 120.0, 1.00); gtk_widget_set_size_request (agc_scale, 400, 30); @@ -327,13 +338,7 @@ void update_agc_gain(double gain) { static void afgain_value_changed_cb(GtkWidget *widget, gpointer data) { active_receiver->volume=gtk_range_get_value(GTK_RANGE(af_gain_scale))/100.0; -#ifdef FREEDV - if(!active_receiver->freedv) { -#endif - SetRXAPanelGain1 (active_receiver->id, active_receiver->volume); -#ifdef FREEDV - } -#endif + SetRXAPanelGain1 (active_receiver->id, active_receiver->volume); } void update_af_gain() { @@ -346,16 +351,19 @@ void set_af_gain(int rx,double value) { if(display_sliders) { gtk_range_set_value (GTK_RANGE(af_gain_scale),receiver[rx]->volume*100.0); } else { - if(scale_status!=AF_GAIN) { - if(scale_status!=NONE) { + if(scale_status!=AF_GAIN || scale_rx!=rx) { + if(scale_status!=NO_FUNCTION) { g_source_remove(scale_timer); gtk_widget_destroy(scale_dialog); - scale_status=NONE; + scale_status=NO_FUNCTION; } } - if(scale_status==NONE) { + if(scale_status==NO_FUNCTION) { scale_status=AF_GAIN; - scale_dialog=gtk_dialog_new_with_buttons("AF Gain",GTK_WINDOW(top_window),GTK_DIALOG_DESTROY_WITH_PARENT,NULL,NULL); + scale_rx=rx; + char title[64]; + sprintf(title,"AF Gain RX %d",rx); + 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)); af_gain_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,0.0, 100.0, 1.00); gtk_widget_set_size_request (af_gain_scale, 400, 30); @@ -396,16 +404,19 @@ void set_rf_gain(int rx,double value) { if(display_sliders) { gtk_range_set_value (GTK_RANGE(rf_gain_scale),receiver[rx]->rf_gain); } else { - if(scale_status!=RF_GAIN) { - if(scale_status!=NONE) { + if(scale_status!=RF_GAIN || scale_rx!=rx) { + if(scale_status!=NO_FUNCTION) { g_source_remove(scale_timer); gtk_widget_destroy(scale_dialog); - scale_status=NONE; + scale_status=NO_FUNCTION; } } - if(scale_status==NONE) { + if(scale_status==NO_FUNCTION) { scale_status=RF_GAIN; - scale_dialog=gtk_dialog_new_with_buttons("RF Gain",GTK_WINDOW(top_window),GTK_DIALOG_DESTROY_WITH_PARENT,NULL,NULL); + scale_rx=rx; + char title[64]; + sprintf(title,"RF Gain RX %d",rx); + 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)); rf_gain_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,0.0, 100.0, 1.00); gtk_widget_set_size_request (rf_gain_scale, 400, 30); @@ -424,16 +435,19 @@ void set_rf_gain(int rx,double value) { } void set_filter_width(int rx,int width) { - if(scale_status!=FILTER_WIDTH) { - if(scale_status!=NONE) { + if(scale_status!=FILTER_WIDTH || scale_rx!=rx) { + if(scale_status!=NO_FUNCTION) { g_source_remove(scale_timer); gtk_widget_destroy(scale_dialog); - scale_status=NONE; + scale_status=NO_FUNCTION; } } - if(scale_status==NONE) { + if(scale_status==NO_FUNCTION) { scale_status=FILTER_WIDTH; - scale_dialog=gtk_dialog_new_with_buttons("Filter Width (Hz)",GTK_WINDOW(top_window),GTK_DIALOG_DESTROY_WITH_PARENT,NULL,NULL); + scale_rx=rx; + char title[64]; + sprintf(title,"Filter Width RX %d (Hz)",rx); + 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)); filter_width_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,0.0, 4000.0, 1.00); gtk_widget_set_size_request (filter_width_scale, 400, 30); @@ -450,6 +464,35 @@ void set_filter_width(int rx,int width) { } } +void set_filter_shift(int rx,int shift) { + if(scale_status!=FILTER_SHIFT || scale_rx!=rx) { + if(scale_status!=NO_FUNCTION) { + g_source_remove(scale_timer); + gtk_widget_destroy(scale_dialog); + scale_status=NO_FUNCTION; + } + } + if(scale_status==NO_FUNCTION) { + scale_status=FILTER_SHIFT; + scale_rx=rx; + char title[64]; + sprintf(title,"Filter SHIFT RX %d (Hz)",rx); + 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)); + filter_shift_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,-1000.0, 1000.0, 1.00); + gtk_widget_set_size_request (filter_shift_scale, 400, 30); + gtk_range_set_value (GTK_RANGE(filter_shift_scale),(double)shift); + gtk_widget_show(filter_shift_scale); + gtk_container_add(GTK_CONTAINER(content),filter_shift_scale); + scale_timer=g_timeout_add(2000,scale_timeout_cb,NULL); + //gtk_widget_show_all(scale_dialog); + gtk_dialog_run(GTK_DIALOG(scale_dialog)); + } else { + g_source_remove(scale_timer); + gtk_range_set_value (GTK_RANGE(filter_shift_scale),(double)shift); + scale_timer=g_timeout_add(2000,scale_timeout_cb,NULL); + } +} static void micgain_value_changed_cb(GtkWidget *widget, gpointer data) { if(mic_linein) { @@ -468,13 +511,13 @@ void set_mic_gain(double value) { gtk_range_set_value (GTK_RANGE(mic_gain_scale),mic_gain); } else { if(scale_status!=MIC_GAIN) { - if(scale_status!=NONE) { + if(scale_status!=NO_FUNCTION) { g_source_remove(scale_timer); gtk_widget_destroy(scale_dialog); - scale_status=NONE; + scale_status=NO_FUNCTION; } } - if(scale_status==NONE) { + if(scale_status==NO_FUNCTION) { scale_status=MIC_GAIN; scale_dialog=gtk_dialog_new_with_buttons("Mic Gain",GTK_WINDOW(top_window),GTK_DIALOG_DESTROY_WITH_PARENT,NULL,NULL); GtkWidget *content=gtk_dialog_get_content_area(GTK_DIALOG(scale_dialog)); @@ -501,13 +544,13 @@ void set_linein_gain(int value) { gtk_range_set_value (GTK_RANGE(mic_gain_scale),linein_gain); } else { if(scale_status!=LINEIN_GAIN) { - if(scale_status!=NONE) { + if(scale_status!=NO_FUNCTION) { g_source_remove(scale_timer); gtk_widget_destroy(scale_dialog); - scale_status=NONE; + scale_status=NO_FUNCTION; } } - if(scale_status==NONE) { + if(scale_status==NO_FUNCTION) { scale_status=LINEIN_GAIN; scale_dialog=gtk_dialog_new_with_buttons("Linein Gain",GTK_WINDOW(top_window),GTK_DIALOG_DESTROY_WITH_PARENT,NULL,NULL); GtkWidget *content=gtk_dialog_get_content_area(GTK_DIALOG(scale_dialog)); @@ -539,13 +582,13 @@ void set_drive(double value) { gtk_range_set_value (GTK_RANGE(drive_scale),value); } else { if(scale_status!=DRIVE) { - if(scale_status!=NONE) { + if(scale_status!=NO_FUNCTION) { g_source_remove(scale_timer); gtk_widget_destroy(scale_dialog); - scale_status=NONE; + scale_status=NO_FUNCTION; } } - if(scale_status==NONE) { + if(scale_status==NO_FUNCTION) { scale_status=DRIVE; scale_dialog=gtk_dialog_new_with_buttons("Drive",GTK_WINDOW(top_window),GTK_DIALOG_DESTROY_WITH_PARENT,NULL,NULL); GtkWidget *content=gtk_dialog_get_content_area(GTK_DIALOG(scale_dialog)); @@ -618,15 +661,17 @@ void set_squelch() { } else { #endif if(scale_status!=SQUELCH) { - if(scale_status!=NONE) { + if(scale_status!=NO_FUNCTION) { g_source_remove(scale_timer); gtk_widget_destroy(scale_dialog); - scale_status=NONE; + scale_status=NO_FUNCTION; } } - if(scale_status==NONE) { + if(scale_status==NO_FUNCTION) { scale_status=SQUELCH; - scale_dialog=gtk_dialog_new_with_buttons("Squelch",GTK_WINDOW(top_window),GTK_DIALOG_DESTROY_WITH_PARENT,NULL,NULL); + char title[64]; + sprintf(title,"Squelch RX %d (Hz)",active_receiver->id); + 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)); squelch_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,0.0, 100.0, 1.00); gtk_widget_override_font(squelch_scale, pango_font_description_from_string("Sans 10")); @@ -653,13 +698,13 @@ void set_compression(TRANSMITTER* tx) { } else { #endif if(scale_status!=COMP) { - if(scale_status!=NONE) { + if(scale_status!=NO_FUNCTION) { g_source_remove(scale_timer); gtk_widget_destroy(scale_dialog); - scale_status=NONE; + scale_status=NO_FUNCTION; } } - if(scale_status==NONE) { + if(scale_status==NO_FUNCTION) { scale_status=COMP; scale_dialog=gtk_dialog_new_with_buttons("COMP",GTK_WINDOW(top_window),GTK_DIALOG_DESTROY_WITH_PARENT,NULL,NULL); GtkWidget *content=gtk_dialog_get_content_area(GTK_DIALOG(scale_dialog)); @@ -685,13 +730,13 @@ void set_compression(TRANSMITTER* tx) { void show_diversity_gain() { if(scale_status!=DIVERSITY_GAIN) { - if(scale_status!=NONE) { + if(scale_status!=NO_FUNCTION) { g_source_remove(scale_timer); gtk_widget_destroy(scale_dialog); - scale_status=NONE; + scale_status=NO_FUNCTION; } } - if(scale_status==NONE) { + if(scale_status==NO_FUNCTION) { scale_status=DIVERSITY_GAIN; scale_dialog=gtk_dialog_new_with_buttons("Diversity Gain",GTK_WINDOW(top_window),GTK_DIALOG_DESTROY_WITH_PARENT,NULL,NULL); GtkWidget *content=gtk_dialog_get_content_area(GTK_DIALOG(scale_dialog)); @@ -712,17 +757,17 @@ void show_diversity_gain() { void show_diversity_phase() { if(scale_status!=DIVERSITY_PHASE) { - if(scale_status!=NONE) { + if(scale_status!=NO_FUNCTION) { g_source_remove(scale_timer); gtk_widget_destroy(scale_dialog); - scale_status=NONE; + scale_status=NO_FUNCTION; } } - if(scale_status==NONE) { + if(scale_status==NO_FUNCTION) { scale_status=DIVERSITY_PHASE; scale_dialog=gtk_dialog_new_with_buttons("Diversity Phase",GTK_WINDOW(top_window),GTK_DIALOG_DESTROY_WITH_PARENT,NULL,NULL); GtkWidget *content=gtk_dialog_get_content_area(GTK_DIALOG(scale_dialog)); - diversity_phase_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,-180.0, 180.0, 1.0); + diversity_phase_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, -180.0, 180.0, 1.0); gtk_widget_set_size_request (diversity_phase_scale, 400, 30); gtk_range_set_value (GTK_RANGE(diversity_phase_scale),div_phase); gtk_widget_show(diversity_phase_scale); @@ -756,6 +801,7 @@ fprintf(stderr,"sliders_init: width=%d height=%d\n", width,height); af_gain_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,0.0, 100.0, 1.00); gtk_widget_override_font(af_gain_scale, pango_font_description_from_string("Sans 10")); + gtk_range_set_increments (GTK_RANGE(af_gain_scale),1.0,1.0); gtk_range_set_value (GTK_RANGE(af_gain_scale),active_receiver->volume*100.0); gtk_widget_show(af_gain_scale); gtk_grid_attach(GTK_GRID(sliders),af_gain_scale,1,0,2,1); @@ -768,6 +814,7 @@ fprintf(stderr,"sliders_init: width=%d height=%d\n", width,height); agc_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,-20.0, 120.0, 1.0); gtk_widget_override_font(agc_scale, pango_font_description_from_string("Sans 10")); + gtk_range_set_increments (GTK_RANGE(agc_scale),1.0,1.0); gtk_range_set_value (GTK_RANGE(agc_scale),active_receiver->agc_gain); gtk_widget_show(agc_scale); gtk_grid_attach(GTK_GRID(sliders),agc_scale,4,0,2,1); @@ -775,9 +822,9 @@ fprintf(stderr,"sliders_init: width=%d height=%d\n", width,height); char title[64]; if (have_rx_gain) { - sprintf(title,"RX-GAIN:"/*,active_receiver->adc*/); + sprintf(title,"RX-GAIN:"); } else { - sprintf(title,"ATT (dB)"/*,active_receiver->adc*/); + sprintf(title,"ATT (dB):"); } attenuation_label=gtk_label_new(title); gtk_widget_override_font(attenuation_label, pango_font_description_from_string("Sans 10")); @@ -785,12 +832,13 @@ fprintf(stderr,"sliders_init: width=%d height=%d\n", width,height); gtk_grid_attach(GTK_GRID(sliders),attenuation_label,6,0,1,1); if (have_rx_gain) { - 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_calibration-adc_attenuation[active_receiver->adc]); + attenuation_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,-12.0, 48.0, 1.0); + gtk_range_set_value (GTK_RANGE(attenuation_scale),adc_attenuation[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]); } + gtk_range_set_increments (GTK_RANGE(attenuation_scale),1.0,1.0); gtk_widget_override_font(attenuation_scale, pango_font_description_from_string("Sans 10")); @@ -828,6 +876,7 @@ fprintf(stderr,"sliders_init: width=%d height=%d\n", width,height); gtk_grid_attach(GTK_GRID(sliders),mic_gain_label,0,1,1,1); mic_gain_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,mic_linein?0.0:-12.0,mic_linein?31.0:50.0, 1.0); + gtk_range_set_increments (GTK_RANGE(mic_gain_scale),1.0,1.0); gtk_widget_override_font(mic_gain_scale, pango_font_description_from_string("Sans 10")); gtk_range_set_value (GTK_RANGE(mic_gain_scale),mic_linein?linein_gain:mic_gain); gtk_grid_attach(GTK_GRID(sliders),mic_gain_scale,1,1,2,1); @@ -839,6 +888,7 @@ fprintf(stderr,"sliders_init: width=%d height=%d\n", width,height); drive_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,0.0, 100.0, 1.0); gtk_widget_override_font(drive_scale, pango_font_description_from_string("Sans 10")); + gtk_range_set_increments (GTK_RANGE(drive_scale),1.0,1.0); gtk_range_set_value (GTK_RANGE(drive_scale),getDrive()); gtk_widget_show(drive_scale); gtk_grid_attach(GTK_GRID(sliders),drive_scale,4,1,2,1); @@ -853,6 +903,7 @@ fprintf(stderr,"sliders_init: width=%d height=%d\n", width,height); squelch_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,0.0, 100.0, 1.0); gtk_widget_override_font(squelch_scale, pango_font_description_from_string("Sans 10")); + gtk_range_set_increments (GTK_RANGE(squelch_scale),1.0,1.0); gtk_range_set_value (GTK_RANGE(squelch_scale),active_receiver->squelch); gtk_widget_show(squelch_scale); gtk_grid_attach(GTK_GRID(sliders),squelch_scale,7,1,2,1); @@ -872,6 +923,7 @@ fprintf(stderr,"sliders_init: width=%d height=%d\n", width,height); comp_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,0.0, 20.0, 1.0); gtk_widget_override_font(comp_scale, pango_font_description_from_string("Sans 10")); + gtk_range_set_increments (GTK_RANGE(comp_scale),1.0,1.0); gtk_range_set_value (GTK_RANGE(comp_scale),transmitter->compressor_level); gtk_widget_show(comp_scale); gtk_grid_attach(GTK_GRID(sliders),comp_scale,7,1,2,1); diff --git a/sliders.h b/sliders.h index bf93e7a..f303db1 100644 --- a/sliders.h +++ b/sliders.h @@ -40,6 +40,7 @@ extern void set_drive(double drive); //extern void set_tune(double tune); extern void set_attenuation_value(double attenuation); extern void set_filter_width(int rx,int width); +extern void set_filter_shift(int rx,int width); extern GtkWidget *sliders_init(int my_width, int my_height); extern void sliders_update(); diff --git a/soapy_discovery.c b/soapy_discovery.c index 4280a7e..9633428 100644 --- a/soapy_discovery.c +++ b/soapy_discovery.c @@ -252,6 +252,7 @@ void soapy_discovery() { SoapySDRKwargs args={}; fprintf(stderr,"soapy_discovery\n"); + rtlsdr_count=0; SoapySDRKwargs *results = SoapySDRDevice_enumerate(NULL, &length); fprintf(stderr,"soapy_discovery: length=%d\n",length); for (i = 0; i < length; i++) { diff --git a/soapy_protocol.c b/soapy_protocol.c index c392273..a6bd4ea 100644 --- a/soapy_protocol.c +++ b/soapy_protocol.c @@ -49,12 +49,6 @@ #include "audio.h" #include "signal.h" #include "vfo.h" -#ifdef FREEDV -#include "freedv.h" -#endif -#ifdef PSK -#include "psk.h" -#endif #include "ext.h" #include "error_handler.h" @@ -79,9 +73,9 @@ static int rate_samples; static gboolean running; +static int mic_samples=0; static int mic_sample_divisor=1; - static int max_tx_samples; static float *output_buffer; static int output_buffer_index; @@ -104,8 +98,9 @@ void soapy_protocol_create_receiver(RECEIVER *rx) { if(rx->sample_rate!=radio_sample_rate) { soapy_rx_sample_rate=radio_sample_rate; } + mic_sample_divisor=soapy_rx_sample_rate/48000; -fprintf(stderr,"soapy_protocol_create_receiver: setting samplerate=%f adc=%d\n",(double)soapy_rx_sample_rate,rx->adc); +fprintf(stderr,"soapy_protocol_create_receiver: setting samplerate=%f adc=%d mic_sample_divisor=%d\n",(double)soapy_rx_sample_rate,rx->adc,mic_sample_divisor); rc=SoapySDRDevice_setSampleRate(soapy_device,SOAPY_SDR_RX,rx->adc,(double)soapy_rx_sample_rate); if(rc!=0) { fprintf(stderr,"soapy_protocol_create_receiver: SoapySDRDevice_setSampleRate(%f) failed: %s\n",(double)soapy_rx_sample_rate,SoapySDR_errToStr(rc)); @@ -271,6 +266,7 @@ static void *receive_thread(void *arg) { RECEIVER *rx=(RECEIVER *)arg; float *buffer=g_new(float,max_samples*2); void *buffs[]={buffer}; + float fsample; running=TRUE; fprintf(stderr,"soapy_protocol: receive_thread\n"); while(running) { @@ -291,6 +287,14 @@ fprintf(stderr,"soapy_protocol: receive_thread\n"); } else { add_iq_samples(rx,isample,qsample); } + if(can_transmit) { + mic_samples++; + if(mic_samples>=mic_sample_divisor) { // reduce to 48000 + fsample = transmitter->local_microphone ? audio_get_next_mic_sample() : (float)0.0; + add_mic_sample(transmitter,fsample); + mic_samples=0; + } + } } } else { for(i=0;i=mic_sample_divisor) { // reduce to 48000 + fsample = transmitter->local_microphone ? audio_get_next_mic_sample() : (float)0.0; + add_mic_sample(transmitter,fsample); + mic_samples=0; + } + } } } } @@ -314,15 +326,7 @@ fprintf(stderr,"soapy_protocol: receive_thread: SoapySDRDevice_unmake\n"); } void soapy_protocol_process_local_mic(float sample) { -#ifdef FREEDV - if(active_receiver->freedv) { - add_freedv_mic_sample(transmitter,sample); - } else { -#endif - add_mic_sample(transmitter,sample); -#ifdef FREEDV - } -#endif + add_mic_sample(transmitter,sample); } void soapy_protocol_iq_samples(float isample,float qsample) { diff --git a/soundio.c b/soundio.c index d711fcf..c6c8b36 100644 --- a/soundio.c +++ b/soundio.c @@ -219,11 +219,6 @@ fprintf(stderr,"audio_open_input: %d\n",n_selected_input_device); fprintf(stderr,"audio_open_input: selected=%d:%s\n",n_selected_input_device,selected); switch(protocol) { -#ifdef RADIOBERRY - case RADIOBERRY_PROTOCOL: - mic_buffer_size = 1024; - break; -#endif case ORIGINAL_PROTOCOL: mic_buffer_size = 720; break; @@ -418,11 +413,6 @@ fprintf(stderr,"mic_read_thread: mic_buffer_size=%d\n",mic_buffer_size); } else { // process the mic input switch(protocol) { -#ifdef RADIOBERRY - case RADIOBERRY_PROTOCOL: - radioberry_protocol_iq_samples(mic_buffer,1); - break; -#endif case ORIGINAL_PROTOCOL: old_protocol_process_local_mic(mic_buffer,1); break; diff --git a/switch_menu.c b/switch_menu.c index 0e49c88..14f722e 100644 --- a/switch_menu.c +++ b/switch_menu.c @@ -17,7 +17,6 @@ * */ -#if defined (CONTROLLER2_V2) || defined (CONTROLLER2_V1) #include #include #include @@ -105,6 +104,7 @@ void switch_menu(GtkWidget *parent) { int row=0; int col=0; char label[64]; + int i; dialog=gtk_dialog_new(); gtk_window_set_transient_for(GTK_WINDOW(dialog),GTK_WINDOW(parent_window)); @@ -133,255 +133,258 @@ void switch_menu(GtkWidget *parent) { row++; col=0; -#if !defined (CONTROLLER2_V2) && !defined (CONTROLLER2_V1) - - GtkWidget *sw7_title=gtk_label_new("SW7: "); - gtk_grid_attach(GTK_GRID(grid),sw7_title,col,row,1,1); - col++; - - GtkWidget *sw7_combo_box=gtk_combo_box_text_new(); - for(i=0;i%s",sw_string[sw_action[SW13]]); - gtk_label_set_markup (GTK_LABEL(sw13_label), label); - gtk_grid_attach(GTK_GRID(grid),sw13,col,row,1,1); - g_signal_connect (sw13, "button_press_event", G_CALLBACK(sw_cb), GINT_TO_POINTER(SW13)); - row++; - col=7; - - GtkWidget *sw12=gtk_button_new_with_label(sw_string[sw_action[SW12]]); - GtkWidget *sw12_label=gtk_bin_get_child(GTK_BIN(sw12)); - sprintf(label,"%s",sw_string[sw_action[SW12]]); - gtk_label_set_markup (GTK_LABEL(sw12_label), label); - gtk_grid_attach(GTK_GRID(grid),sw12,col,row,1,1); - g_signal_connect (sw12, "button_press_event", G_CALLBACK(sw_cb), GINT_TO_POINTER(SW12)); - col++; - - GtkWidget *sw11=gtk_button_new_with_label(sw_string[sw_action[SW11]]); - GtkWidget *sw11_label=gtk_bin_get_child(GTK_BIN(sw11)); - sprintf(label,"%s",sw_string[sw_action[SW11]]); - gtk_label_set_markup (GTK_LABEL(sw11_label), label); - gtk_grid_attach(GTK_GRID(grid),sw11,col,row,1,1); - g_signal_connect (sw11, "button_press_event", G_CALLBACK(sw_cb), GINT_TO_POINTER(SW11)); - row++; - col=7; - - GtkWidget *sw10=gtk_button_new_with_label(sw_string[sw_action[SW10]]); - GtkWidget *sw10_label=gtk_bin_get_child(GTK_BIN(sw10)); - sprintf(label,"%s",sw_string[sw_action[SW10]]); - gtk_label_set_markup (GTK_LABEL(sw10_label), label); - gtk_grid_attach(GTK_GRID(grid),sw10,col,row,1,1); - g_signal_connect (sw10, "button_press_event", G_CALLBACK(sw_cb), GINT_TO_POINTER(SW10)); - col++; - - GtkWidget *sw9=gtk_button_new_with_label(sw_string[sw_action[SW9]]); - GtkWidget *sw9_label=gtk_bin_get_child(GTK_BIN(sw9)); - sprintf(label,"%s",sw_string[sw_action[SW9]]); - gtk_label_set_markup (GTK_LABEL(sw9_label), label); - gtk_grid_attach(GTK_GRID(grid),sw9,col,row,1,1); - g_signal_connect (sw9, "button_press_event", G_CALLBACK(sw_cb), GINT_TO_POINTER(SW9)); - row++; - col=7; - - GtkWidget *sw7=gtk_button_new_with_label(sw_string[sw_action[SW7]]); - GtkWidget *sw7_label=gtk_bin_get_child(GTK_BIN(sw7)); - sprintf(label,"%s",sw_string[sw_action[SW7]]); - gtk_label_set_markup (GTK_LABEL(sw7_label), label); - gtk_grid_attach(GTK_GRID(grid),sw7,col,row,1,1); - g_signal_connect (sw7, "button_press_event", G_CALLBACK(sw_cb), GINT_TO_POINTER(SW7)); - col++; - - GtkWidget *sw8=gtk_button_new_with_label(sw_string[sw_action[SW8]]); - GtkWidget *sw8_label=gtk_bin_get_child(GTK_BIN(sw8)); - sprintf(label,"%s",sw_string[sw_action[SW8]]); - gtk_label_set_markup (GTK_LABEL(sw8_label), label); - gtk_grid_attach(GTK_GRID(grid),sw8,col,row,1,1); - g_signal_connect (sw8, "button_press_event", G_CALLBACK(sw_cb), GINT_TO_POINTER(SW8)); - row++; - col=7; - - GtkWidget *sw16=gtk_button_new_with_label(sw_string[sw_action[SW16]]); - GtkWidget *sw16_label=gtk_bin_get_child(GTK_BIN(sw16)); - sprintf(label,"%s",sw_string[sw_action[SW16]]); - gtk_label_set_markup (GTK_LABEL(sw16_label), label); - gtk_grid_attach(GTK_GRID(grid),sw16,col,row,1,1); - g_signal_connect (sw16, "button_press_event", G_CALLBACK(sw_cb), GINT_TO_POINTER(SW16)); - col++; - - GtkWidget *sw17=gtk_button_new_with_label(sw_string[sw_action[SW17]]); - GtkWidget *sw17_label=gtk_bin_get_child(GTK_BIN(sw17)); - sprintf(label,"%s",sw_string[sw_action[SW17]]); - gtk_label_set_markup (GTK_LABEL(sw17_label), label); - gtk_grid_attach(GTK_GRID(grid),sw17,col,row,1,1); - g_signal_connect (sw17, "button_press_event", G_CALLBACK(sw_cb), GINT_TO_POINTER(SW17)); - row++; - col=0; - - GtkWidget *sw2=gtk_button_new_with_label(sw_string[sw_action[SW2]]); - GtkWidget *sw2_label=gtk_bin_get_child(GTK_BIN(sw2)); - sprintf(label,"%s",sw_string[sw_action[SW2]]); - gtk_label_set_markup (GTK_LABEL(sw2_label), label); - gtk_grid_attach(GTK_GRID(grid),sw2,col,row,1,1); - g_signal_connect (sw2, "button_press_event", G_CALLBACK(sw_cb), GINT_TO_POINTER(SW2)); - col++; + switch(controller) { + default: + { + GtkWidget *sw7_title=gtk_label_new("SW7: "); + gtk_grid_attach(GTK_GRID(grid),sw7_title,col,row,1,1); + col++; + + GtkWidget *sw7_combo_box=gtk_combo_box_text_new(); + for(i=0;i%s",sw_string[sw_action[CONTROLLER2_SW13]]); + gtk_label_set_markup (GTK_LABEL(sw13_label), label); + gtk_grid_attach(GTK_GRID(grid),sw13,col,row,1,1); + g_signal_connect (sw13, "button_press_event", G_CALLBACK(sw_cb), GINT_TO_POINTER(CONTROLLER2_SW13)); + row++; + col=7; + + GtkWidget *sw12=gtk_button_new_with_label(sw_string[sw_action[CONTROLLER2_SW12]]); + GtkWidget *sw12_label=gtk_bin_get_child(GTK_BIN(sw12)); + sprintf(label,"%s",sw_string[sw_action[CONTROLLER2_SW12]]); + gtk_label_set_markup (GTK_LABEL(sw12_label), label); + gtk_grid_attach(GTK_GRID(grid),sw12,col,row,1,1); + g_signal_connect (sw12, "button_press_event", G_CALLBACK(sw_cb), GINT_TO_POINTER(CONTROLLER2_SW12)); + col++; + + GtkWidget *sw11=gtk_button_new_with_label(sw_string[sw_action[CONTROLLER2_SW11]]); + GtkWidget *sw11_label=gtk_bin_get_child(GTK_BIN(sw11)); + sprintf(label,"%s",sw_string[sw_action[CONTROLLER2_SW11]]); + gtk_label_set_markup (GTK_LABEL(sw11_label), label); + gtk_grid_attach(GTK_GRID(grid),sw11,col,row,1,1); + g_signal_connect (sw11, "button_press_event", G_CALLBACK(sw_cb), GINT_TO_POINTER(CONTROLLER2_SW11)); + row++; + col=7; + + GtkWidget *sw10=gtk_button_new_with_label(sw_string[sw_action[CONTROLLER2_SW10]]); + GtkWidget *sw10_label=gtk_bin_get_child(GTK_BIN(sw10)); + sprintf(label,"%s",sw_string[sw_action[CONTROLLER2_SW10]]); + gtk_label_set_markup (GTK_LABEL(sw10_label), label); + gtk_grid_attach(GTK_GRID(grid),sw10,col,row,1,1); + g_signal_connect (sw10, "button_press_event", G_CALLBACK(sw_cb), GINT_TO_POINTER(CONTROLLER2_SW10)); + col++; + + GtkWidget *sw9=gtk_button_new_with_label(sw_string[sw_action[CONTROLLER2_SW9]]); + GtkWidget *sw9_label=gtk_bin_get_child(GTK_BIN(sw9)); + sprintf(label,"%s",sw_string[sw_action[CONTROLLER2_SW9]]); + gtk_label_set_markup (GTK_LABEL(sw9_label), label); + gtk_grid_attach(GTK_GRID(grid),sw9,col,row,1,1); + g_signal_connect (sw9, "button_press_event", G_CALLBACK(sw_cb), GINT_TO_POINTER(CONTROLLER2_SW9)); + row++; + col=7; + + GtkWidget *sw7=gtk_button_new_with_label(sw_string[sw_action[CONTROLLER2_SW7]]); + GtkWidget *sw7_label=gtk_bin_get_child(GTK_BIN(sw7)); + sprintf(label,"%s",sw_string[sw_action[CONTROLLER2_SW7]]); + gtk_label_set_markup (GTK_LABEL(sw7_label), label); + gtk_grid_attach(GTK_GRID(grid),sw7,col,row,1,1); + g_signal_connect (sw7, "button_press_event", G_CALLBACK(sw_cb), GINT_TO_POINTER(CONTROLLER2_SW7)); + col++; + + GtkWidget *sw8=gtk_button_new_with_label(sw_string[sw_action[CONTROLLER2_SW8]]); + GtkWidget *sw8_label=gtk_bin_get_child(GTK_BIN(sw8)); + sprintf(label,"%s",sw_string[sw_action[CONTROLLER2_SW8]]); + gtk_label_set_markup (GTK_LABEL(sw8_label), label); + gtk_grid_attach(GTK_GRID(grid),sw8,col,row,1,1); + g_signal_connect (sw8, "button_press_event", G_CALLBACK(sw_cb), GINT_TO_POINTER(CONTROLLER2_SW8)); + row++; + col=7; + + GtkWidget *sw16=gtk_button_new_with_label(sw_string[sw_action[CONTROLLER2_SW16]]); + GtkWidget *sw16_label=gtk_bin_get_child(GTK_BIN(sw16)); + sprintf(label,"%s",sw_string[sw_action[CONTROLLER2_SW16]]); + gtk_label_set_markup (GTK_LABEL(sw16_label), label); + gtk_grid_attach(GTK_GRID(grid),sw16,col,row,1,1); + g_signal_connect (sw16, "button_press_event", G_CALLBACK(sw_cb), GINT_TO_POINTER(CONTROLLER2_SW16)); + col++; + + GtkWidget *sw17=gtk_button_new_with_label(sw_string[sw_action[CONTROLLER2_SW17]]); + GtkWidget *sw17_label=gtk_bin_get_child(GTK_BIN(sw17)); + sprintf(label,"%s",sw_string[sw_action[CONTROLLER2_SW17]]); + gtk_label_set_markup (GTK_LABEL(sw17_label), label); + gtk_grid_attach(GTK_GRID(grid),sw17,col,row,1,1); + g_signal_connect (sw17, "button_press_event", G_CALLBACK(sw_cb), GINT_TO_POINTER(CONTROLLER2_SW17)); + row++; + col=0; + + GtkWidget *sw2=gtk_button_new_with_label(sw_string[sw_action[CONTROLLER2_SW2]]); + GtkWidget *sw2_label=gtk_bin_get_child(GTK_BIN(sw2)); + sprintf(label,"%s",sw_string[sw_action[CONTROLLER2_SW2]]); + gtk_label_set_markup (GTK_LABEL(sw2_label), label); + gtk_grid_attach(GTK_GRID(grid),sw2,col,row,1,1); + g_signal_connect (sw2, "button_press_event", G_CALLBACK(sw_cb), GINT_TO_POINTER(CONTROLLER2_SW2)); + col++; - GtkWidget *sw3=gtk_button_new_with_label(sw_string[sw_action[SW3]]); - GtkWidget *sw3_label=gtk_bin_get_child(GTK_BIN(sw3)); - sprintf(label,"%s",sw_string[sw_action[SW3]]); - gtk_label_set_markup (GTK_LABEL(sw3_label), label); - gtk_grid_attach(GTK_GRID(grid),sw3,col,row,1,1); - g_signal_connect (sw3, "button_press_event", G_CALLBACK(sw_cb), GINT_TO_POINTER(SW3)); - col++; + GtkWidget *sw3=gtk_button_new_with_label(sw_string[sw_action[CONTROLLER2_SW3]]); + GtkWidget *sw3_label=gtk_bin_get_child(GTK_BIN(sw3)); + sprintf(label,"%s",sw_string[sw_action[CONTROLLER2_SW3]]); + gtk_label_set_markup (GTK_LABEL(sw3_label), label); + gtk_grid_attach(GTK_GRID(grid),sw3,col,row,1,1); + g_signal_connect (sw3, "button_press_event", G_CALLBACK(sw_cb), GINT_TO_POINTER(CONTROLLER2_SW3)); + col++; - GtkWidget *sw4=gtk_button_new_with_label(sw_string[sw_action[SW4]]); - GtkWidget *sw4_label=gtk_bin_get_child(GTK_BIN(sw4)); - sprintf(label,"%s",sw_string[sw_action[SW4]]); - gtk_label_set_markup (GTK_LABEL(sw4_label), label); - gtk_grid_attach(GTK_GRID(grid),sw4,col,row,1,1); - g_signal_connect (sw4, "button_press_event", G_CALLBACK(sw_cb), GINT_TO_POINTER(SW4)); - col++; + GtkWidget *sw4=gtk_button_new_with_label(sw_string[sw_action[CONTROLLER2_SW4]]); + GtkWidget *sw4_label=gtk_bin_get_child(GTK_BIN(sw4)); + sprintf(label,"%s",sw_string[sw_action[CONTROLLER2_SW4]]); + gtk_label_set_markup (GTK_LABEL(sw4_label), label); + gtk_grid_attach(GTK_GRID(grid),sw4,col,row,1,1); + g_signal_connect (sw4, "button_press_event", G_CALLBACK(sw_cb), GINT_TO_POINTER(CONTROLLER2_SW4)); + col++; - GtkWidget *sw5=gtk_button_new_with_label(sw_string[sw_action[SW5]]); - GtkWidget *sw5_label=gtk_bin_get_child(GTK_BIN(sw5)); - sprintf(label,"%s",sw_string[sw_action[SW5]]); - gtk_label_set_markup (GTK_LABEL(sw5_label), label); - gtk_grid_attach(GTK_GRID(grid),sw5,col,row,1,1); - g_signal_connect (sw5, "button_press_event", G_CALLBACK(sw_cb), GINT_TO_POINTER(SW5)); - col++; + GtkWidget *sw5=gtk_button_new_with_label(sw_string[sw_action[CONTROLLER2_SW5]]); + GtkWidget *sw5_label=gtk_bin_get_child(GTK_BIN(sw5)); + sprintf(label,"%s",sw_string[sw_action[CONTROLLER2_SW5]]); + gtk_label_set_markup (GTK_LABEL(sw5_label), label); + gtk_grid_attach(GTK_GRID(grid),sw5,col,row,1,1); + g_signal_connect (sw5, "button_press_event", G_CALLBACK(sw_cb), GINT_TO_POINTER(CONTROLLER2_SW5)); + col++; - GtkWidget *sw6=gtk_button_new_with_label(sw_string[sw_action[SW6]]); - GtkWidget *sw6_label=gtk_bin_get_child(GTK_BIN(sw6)); - sprintf(label,"%s",sw_string[sw_action[SW6]]); - gtk_label_set_markup (GTK_LABEL(sw6_label), label); - gtk_grid_attach(GTK_GRID(grid),sw6,col,row,1,1); - g_signal_connect (sw6, "button_press_event", G_CALLBACK(sw_cb), GINT_TO_POINTER(SW6)); - col++; + GtkWidget *sw6=gtk_button_new_with_label(sw_string[sw_action[CONTROLLER2_SW6]]); + GtkWidget *sw6_label=gtk_bin_get_child(GTK_BIN(sw6)); + sprintf(label,"%s",sw_string[sw_action[CONTROLLER2_SW6]]); + gtk_label_set_markup (GTK_LABEL(sw6_label), label); + gtk_grid_attach(GTK_GRID(grid),sw6,col,row,1,1); + g_signal_connect (sw6, "button_press_event", G_CALLBACK(sw_cb), GINT_TO_POINTER(CONTROLLER2_SW6)); + col++; - GtkWidget *sw14=gtk_button_new_with_label(sw_string[sw_action[SW14]]); - GtkWidget *sw14_label=gtk_bin_get_child(GTK_BIN(sw14)); - sprintf(label,"%s",sw_string[sw_action[SW14]]); - gtk_label_set_markup (GTK_LABEL(sw14_label), label); - gtk_grid_attach(GTK_GRID(grid),sw14,col,row,1,1); - g_signal_connect (sw14, "button_press_event", G_CALLBACK(sw_cb), GINT_TO_POINTER(SW14)); - col++; + GtkWidget *sw14=gtk_button_new_with_label(sw_string[sw_action[CONTROLLER2_SW14]]); + GtkWidget *sw14_label=gtk_bin_get_child(GTK_BIN(sw14)); + sprintf(label,"%s",sw_string[sw_action[CONTROLLER2_SW14]]); + gtk_label_set_markup (GTK_LABEL(sw14_label), label); + gtk_grid_attach(GTK_GRID(grid),sw14,col,row,1,1); + g_signal_connect (sw14, "button_press_event", G_CALLBACK(sw_cb), GINT_TO_POINTER(CONTROLLER2_SW14)); + col++; - GtkWidget *sw15=gtk_button_new_with_label(sw_string[sw_action[SW15]]); - GtkWidget *sw15_label=gtk_bin_get_child(GTK_BIN(sw15)); - sprintf(label,"%s",sw_string[sw_action[SW15]]); - gtk_label_set_markup (GTK_LABEL(sw15_label), label); - gtk_grid_attach(GTK_GRID(grid),sw15,col,row,1,1); - g_signal_connect (sw15, "button_press_event", G_CALLBACK(sw_cb), GINT_TO_POINTER(SW15)); - col++; - - - -#endif + GtkWidget *sw15=gtk_button_new_with_label(sw_string[sw_action[CONTROLLER2_SW15]]); + GtkWidget *sw15_label=gtk_bin_get_child(GTK_BIN(sw15)); + sprintf(label,"%s",sw_string[sw_action[CONTROLLER2_SW15]]); + gtk_label_set_markup (GTK_LABEL(sw15_label), label); + gtk_grid_attach(GTK_GRID(grid),sw15,col,row,1,1); + g_signal_connect (sw15, "button_press_event", G_CALLBACK(sw_cb), GINT_TO_POINTER(CONTROLLER2_SW15)); + col++; + } + break; + } gtk_container_add(GTK_CONTAINER(content),grid); @@ -389,4 +392,3 @@ void switch_menu(GtkWidget *parent) { gtk_widget_show_all(dialog); } -#endif diff --git a/toolbar.c b/toolbar.c index f4e8e45..ba2cf94 100644 --- a/toolbar.c +++ b/toolbar.c @@ -29,7 +29,6 @@ #include "toolbar.h" #include "mode.h" #include "filter.h" -#include "frequency.h" #include "bandstack.h" #include "band.h" #include "discovered.h" @@ -276,7 +275,7 @@ static void aswapb_cb (GtkWidget *widget, gpointer data) { } static void split_cb (GtkWidget *widget, gpointer data) { - g_idle_add(ext_split_toggle, NULL); + g_idle_add(ext_split_toggle,NULL); } static void duplex_cb (GtkWidget *widget, gpointer data) { @@ -440,6 +439,8 @@ static void exit_cb(GtkWidget *widget, gpointer data) { g_signal_connect(b_halt,"pressed",G_CALLBACK(halt_cb),NULL); gtk_container_add(GTK_CONTAINER(content),grid); + GtkWidget *close_button=gtk_dialog_add_button(GTK_DIALOG(dialog),"Cancel",GTK_RESPONSE_OK); + //gtk_widget_override_font(close_button, pango_font_description_from_string("Arial 18")); gtk_widget_show_all(dialog); g_signal_connect_swapped (dialog, diff --git a/transmitter.c b/transmitter.c index 917f535..c732f4e 100644 --- a/transmitter.c +++ b/transmitter.c @@ -48,10 +48,6 @@ #ifdef SOAPYSDR #include "soapy_protocol.h" #endif -#ifdef FREEDV -#include "freedv.h" -#endif -#include "audio_waterfall.h" #include "audio.h" #include "ext.h" @@ -224,13 +220,6 @@ void transmitter_save_state(TRANSMITTER *tx) { sprintf(name,"transmitter.%d.am_carrier_level",tx->id); sprintf(value,"%f",tx->am_carrier_level); setProperty(name,value); -#ifdef FREEDV - if(strlen(tx->freedv_text_data)>0) { - sprintf(name,"transmitter.%d.freedv_text_data",tx->id); - sprintf(value,"%s",tx->freedv_text_data); - setProperty(name,value); - } -#endif sprintf(name,"transmitter.%d.drive",tx->id); sprintf(value,"%d",tx->drive); setProperty(name,value); @@ -325,11 +314,6 @@ void transmitter_restore_state(TRANSMITTER *tx) { sprintf(name,"transmitter.%d.am_carrier_level",tx->id); value=getProperty(name); if(value) tx->am_carrier_level=atof(value); -#ifdef FREEDV - sprintf(name,"transmitter.%d.freedv_text_data",tx->id); - value=getProperty(name); - if(value) strcpy(tx->freedv_text_data,value); -#endif sprintf(name,"transmitter.%d.drive",tx->id); value=getProperty(name); if(value) tx->drive=atoi(value); @@ -356,20 +340,51 @@ void transmitter_restore_state(TRANSMITTER *tx) { if(value) tx->xit=atoll(value); } +static double compute_power(double p) { + double interval=10.0; + switch(pa_power) { + case PA_1W: + interval=100.0; // mW + break; + case PA_10W: + interval=1.0; // W + break; + case PA_30W: + interval=3.0; // W + break; + case PA_50W: + interval=5.0; // W + break; + case PA_100W: + interval=10.0; // W + break; + case PA_200W: + interval=20.0; // W + break; + case PA_500W: + interval=50.0; // W + break; + } + int i=0; + if(p>(double)pa_trim[10]) { + i=9; + } else { + while(p>(double)pa_trim[i]) { + i++; + } + if(i>0) i--; + } + + double frac = (p - (double)pa_trim[i]) / ((double)pa_trim[i + 1] - (double)pa_trim[i]); + return interval * ((1.0 - frac) * (double)i + frac * (double)(i + 1)); +} + static gboolean update_display(gpointer data) { TRANSMITTER *tx=(TRANSMITTER *)data; int rc; //fprintf(stderr,"update_display: tx id=%d\n",tx->id); if(tx->displaying) { -#ifdef AUDIO_SAMPLES - if(audio_samples!=NULL) { - GetPixels(CHANNEL_AUDIO,0,audio_samples,&rc); - if(rc) { - audio_waterfall_update(); - } - } -#endif // if "MON" button is active (tx->feedback is TRUE), // then obtain spectrum pixels from PS_RX_FEEDBACK, // that is, display the (attenuated) TX signal from the "antenna" @@ -408,10 +423,20 @@ static gboolean update_display(gpointer data) { transmitter->alc=GetTXAMeter(tx->id, alc); double constant1=3.3; double constant2=0.095; + int fwd_cal_offset=6; - int power; + int fwd_power; + int rev_power; + int ex_power; double v1; + fwd_power=alex_forward_power; + rev_power=alex_reverse_power; + if(device==DEVICE_HERMES_LITE || device==DEVICE_HERMES_LITE2) { + ex_power=0; + } else { + ex_power=exciter_power; + } switch(protocol) { case ORIGINAL_PROTOCOL: switch(device) { @@ -431,31 +456,44 @@ static gboolean update_display(gpointer data) { case DEVICE_ORION: constant1=5.0; constant2=0.108; + fwd_cal_offset=4; break; case DEVICE_ORION2: constant1=5.0; - constant2=0.108; + constant2=0.08; + fwd_cal_offset=18; break; case DEVICE_HERMES_LITE: case DEVICE_HERMES_LITE2: + // possible reversed depending polarity of current sense transformer + if(rev_power>fwd_power) { + fwd_power=alex_reverse_power; + rev_power=alex_forward_power; + } + constant1=3.3; + constant2=1.4; + fwd_cal_offset=6; break; } - power=alex_forward_power; - if(power==0) { - power=exciter_power; + if(fwd_power==0) { + fwd_power=ex_power; } - v1=((double)power/4095.0)*constant1; + fwd_power=fwd_power-fwd_cal_offset; + v1=((double)fwd_power/4095.0)*constant1; transmitter->fwd=(v1*v1)/constant2; - power=exciter_power; - v1=((double)power/4095.0)*constant1; - transmitter->exciter=(v1*v1)/constant2; + if(device==DEVICE_HERMES_LITE || device==DEVICE_HERMES_LITE2) { + transmitter->exciter=0.0; + } else { + ex_power=ex_power-fwd_cal_offset; + v1=((double)ex_power/4095.0)*constant1; + transmitter->exciter=(v1*v1)/constant2; + } transmitter->rev=0.0; - if(alex_forward_power!=0) { - power=alex_reverse_power; - v1=((double)power/4095.0)*constant1; + if(fwd_power!=0) { + v1=((double)rev_power/4095.0)*constant1; transmitter->rev=(v1*v1)/constant2; } break; @@ -480,10 +518,12 @@ static gboolean update_display(gpointer data) { case NEW_DEVICE_ORION: constant1=5.0; constant2=0.108; + fwd_cal_offset=4; break; case NEW_DEVICE_ORION2: constant1=5.0; - constant2=0.108; + constant2=0.08; + fwd_cal_offset=18; break; case NEW_DEVICE_HERMES_LITE: case NEW_DEVICE_HERMES_LITE2: @@ -492,21 +532,23 @@ static gboolean update_display(gpointer data) { break; } - power=alex_forward_power; - if(power==0) { - power=exciter_power; + fwd_power=alex_forward_power; + if(fwd_power==0) { + fwd_power=exciter_power; } - v1=((double)power/4095.0)*constant1; + fwd_power=fwd_power-fwd_cal_offset; + v1=((double)fwd_power/4095.0)*constant1; transmitter->fwd=(v1*v1)/constant2; - power=exciter_power; - v1=((double)power/4095.0)*constant1; + ex_power=exciter_power; + ex_power=ex_power-fwd_cal_offset; + v1=((double)ex_power/4095.0)*constant1; transmitter->exciter=(v1*v1)/constant2; transmitter->rev=0.0; if(alex_forward_power!=0) { - power=alex_reverse_power; - v1=((double)power/4095.0)*constant1; + rev_power=alex_reverse_power; + v1=((double)rev_power/4095.0)*constant1; transmitter->rev=(v1*v1)/constant2; } break; @@ -520,8 +562,12 @@ static gboolean update_display(gpointer data) { #endif } + double fwd=compute_power(transmitter->fwd); + +//g_print("transmitter: meter_update: fwd:%f->%f rev:%f ex_fwd=%d alex_fwd=%d alex_rev=%d\n",transmitter->fwd,fwd,transmitter->rev,exciter_power,alex_forward_power,alex_reverse_power); + if(!duplex) { - meter_update(active_receiver,POWER,transmitter->fwd,transmitter->rev,transmitter->exciter,transmitter->alc); + meter_update(active_receiver,POWER,/*transmitter->*/fwd,transmitter->rev,transmitter->exciter,transmitter->alc); } return TRUE; // keep going @@ -583,7 +629,6 @@ static void init_analyzer(TRANSMITTER *tx) { SetDisplayDetectorMode(tx->id, 0, DETECTOR_MODE_PEAK); SetDisplayAverageMode(tx->id, 0, AVERAGE_MODE_NONE); - } void create_dialog(TRANSMITTER *tx) { @@ -666,6 +711,7 @@ TRANSMITTER *create_transmitter(int id, int buffer_size, int fft_size, int fps, tx->panadapter_high=0; tx->panadapter_low=-60; + tx->panadapter_step=10; tx->displaying=0; @@ -694,11 +740,6 @@ fprintf(stderr,"create_transmitter: id=%d buffer_size=%d mic_sample_rate=%d mic_ tx->deviation=2500; tx->am_carrier_level=0.5; -#ifdef FREEDV - strcpy(tx->freedv_text_data,"Call, Name and Location"); - tx->freedv_samples=0; -#endif - tx->drive=50; tx->tune_percent=10; tx->tune_use_drive=0; @@ -1245,32 +1286,6 @@ void add_ps_iq_samples(TRANSMITTER *tx, double i_sample_tx,double q_sample_tx, d #endif } -#ifdef FREEDV -void add_freedv_mic_sample(TRANSMITTER *tx, float mic_sample) { - int i,s; - - //if(active_receiver->freedv && isTransmitting() && !tune) { - if(!tune) { - if(tx->freedv_samples==0) { - //int modem_samples=mod_sample_freedv(mic_sample); - short vs=(short)((double)mic_sample*pow(10.0, mic_gain / 20.0)); - int modem_samples=mod_sample_freedv(vs); - if(modem_samples!=0) { - for(s=0;sfreedv_samples++; - if(tx->freedv_samples>=freedv_resample) { - tx->freedv_samples=0; - } - } -} -#endif - void tx_set_displaying(TRANSMITTER *tx,int state) { tx->displaying=state; if(state) { diff --git a/transmitter.h b/transmitter.h index 20c62f3..6b75146 100644 --- a/transmitter.h +++ b/transmitter.h @@ -59,6 +59,7 @@ typedef struct _transmitter { int panadapter_low; int panadapter_high; + int panadapter_step; cairo_surface_t *panadapter_surface; @@ -91,12 +92,6 @@ typedef struct _transmitter { int drive_level; -#ifdef FREEDV - char freedv_text_data[64]; - int freedv_text_index; - int freedv_samples; -#endif - int compressor; double compressor_level; diff --git a/tx_menu.c b/tx_menu.c index 5b73ce2..f519912 100644 --- a/tx_menu.c +++ b/tx_menu.c @@ -92,6 +92,10 @@ static void panadapter_low_value_changed_cb(GtkWidget *widget, gpointer data) { transmitter->panadapter_low=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget)); } +static void panadapter_step_value_changed_cb(GtkWidget *widget, gpointer data) { + transmitter->panadapter_step=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget)); +} + static void am_carrier_level_value_changed_cb(GtkWidget *widget, gpointer data) { transmitter->am_carrier_level=gtk_spin_button_get_value(GTK_SPIN_BUTTON(widget)); transmitter_set_am_carrier_level(transmitter); @@ -259,8 +263,74 @@ void tx_menu(GtkWidget *parent) { row++; col=0; - if(protocol==ORIGINAL_PROTOCOL || protocol==NEW_PROTOCOL) { - micin_b=gtk_radio_button_new_with_label_from_widget(NULL,"Mic In"); + if(n_input_devices>0) { + GtkWidget *local_microphone_b=gtk_check_button_new_with_label("Local Microphone"); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (local_microphone_b), transmitter->local_microphone); + gtk_widget_show(local_microphone_b); + gtk_grid_attach(GTK_GRID(grid),local_microphone_b,col,row,1,1); + g_signal_connect(local_microphone_b,"toggled",G_CALLBACK(local_microphone_cb),NULL); + col++; + + input=gtk_combo_box_text_new(); + for(i=0;imicrophone_name!=NULL) { + if(strcmp(transmitter->microphone_name,input_devices[i].name)==0) { + gtk_combo_box_set_active(GTK_COMBO_BOX(input),i); + } + } + } + + // If the combo box shows no device, take the first one + i=gtk_combo_box_get_active(GTK_COMBO_BOX(input)); + if (i < 0) { + gtk_combo_box_set_active(GTK_COMBO_BOX(input),0); + } + + gtk_grid_attach(GTK_GRID(grid),input,col,row,3,1); + g_signal_connect(input,"changed",G_CALLBACK(local_input_changed_cb),NULL); + } + + row++; + col=0; + + gboolean device_has_microphone_input=FALSE; + switch(protocol) { + case ORIGINAL_PROTOCOL: + switch(device) { + case DEVICE_METIS: + case DEVICE_HERMES: + case DEVICE_GRIFFIN: + case DEVICE_ANGELIA: + case DEVICE_ORION: + case DEVICE_ORION2: + device_has_microphone_input=TRUE; + break; + } + break; + case NEW_PROTOCOL: + switch(device) { + case NEW_DEVICE_ATLAS: + case NEW_DEVICE_HERMES: + case NEW_DEVICE_HERMES2: + case NEW_DEVICE_ANGELIA: + case NEW_DEVICE_ORION: + case NEW_DEVICE_ORION2: + device_has_microphone_input=TRUE; + break; + } + break; + } + + if(device_has_microphone_input) { + micboost_b=gtk_check_button_new_with_label("Radio Mic Boost"); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (micboost_b), mic_boost); + gtk_grid_attach(GTK_GRID(grid),micboost_b,col,row,1,1); + g_signal_connect(micboost_b,"toggled",G_CALLBACK(micboost_cb),NULL); + + col++; + + micin_b=gtk_radio_button_new_with_label_from_widget(NULL,"Radio Mic In"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (micin_b), mic_linein==0); gtk_widget_show(micin_b); gtk_grid_attach(GTK_GRID(grid),micin_b,col,row,1,1); @@ -268,7 +338,7 @@ void tx_menu(GtkWidget *parent) { col++; - linein_b=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(micin_b),"Line In"); + linein_b=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(micin_b),"Radio Line In"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (linein_b), mic_linein==1); gtk_widget_show(linein_b); gtk_grid_attach(GTK_GRID(grid),linein_b,col,row,1,1); @@ -277,14 +347,6 @@ void tx_menu(GtkWidget *parent) { row++; col=0; - micboost_b=gtk_check_button_new_with_label("Mic Boost (radio only)"); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (micboost_b), mic_boost); - gtk_grid_attach(GTK_GRID(grid),micboost_b,col,row,2,1); - g_signal_connect(micboost_b,"toggled",G_CALLBACK(micboost_cb),NULL); - - row++; - col=0; - } @@ -300,18 +362,12 @@ void tx_menu(GtkWidget *parent) { gtk_grid_attach(GTK_GRID(grid),comp,col,row,1,1); g_signal_connect(comp,"value-changed",G_CALLBACK(comp_cb),NULL); + row++; col=0; - GtkWidget *label=gtk_label_new("TX Filter: "); -#ifdef GTK316 - gtk_label_set_xalign(GTK_LABEL(label),0); -#endif - gtk_grid_attach(GTK_GRID(grid),label,col,row,1,1); - - col++; - GtkWidget *use_rx_filter_b=gtk_check_button_new_with_label("Use RX filter"); + GtkWidget *use_rx_filter_b=gtk_check_button_new_with_label("Use RX Filter"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (use_rx_filter_b), transmitter->use_rx_filter); gtk_widget_show(use_rx_filter_b); gtk_grid_attach(GTK_GRID(grid),use_rx_filter_b,col,row,1,1); @@ -319,6 +375,14 @@ void tx_menu(GtkWidget *parent) { col++; + GtkWidget *label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(label), "TX Filter: "); +#ifdef GTK316 + gtk_label_set_xalign(GTK_LABEL(label),0); +#endif + gtk_grid_attach(GTK_GRID(grid),label,col,row,1,1); + + col++; tx_spin_low=gtk_spin_button_new_with_range(0.0,8000.0,1.0); gtk_spin_button_set_value(GTK_SPIN_BUTTON(tx_spin_low),(double)tx_filter_low); gtk_grid_attach(GTK_GRID(grid),tx_spin_low,col,row,1,1); @@ -343,39 +407,8 @@ void tx_menu(GtkWidget *parent) { int saved_row=row; - if(n_input_devices>0) { - GtkWidget *local_microphone_b=gtk_check_button_new_with_label("Local Microphone Input"); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (local_microphone_b), transmitter->local_microphone); - gtk_widget_show(local_microphone_b); - gtk_grid_attach(GTK_GRID(grid),local_microphone_b,col,row++,2,1); - g_signal_connect(local_microphone_b,"toggled",G_CALLBACK(local_microphone_cb),NULL); - - input=gtk_combo_box_text_new(); - for(i=0;imicrophone_name!=NULL) { - if(strcmp(transmitter->microphone_name,input_devices[i].name)==0) { - gtk_combo_box_set_active(GTK_COMBO_BOX(input),i); - } - } - } - - // If the combo box shows no device, take the first one - i=gtk_combo_box_get_active(GTK_COMBO_BOX(input)); - if (i < 0) { - gtk_combo_box_set_active(GTK_COMBO_BOX(input),0); - } - - gtk_grid_attach(GTK_GRID(grid),input,col,row++,1,1); - g_signal_connect(input,"changed",G_CALLBACK(local_input_changed_cb),NULL); - - - } - - row=saved_row; - col=3; - - GtkWidget *panadapter_high_label=gtk_label_new("Panadapter High: "); + GtkWidget *panadapter_high_label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(panadapter_high_label), "Panadapter High: "); #ifdef GTK316 gtk_label_set_xalign(GTK_LABEL(panadapter_high_label),0); #endif @@ -384,16 +417,8 @@ void tx_menu(GtkWidget *parent) { col++; - GtkWidget *panadapter_high_r=gtk_spin_button_new_with_range(-220.0,100.0,1.0); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(panadapter_high_r),(double)transmitter->panadapter_high); - gtk_widget_show(panadapter_high_r); - gtk_grid_attach(GTK_GRID(grid),panadapter_high_r,col,row,1,1); - g_signal_connect(panadapter_high_r,"value_changed",G_CALLBACK(panadapter_high_value_changed_cb),NULL); - - row++; - col=3; - - GtkWidget *panadapter_low_label=gtk_label_new("Panadapter Low: "); + GtkWidget *panadapter_low_label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(panadapter_low_label), "Panadapter Low: "); #ifdef GTK316 gtk_label_set_xalign(GTK_LABEL(panadapter_low_label),0); #endif @@ -402,16 +427,44 @@ void tx_menu(GtkWidget *parent) { col++; + GtkWidget *panadapter_step_label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(panadapter_step_label), "Panadapter Step: "); +#ifdef GTK316 + gtk_label_set_xalign(GTK_LABEL(panadapter_step_label),0); +#endif + gtk_widget_show(panadapter_step_label); + gtk_grid_attach(GTK_GRID(grid),panadapter_step_label,col,row,1,1); + + row++; + col=0; + + GtkWidget *panadapter_high_r=gtk_spin_button_new_with_range(-220.0,100.0,1.0); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(panadapter_high_r),(double)transmitter->panadapter_high); + gtk_widget_show(panadapter_high_r); + gtk_grid_attach(GTK_GRID(grid),panadapter_high_r,col,row,1,1); + g_signal_connect(panadapter_high_r,"value_changed",G_CALLBACK(panadapter_high_value_changed_cb),NULL); + + col++; + GtkWidget *panadapter_low_r=gtk_spin_button_new_with_range(-400.0,100.0,1.0); gtk_spin_button_set_value(GTK_SPIN_BUTTON(panadapter_low_r),(double)transmitter->panadapter_low); gtk_widget_show(panadapter_low_r); gtk_grid_attach(GTK_GRID(grid),panadapter_low_r,col,row,1,1); g_signal_connect(panadapter_low_r,"value_changed",G_CALLBACK(panadapter_low_value_changed_cb),NULL); + col++; + + GtkWidget *panadapter_step_r=gtk_spin_button_new_with_range(-400.0,100.0,1.0); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(panadapter_step_r),(double)transmitter->panadapter_step); + gtk_widget_show(panadapter_step_r); + gtk_grid_attach(GTK_GRID(grid),panadapter_step_r,col,row,1,1); + g_signal_connect(panadapter_step_r,"value_changed",G_CALLBACK(panadapter_step_value_changed_cb),NULL); + row++; - col=3; + col=0; - GtkWidget *am_carrier_level_label=gtk_label_new("AM Carrier Level: "); + GtkWidget *am_carrier_level_label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(am_carrier_level_label), "AM Carrier Level:"); #ifdef GTK316 gtk_label_set_xalign(GTK_LABEL(am_carrier_level_label),0); #endif @@ -427,7 +480,7 @@ void tx_menu(GtkWidget *parent) { g_signal_connect(am_carrier_level,"value_changed",G_CALLBACK(am_carrier_level_value_changed_cb),NULL); row++; - col=3; + col=0; GtkWidget *emp_b=gtk_check_button_new_with_label("FM TX Pre-emphasize before limiting"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (emp_b), pre_emphasize); @@ -436,7 +489,7 @@ void tx_menu(GtkWidget *parent) { g_signal_connect(emp_b,"toggled",G_CALLBACK(emp_cb),NULL); row++; - col=3; + col=0; GtkWidget *ctcss_b=gtk_check_button_new_with_label("CTCSS Enable"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ctcss_b), transmitter->ctcss); @@ -451,7 +504,7 @@ void tx_menu(GtkWidget *parent) { g_signal_connect(ctcss_spin,"value-changed",G_CALLBACK(ctcss_spin_cb),NULL); row++; - col=3; + col=0; GtkWidget *tune_use_drive_b=gtk_check_button_new_with_label("Tune use drive"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tune_use_drive_b), transmitter->tune_use_drive); @@ -460,9 +513,10 @@ void tx_menu(GtkWidget *parent) { g_signal_connect(tune_use_drive_b,"toggled",G_CALLBACK(tune_use_drive_cb),NULL); row++; - col=3; + col=0; - GtkWidget *tune_percent_label=gtk_label_new("Tune Percent: "); + GtkWidget *tune_percent_label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(tune_percent_label), "Tune Percent:"); #ifdef GTK316 gtk_label_set_xalign(GTK_LABEL(tune_percent_label),0); #endif diff --git a/tx_panadapter.c b/tx_panadapter.c index 9021642..202e7f8 100644 --- a/tx_panadapter.c +++ b/tx_panadapter.c @@ -35,9 +35,6 @@ #include "tx_panadapter.h" #include "vfo.h" #include "mode.h" -#ifdef FREEDV -#include "freedv.h" -#endif #ifdef GPIO #include "gpio.h" #endif @@ -186,6 +183,7 @@ void tx_panadapter_update(TRANSMITTER *tx) { int display_width=gtk_widget_get_allocated_width (tx->panadapter); int display_height=gtk_widget_get_allocated_height (tx->panadapter); + int txvfo = get_tx_vfo(); int txmode = get_tx_mode(); @@ -210,8 +208,10 @@ void tx_panadapter_update(TRANSMITTER *tx) { } - // plot the levels 0, -20, 40, ... dBm (turquoise line with label) - // plot the levels -10, -30, -50, ... dBm (dark turquoise line without label) + // plot the levels 0, -20, 40, ... dBm (bright turquoise line with label) + // additionally, plot the levels in steps of the chosen panadapter step size + // (dark turquoise line without label) + double dbm_per_line=(double)display_height/((double)tx->panadapter_high-(double)tx->panadapter_low); cairo_set_source_rgb (cr, 0.00, 1.00, 1.00); cairo_set_line_width(cr, 1.0); @@ -220,7 +220,7 @@ void tx_panadapter_update(TRANSMITTER *tx) { for(i=tx->panadapter_high;i>=tx->panadapter_low;i--) { char v[32]; - if((abs(i)%10) ==0) { + if((abs(i)%tx->panadapter_step) ==0) { double y = (double)(tx->panadapter_high-i)*dbm_per_line; if ((abs(i) % 20) == 0) { cairo_set_source_rgb (cr, 0.00, 1.00, 1.00); @@ -232,7 +232,7 @@ void tx_panadapter_update(TRANSMITTER *tx) { cairo_show_text(cr, v); cairo_stroke(cr); } else { - cairo_set_source_rgb (cr, 0.00, 0.66, 0.66); + cairo_set_source_rgb (cr, 0.00, 0.50, 0.50); cairo_move_to(cr,0.0,y); cairo_line_to(cr,(double)display_width,y); cairo_stroke(cr); @@ -260,8 +260,8 @@ void tx_panadapter_update(TRANSMITTER *tx) { } } - cairo_text_extents_t extents; // used also in FREEDV code #ifdef TX_FREQ_MARKERS + cairo_text_extents_t extents; long long f; long long divisor=50000; for(i=0;ifreedv) { - cairo_set_source_rgb(cr, 1.0, 0.0, 0.0); - cairo_set_font_size(cr, 16); - cairo_text_extents(cr, transmitter->freedv_text_data, &extents); - cairo_move_to(cr, (double)display_width/2.0-(extents.width/2.0),(double)display_height-2.0); - cairo_show_text(cr, transmitter->freedv_text_data); - } -#endif +#ifdef GPIO + if(controller==CONTROLLER1 && !duplex) { + char text[64]; -#if !defined (CONTROLLER2_V2) && !defined (CONTROLLER2_V1) && defined (GPIO) - cairo_set_source_rgb(cr,1.0,1.0,0.0); - cairo_set_font_size(cr,16); - if(ENABLE_E2_ENCODER) { - cairo_move_to(cr, display_width-150,30); - cairo_show_text(cr, encoder_string[e2_encoder_action]); - } + cairo_set_source_rgb(cr,1.0,1.0,0.0); + cairo_set_font_size(cr,16); + if(ENABLE_E2_ENCODER) { + cairo_move_to(cr, display_width-200,30); + sprintf(text,"%s (%s)",encoder_string[e2_encoder_action],sw_string[e2_sw_action]); + cairo_show_text(cr, text); + } - if(ENABLE_E3_ENCODER) { - cairo_move_to(cr, display_width-150,50); - cairo_show_text(cr, encoder_string[e3_encoder_action]); - } + if(ENABLE_E3_ENCODER) { + cairo_move_to(cr, display_width-200,50); + sprintf(text,"%s (%s)",encoder_string[e3_encoder_action],sw_string[e3_sw_action]); + cairo_show_text(cr, text); + } - if(ENABLE_E4_ENCODER) { - cairo_move_to(cr, display_width-150,70); - cairo_show_text(cr, encoder_string[e4_encoder_action]); + if(ENABLE_E4_ENCODER) { + cairo_move_to(cr, display_width-200,70); + sprintf(text,"%s (%s)",encoder_string[e4_encoder_action],sw_string[e4_sw_action]); + cairo_show_text(cr, text); + } } #endif + #ifdef PURESIGNAL if(tx->puresignal) { cairo_set_source_rgb(cr,0.0,1.0,0.0); @@ -403,7 +401,11 @@ void tx_panadapter_update(TRANSMITTER *tx) { cairo_set_source_rgb(cr,1.0,0.0,0.0); cairo_set_font_size(cr, 16); - sprintf(text,"FWD: %0.3f",transmitter->fwd); + if(transmitter->fwd<0.0001) { + sprintf(text,"FWD: %0.3f",transmitter->exciter); + } else { + sprintf(text,"FWD: %0.3f",transmitter->fwd); + } cairo_move_to(cr,10,15); cairo_show_text(cr, text); @@ -414,6 +416,16 @@ void tx_panadapter_update(TRANSMITTER *tx) { sprintf(text,"ALC: %0.3f",transmitter->alc); cairo_move_to(cr,10,45); cairo_show_text(cr, text); + +/* + sprintf(text,"FWD: %0.8f",transmitter->fwd); + cairo_move_to(cr,10,60); + cairo_show_text(cr, text); + + sprintf(text,"EXC: %0.3f",transmitter->exciter); + cairo_move_to(cr,10,75); + cairo_show_text(cr, text); +*/ } cairo_destroy (cr); diff --git a/version.c b/version.c index a6762d4..dab4095 100644 --- a/version.c +++ b/version.c @@ -20,12 +20,21 @@ char build_date[]=GIT_DATE; char build_version[]=GIT_VERSION; -#if defined (CONTROLLER2_V1) -char version[]="2.0.7-beta (Controller2 V1)"; -#elif defined (CONTROLLER2_V2) -char version[]="2.0.7-beta (Controller2 V2)"; -#elif defined (GPIO) -char version[]="2.0.7-beta (Controller1)"; -#else -char version[]="2.0.7-beta"; +char version[]="2.0.0-RC1" +#if defined(GPIO) || defined(PURESIGNAL) || defined(SOAPYSDR) || defined(MIDI) +" includes" #endif +#ifdef GPIO +" GPIO" +#endif +#ifdef PURESIGNAL +" PURESIGNAL" +#endif +#ifdef SOAPYSDR +" SOAPYSDR" +#endif +#ifdef MIDI +" MIDI" +#endif + +; diff --git a/vfo.c b/vfo.c index 598900f..adf3b15 100644 --- a/vfo.c +++ b/vfo.c @@ -38,7 +38,6 @@ #include "filter.h" #include "bandstack.h" #include "band.h" -#include "frequency.h" #include "new_protocol.h" #include "property.h" #include "radio.h" @@ -50,9 +49,6 @@ #include "new_menu.h" #include "rigctl.h" #include "ext.h" -#ifdef FREEDV -#include "freedv.h" -#endif static GtkWidget *parent_window; static int my_width; @@ -196,23 +192,28 @@ void vfo_restore_state() { char *value; for(i=0;iprotocol==SOAPYSDR_PROTOCOL) { + vfo[i].band=band144; + vfo[i].bandstack=0; vfo[i].frequency=144010000; } #endif vfo[i].mode=modeCWU; - vfo[i].filter=6; + vfo[i].filter=filterF6; vfo[i].lo=0; vfo[i].offset=0; vfo[i].rit_enabled=0; vfo[i].rit=0; vfo[i].ctun=0; +g_print("vfo_restore_state: band=%d frequency=%lld\n",vfo[i].band,vfo[i].frequency); + sprintf(name,"vfo.%d.band",i); value=getProperty(name); if(value) vfo[i].band=atoi(value); @@ -363,7 +364,7 @@ void vfo_bandstack_changed(int b) { } if(can_transmit) { - tx_set_mode(transmitter,get_tx_mode()); + tx_set_mode(transmitter,get_tx_mode()); } // // I do not think the band can change within this function. @@ -406,7 +407,7 @@ void vfo_mode_changed(int m) { break; } if(can_transmit) { - tx_set_mode(transmitter,get_tx_mode()); + tx_set_mode(transmitter,get_tx_mode()); } // // changing modes may change BFO frequency @@ -827,23 +828,12 @@ void vfo_update() { CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD); - char dv[32]; - strcpy(dv,""); -#ifdef FREEDV - if(active_receiver->freedv) { - sprintf(dv,"FreeDV %s", freedv_get_mode_string()); - } -#endif - cairo_set_font_size(cr, 12); - cairo_set_source_rgb(cr, 1.0, 1.0, 0.0); - cairo_move_to(cr, 5, 15); - switch(vfo[id].mode) { case modeFMN: if(active_receiver->deviation==2500) { - sprintf(temp_text,"%s 8k %s",mode_string[vfo[id].mode],dv); + sprintf(temp_text,"%s 8k",mode_string[vfo[id].mode]); } else { - sprintf(temp_text,"%s 16k %s",mode_string[vfo[id].mode],dv); + sprintf(temp_text,"%s 16k",mode_string[vfo[id].mode]); } break; case modeCWL: @@ -854,7 +844,7 @@ void vfo_update() { case modeUSB: case modeDSB: case modeAM: - sprintf(temp_text,"%s %s %s",mode_string[vfo[id].mode],band_filter->title,dv); + sprintf(temp_text,"%s %s",mode_string[vfo[id].mode],band_filter->title); break; default: sprintf(temp_text,"%s %s",mode_string[vfo[id].mode],band_filter->title); @@ -865,7 +855,7 @@ void vfo_update() { // In what follows, we want to display the VFO frequency // on which we currently transmit a signal with red colour. // If it is out-of-band, we display "Out of band" in red. - // Frequencies we are not transmitting on are displayed in green + // Frequencies we are not transmitting on are displayed in green // (dimmed if the freq. does not belong to the active receiver). // Frequencies of VFO A and B @@ -875,9 +865,7 @@ void vfo_update() { int oob=0; if (can_transmit) oob=transmitter->out_of_band; - sprintf(temp_text,"VFO A: %0lld.%06lld",af/(long long)1000000,af%(long long)1000000); - if(txvfo == 0 && (isTransmitting() || oob)) { if (oob) sprintf(temp_text,"VFO A: Out of band"); cairo_set_source_rgb(cr, 1.0, 0.0, 0.0); diff --git a/vfo_menu.c b/vfo_menu.c index 8744a27..209873d 100644 --- a/vfo_menu.c +++ b/vfo_menu.c @@ -35,9 +35,6 @@ #include "vfo.h" #include "button_text.h" #include "ext.h" -#ifdef FREEDV -#include "freedv.h" -#endif static GtkWidget *parent_window=NULL; static GtkWidget *dialog=NULL; @@ -183,12 +180,6 @@ static void vfo_cb(GtkComboBox *widget,gpointer data) { g_idle_add(ext_vfo_update,NULL); } -#ifdef FREEDV -static void enable_freedv_cb(GtkWidget *widget, gpointer data) { - set_freedv(gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))); -} -#endif - #ifdef PURESIGNAL static void enable_ps_cb(GtkWidget *widget, gpointer data) { tx_set_ps(transmitter,gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))); @@ -306,13 +297,6 @@ void vfo_menu(GtkWidget *parent) { gtk_grid_attach(GTK_GRID(grid),enable_squelch,3,5,1,1); g_signal_connect(enable_squelch,"toggled",G_CALLBACK(squelch_enable_cb),NULL); -#ifdef FREEDV - GtkWidget *enable_freedv=gtk_check_button_new_with_label("Enable FreeDV"); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (enable_freedv), active_receiver->freedv); - gtk_grid_attach(GTK_GRID(grid),enable_freedv,3,6,1,1); - g_signal_connect(enable_freedv,"toggled",G_CALLBACK(enable_freedv_cb),NULL); -#endif - #ifdef PURESIGNAL if(can_transmit) { GtkWidget *enable_ps=gtk_check_button_new_with_label("Enable Pure Signal"); diff --git a/vox_menu.c b/vox_menu.c index 4b10114..5bba3ee 100644 --- a/vox_menu.c +++ b/vox_menu.c @@ -176,7 +176,8 @@ void vox_menu(GtkWidget *parent) { g_signal_connect (enable_b, "pressed", G_CALLBACK(enable_cb), NULL); gtk_grid_attach(GTK_GRID(grid),enable_b,3,0,1,1); - GtkWidget *level_label=gtk_label_new("Mic Level:"); + GtkWidget *level_label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(level_label), "Mic Level:"); gtk_misc_set_alignment (GTK_MISC(level_label), 0, 0); gtk_widget_show(level_label); gtk_grid_attach(GTK_GRID(grid),level_label,0,1,1,1); @@ -186,24 +187,28 @@ void vox_menu(GtkWidget *parent) { gtk_widget_show(level); gtk_grid_attach(GTK_GRID(grid),level,1,1,3,1); - GtkWidget *threshold_label=gtk_label_new("VOX Threshold:"); + GtkWidget *threshold_label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(threshold_label), "VOX Threshold:"); gtk_misc_set_alignment (GTK_MISC(threshold_label), 0, 0); gtk_widget_show(threshold_label); gtk_grid_attach(GTK_GRID(grid),threshold_label,0,2,1,1); GtkWidget *vox_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,0.0,1000.0,1.0); // gtk_widget_set_size_request (vox_scale, 300, 25); + gtk_range_set_increments (GTK_RANGE(vox_scale),1.0,1.0); gtk_range_set_value(GTK_RANGE(vox_scale),vox_threshold*1000.0); gtk_widget_show(vox_scale); gtk_grid_attach(GTK_GRID(grid),vox_scale,1,2,3,1); g_signal_connect(G_OBJECT(vox_scale),"value_changed",G_CALLBACK(vox_value_changed_cb),NULL); - GtkWidget *hang_label=gtk_label_new("VOX Hang (ms):"); + GtkWidget *hang_label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(hang_label), "VOX Hand (ms):"); gtk_misc_set_alignment (GTK_MISC(hang_label), 0, 0); gtk_widget_show(hang_label); gtk_grid_attach(GTK_GRID(grid),hang_label,0,4,1,1); GtkWidget *vox_hang_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,0.0,1000.0,1.0); + gtk_range_set_increments (GTK_RANGE(vox_hang_scale),1.0,1.0); gtk_range_set_value(GTK_RANGE(vox_hang_scale),vox_hang); gtk_widget_show(vox_hang_scale); gtk_grid_attach(GTK_GRID(grid),vox_hang_scale,1,4,3,1); diff --git a/xvtr_menu.c b/xvtr_menu.c index c9ce2e6..805ded7 100644 --- a/xvtr_menu.c +++ b/xvtr_menu.c @@ -237,23 +237,23 @@ fprintf(stderr,"xvtr_menu\n"); g_signal_connect (close_b, "pressed", G_CALLBACK(close_cb), NULL); gtk_grid_attach(GTK_GRID(grid),close_b,0,0,1,1); - GtkWidget *label=gtk_label_new("Title"); + GtkWidget *label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(label), "Title"); gtk_grid_attach(GTK_GRID(grid),label,0,1,1,1); - label=gtk_label_new("Min Freq(MHz)"); + label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(label), "Min Freq(MHz)"); gtk_grid_attach(GTK_GRID(grid),label,1,1,1,1); - label=gtk_label_new("Max Freq(MHz)"); + label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(label), "Max Freq(MHz)"); gtk_grid_attach(GTK_GRID(grid),label,2,1,1,1); - label=gtk_label_new("LO Freq(MHz)"); + label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(label), "LO Freq(MHz)"); gtk_grid_attach(GTK_GRID(grid),label,3,1,1,1); - label=gtk_label_new("LO Err(Hz)"); + label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(label), "LO Err(MHz)"); gtk_grid_attach(GTK_GRID(grid),label,4,1,1,1); -/* - label=gtk_label_new("TX LO Freq(MHz)"); - gtk_grid_attach(GTK_GRID(grid),label,5,1,1,1); - label=gtk_label_new("TX LO Err(Hz)"); - gtk_grid_attach(GTK_GRID(grid),label,6,1,1,1); -*/ - label=gtk_label_new("Disable PA"); + label=gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(label), "Disable PA"); gtk_grid_attach(GTK_GRID(grid),label,7,1,1,1); @@ -293,22 +293,6 @@ fprintf(stderr,"xvtr_menu\n"); gtk_grid_attach(GTK_GRID(grid),lo_error[i],4,i+2,1,1); g_signal_connect(lo_error[i],"changed",G_CALLBACK(lo_error_cb),GINT_TO_POINTER(i)); -/* - tx_lo_frequency[i]=gtk_entry_new(); - gtk_entry_set_width_chars(GTK_ENTRY(tx_lo_frequency[i]),7); - sprintf(f,"%5.3f",(double)xvtr->txFrequencyLO/1000000.0); - gtk_entry_set_text(GTK_ENTRY(tx_lo_frequency[i]),f); - gtk_grid_attach(GTK_GRID(grid),tx_lo_frequency[i],5,i+2,1,1); - g_signal_connect(tx_lo_frequency[i],"changed",G_CALLBACK(tx_lo_frequency_cb),GINT_TO_POINTER(i)); - - tx_lo_error[i]=gtk_entry_new(); - gtk_entry_set_width_chars(GTK_ENTRY(tx_lo_error[i]),9); - sprintf(f,"%lld",xvtr->txErrorLO); - gtk_entry_set_text(GTK_ENTRY(tx_lo_error[i]),f); - gtk_grid_attach(GTK_GRID(grid),tx_lo_error[i],6,i+2,1,1); - g_signal_connect(tx_lo_error[i],"changed",G_CALLBACK(tx_lo_error_cb),GINT_TO_POINTER(i)); -*/ - disable_pa[i]=gtk_check_button_new(); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(disable_pa[i]),xvtr->disablePA); gtk_grid_attach(GTK_GRID(grid),disable_pa[i],7,i+2,1,1); -- 2.45.2