From a3b62bff905d2272f0f67d0e8fec5fb8f779cff9 Mon Sep 17 00:00:00 2001 From: c vw Date: Fri, 23 Jul 2021 15:20:05 +0200 Subject: [PATCH] Further preparations for "big merge", and small corrections --- Makefile | 145 ++++++++++++----------- actions.h | 122 ++++++++++++++++++- alsa_midi.c | 20 ++-- encoder_menu.c | 5 + ext.h | 5 + gpio.c | 2 + gpio.h | 100 ---------------- i2c.c | 3 + mac_midi.c | 21 ++-- midi.h | 27 +++-- midi2.c | 292 +++++++++++++++++++++++----------------------- midi3.c | 102 ++++++++-------- midi_menu.c | 143 +++++++++++------------ new_menu.c | 11 +- new_menu.h | 3 +- radio.c | 23 ---- radio_menu.c | 8 +- rx_menu.c | 3 - rx_panadapter.c | 1 + sliders.c | 96 +++++++-------- sliders.h | 19 --- soapy_discovery.c | 32 +---- switch_menu.c | 1 + toolbar.c | 1 + zoompan.c | 13 ++- 25 files changed, 599 insertions(+), 599 deletions(-) diff --git a/Makefile b/Makefile index 9ece661..2d8d819 100644 --- a/Makefile +++ b/Makefile @@ -52,6 +52,8 @@ MIDI_INCLUDE=MIDI #SERVER_INCLUDE=SERVER CFLAGS?= -O -Wno-deprecated-declarations +LINK?= $(CC) + PKG_CONFIG = pkg-config ifeq ($(MIDI_INCLUDE),MIDI) @@ -103,6 +105,7 @@ USBOZY_OBJS= \ ozyio.o endif + ifeq ($(SOAPYSDR_INCLUDE),SOAPYSDR) SOAPYSDR_OPTIONS=-D SOAPYSDR SOAPYSDRLIBS=-lSoapySDR @@ -117,36 +120,20 @@ soapy_discovery.o \ soapy_protocol.o endif +ifeq ($(LOCALCW_INCLUDE),LOCALCW) +LOCALCW_OPTIONS=-D LOCALCW +LOCALCW_SOURCES= iambic.c +LOCALCW_HEADERS= iambic.h +LOCALCW_OBJS = iambic.o +endif + ifeq ($(PTT_INCLUDE),PTT) PTT_OPTIONS=-D PTT endif ifeq ($(GPIO_INCLUDE),GPIO) -GPIOD_VERSION=$(shell pkg-config --modversion libgpiod) -ifeq ($(GPIOD_VERSION),1.2) -GPIOD_OPTIONS=-D OLD_GPIOD -endif GPIO_OPTIONS=-D GPIO GPIO_LIBS=-lwiringPi -GPIO_SOURCES= \ - configure.c \ - i2c.c \ - encoder_menu.c -GPIO_HEADERS= \ - configure.h \ - i2c.h \ - encoder_menu.h -GPIO_OBJS= \ - configure.o \ - i2c.o \ - encoder_menu.o -endif - -ifeq ($(LOCALCW_INCLUDE),LOCALCW) -LOCALCW_OPTIONS=-D LOCALCW -LOCALCW_SOURCES= iambic.c -LOCALCW_HEADERS= iambic.h -LOCALCW_OBJS = iambic.o endif # @@ -187,7 +174,9 @@ GTKINCLUDES=$(shell $(PKG_CONFIG) --cflags gtk+-3.0) GTKLIBS=$(shell $(PKG_CONFIG) --libs gtk+-3.0) # -# MacOS: only PORTAUDIO +# set options for audio module +# - MacOS: only PORTAUDIO +# - Linux: either ALSA or PULSEAUDIO # ifeq ($(UNAME_S), Darwin) AUDIO_MODULE=PORTAUDIO @@ -225,20 +214,27 @@ AUDIO_SOURCES=portaudio.c AUDIO_OBJS=portaudio.o endif +OPTIONS=$(SMALL_SCREEN_OPTIONS) $(MIDI_OPTIONS) $(PURESIGNAL_OPTIONS) $(REMOTE_OPTIONS) $(USBOZY_OPTIONS) \ + $(GPIO_OPTIONS) $(SOAPYSDR_OPTIONS) $(LOCALCW_OPTIONS) \ + $(STEMLAB_OPTIONS) $(PTT_OPTIONS) \ + $(SERVER_OPTIONS) \ + $(AUDIO_OPTIONS) \ + -D GIT_DATE='"$(GIT_DATE)"' -D GIT_VERSION='"$(GIT_VERSION)"' $(DEBUG_OPTION) + +# +# Specify additional OS-dependent system libraries +# + ifeq ($(UNAME_S), Linux) SYSLIBS=-lrt endif + ifeq ($(UNAME_S), Darwin) SYSLIBS=-framework IOKit endif -OPTIONS=$(SMALL_SCREEN_OPTIONS) $(MIDI_OPTIONS) $(PURESIGNAL_OPTIONS) $(REMOTE_OPTIONS) $(USBOZY_OPTIONS) \ - $(GPIO_OPTIONS) $(GPIOD_OPTIONS) $(SOAPYSDR_OPTIONS) $(LOCALCW_OPTIONS) \ - $(STEMLAB_OPTIONS) $(PTT_OPTIONS) $(SERVER_OPTIONS) $(AUDIO_OPTIONS) $(GPIO_OPTIONS) \ - -D GIT_DATE='"$(GIT_DATE)"' -D GIT_VERSION='"$(GIT_VERSION)"' $(DEBUG_OPTION) - -LIBS= -lm -lwdsp -lpthread $(SYSLIBS) $(AUDIO_LIBS) $(USBOZY_LIBS) $(GTKLIBS) \ - $(GPIO_LIBS) $(SOAPYSDRLIBS) $(STEMLAB_LIBS) $(MIDI_LIBS) +LIBS= $(LDFLAGS) $(AUDIO_LIBS) $(USBOZY_LIBS) $(GTKLIBS) $(GPIO_LIBS) $(SOAPYSDRLIBS) $(STEMLAB_LIBS) \ + $(MIDI_LIBS) -lwdsp -lpthread -lm $(SYSLIBS) INCLUDES=$(GTKINCLUDES) COMPILE=$(CC) $(CFLAGS) $(OPTIONS) $(INCLUDES) @@ -316,8 +312,11 @@ cwramp.c \ protocols.c \ css.c \ actions.c \ -switch_menu.c \ -gpio.c +configure.c \ +is2.c \ +gpio.c \ +encoder_menu.c \ +switch_menu.c HEADERS= \ @@ -387,9 +386,13 @@ led.h \ ext.h \ error_handler.h \ protocols.h \ +css.h \ actions.h \ -switch_menu.h \ -gpio.h +configure.h \ +i2c.h \ +gpio.h \ +encoder_menu.h \ +switch_menu.h OBJS= \ @@ -460,25 +463,28 @@ cwramp.o \ protocols.o \ css.o \ actions.o \ -switch_menu.o \ -gpio.o +configure.o \ +i2c.o \ +gpio.o \ +encoder_menu.o \ +switch_menu.o $(PROGRAM): $(OBJS) $(AUDIO_OBJS) $(REMOTE_OBJS) $(USBOZY_OBJS) $(SOAPYSDR_OBJS) \ - $(LOCALCW_OBJS) $(PURESIGNAL_OBJS) $(GPIO_OBJS) \ + $(LOCALCW_OBJS) $(PURESIGNAL_OBJS) \ $(MIDI_OBJS) $(STEMLAB_OBJS) $(SERVER_OBJS) - $(CC) -o $(PROGRAM) $(OBJS) $(AUDIO_OBJS) $(REMOTE_OBJS) $(USBOZY_OBJS) \ - $(SOAPYSDR_OBJS) $(LOCALCW_OBJS) $(PURESIGNAL_OBJS) $(GPIO_OBJS) \ - $(MIDI_OBJS) $(STEMLAB_OBJS) $(SERVER_OBJS) $(LIBS) $(LDFLAGS) + $(LINK) -o $(PROGRAM) $(OBJS) $(AUDIO_OBJS) $(REMOTE_OBJS) $(USBOZY_OBJS) \ + $(SOAPYSDR_OBJS) $(LOCALCW_OBJS) $(PURESIGNAL_OBJS) \ + $(MIDI_OBJS) $(STEMLAB_OBJS) $(SERVER_OBJS) $(LIBS) -.PHONY: all -all: prebuild $(PROGRAM) $(HEADERS) $(AUDIO_HEADERS) $(USBOZY_HEADERS) $(SOAPYSDR_HEADERS) \ - $(LOCALCW_HEADERS) $(GPIO_HEADERS) \ +.PHONY: all +all: prebuild $(PROGRAM) $(HEADERS) $(AUDIO_HEADERS) $(USBOZY_HEADERS) $(SOAPYSDR_HEADERS) \ + $(LOCALCW_HEADERS) \ $(PURESIGNAL_HEADERS) $(MIDI_HEADERS) $(STEMLAB_HEADERS) $(SERVER_HEADERS) \ - $(AUDIO_SOURCES) $(SOURCES) $(GPIO_SOURCES) \ + $(AUDIO_SOURCES) $(SOURCES) \ $(USBOZY_SOURCES) $(SOAPYSDR_SOURCES) $(LOCALCW_SOURCE) \ $(PURESIGNAL_SOURCES) $(MIDI_SOURCES) $(STEMLAB_SOURCES) $(SERVER_SOURCES) -.PHONY: prebuild +.PHONY: rebuild prebuild: rm -f version.o @@ -488,47 +494,56 @@ prebuild: # Therefore, correct this here. Furthermore, we can add additional options to CPP # in the variable CPPOPTIONS # -CPPOPTIONS= --enable=all --suppress=shadowVariable --suppress=variableScope -D__APPLE__ +CPPOPTIONS= --enable=all --suppress=shadowVariable --suppress=variableScope +ifeq ($(UNAME_S), Darwin) +CPPOPTIONS += -D__APPLE__ +endif CPPINCLUDES:=$(shell echo $(INCLUDES) | sed -e "s/-pthread / /" ) .PHONY: cppcheck cppcheck: - cppcheck $(CPPOPTIONS) $(OPTIONS) $(CPPINCLUDES) $(SOURCES) $(REMOTE_SOURCES) \ - $(USBOZY_SOURCES) $(SOAPYSDR_SOURCES) $(SERVER_SOURCES) \ - $(PURESIGNAL_SOURCES) $(MIDI_SOURCES) $(STEMLAB_SOURCES) $(LOCALCW_SOURCES) + cppcheck $(CPPOPTIONS) $(OPTIONS) $(CPPINCLUDES) $(AUDIO_SOURCES) $(SOURCES) $(REMOTE_SOURCES) \ + $(USBOZY_SOURCES) $(SOAPYSDR_SOURCES) \ + $(PURESIGNAL_SOURCES) $(MIDI_SOURCES) $(STEMLAB_SOURCES) $(LOCALCW_SOURCES) \ + $(SERVER_SOURCES) -.PHONY: clean +.PHONY: clean clean: -rm -f *.o -rm -f $(PROGRAM) hpsdrsim -rm -rf $(PROGRAM).app -.PHONY: install +# +# If $DESTDIR is set, copy to that directory, otherwise use /usr/local/bin +# +DESTDIR?= /usr/local/bin + +.PHONY: install install: $(PROGRAM) - cp $(PROGRAM) $(DESTDIR)/usr/local/bin + cp $(PROGRAM) $(DESTDIR) -.PHONY: release +.PHONY: release release: $(PROGRAM) cp $(PROGRAM) release/pihpsdr cd release; tar cvf pihpsdr.tar pihpsdr cd release; tar cvf pihpsdr-$(GIT_VERSION).tar pihpsdr -.PHONY: nocontroller +.PHONY: nocontroller nocontroller: clean controller1 $(PROGRAM) cp $(PROGRAM) release/pihpsdr cd release; tar cvf pihpsdr-nocontroller.$(GIT_VERSION).tar pihpsdr -.PHONY: controller1 +.PHONY: controller1 controller1: clean $(PROGRAM) cp $(PROGRAM) release/pihpsdr cd release; tar cvf pihpsdr-controller1.$(GIT_VERSION).tar pihpsdr -.PHONY: controller2v1 +.PHONY: controller2v1 controller2v1: clean $(PROGRAM) cp $(PROGRAM) release/pihpsdr cd release; tar cvf pihpsdr-controller2-v1.$(GIT_VERSION).tar pihpsdr -.PHONY: controller2v2 +.PHONY: controller2v2 controller2v2: clean $(PROGRAM) cp $(PROGRAM) release/pihpsdr cd release; tar cvf pihpsdr-controller2-v2.$(GIT_VERSION).tar pihpsdr @@ -550,7 +565,7 @@ newhpsdrsim.o: newhpsdrsim.c hpsdrsim.h $(CC) -c -O newhpsdrsim.c hpsdrsim: hpsdrsim.o newhpsdrsim.o - $(CC) -o hpsdrsim hpsdrsim.o newhpsdrsim.o -lm -lpthread + $(LINK) -o hpsdrsim hpsdrsim.o newhpsdrsim.o -lm -lpthread debian: cp $(PROGRAM) pkg/pihpsdr/usr/local/bin @@ -578,10 +593,10 @@ debian: .PHONY: app app: $(OBJS) $(AUDIO_OBJS) $(REMOTE_OBJS) $(USBOZY_OBJS) $(SOAPYSDR_OBJS) \ - $(LOCALCW_OBJS) $(PURESIGNAL_OBJS) $(GPIO_OBJS) \ + $(LOCALCW_OBJS) $(PURESIGNAL_OBJS) \ $(MIDI_OBJS) $(STEMLAB_OBJS) $(SERVER_OBJS) - $(CC) -headerpad_max_install_names -o $(PROGRAM) $(OBJS) $(AUDIO_OBJS) $(REMOTE_OBJS) $(USBOZY_OBJS) \ - $(SOAPYSDR_OBJS) $(LOCALCW_OBJS) $(PURESIGNAL_OBJS) $(GPIO_OBJS) \ + $(LINK) -headerpad_max_install_names -o $(PROGRAM) $(OBJS) $(AUDIO_OBJS) $(REMOTE_OBJS) $(USBOZY_OBJS) \ + $(SOAPYSDR_OBJS) $(LOCALCW_OBJS) $(PURESIGNAL_OBJS) \ $(MIDI_OBJS) $(STEMLAB_OBJS) $(SERVER_OBJS) $(LIBS) $(LDFLAGS) @rm -rf pihpsdr.app @mkdir -p pihpsdr.app/Contents/MacOS @@ -595,11 +610,11 @@ app: $(OBJS) $(AUDIO_OBJS) $(REMOTE_OBJS) $(USBOZY_OBJS) $(SOAPYSDR_OBJS) \ # # Copy the WDSP library into the executable # - @lib=`otool -L pihpsdr.app/Contents/MacOS/pihpsdr | grep libwdsp | sed -e "s/ (.*//" | sed -e 's/ //'`; \ + @lib=`/usr/bin/otool -L pihpsdr.app/Contents/MacOS/pihpsdr | grep libwdsp | sed -e "s/ (.*//" | sed -e 's/ //'`; \ libfn=`basename $$lib`; \ cp "$$lib" "pihpsdr.app/Contents/Frameworks/$$libfn"; \ chmod u+w "pihpsdr.app/Contents/Frameworks/$$libfn"; \ - install_name_tool -id "@executable_path/../Frameworks/$$libfn" "pihpsdr.app/Contents/Frameworks/$$libfn"; \ - install_name_tool -change "$$lib" "@executable_path/../Frameworks/$$libfn" pihpsdr.app/Contents/MacOS/pihpsdr + /usr/bin/install_name_tool -id "@executable_path/../Frameworks/$$libfn" "pihpsdr.app/Contents/Frameworks/$$libfn"; \ + /usr/bin/install_name_tool -change "$$lib" "@executable_path/../Frameworks/$$libfn" pihpsdr.app/Contents/MacOS/pihpsdr # ############################################################################# diff --git a/actions.h b/actions.h index 6d4177f..050ae53 100644 --- a/actions.h +++ b/actions.h @@ -1,3 +1,123 @@ /* - * This file left empty intentionally + * Rudimentary file, to be replaced upon version merging */ + +enum { + ENCODER_NO_ACTION=0, + ENCODER_AF_GAIN, + ENCODER_AF_GAIN_RX1, + ENCODER_AF_GAIN_RX2, + ENCODER_AGC_GAIN, + ENCODER_AGC_GAIN_RX1, + ENCODER_AGC_GAIN_RX2, + ENCODER_ATTENUATION, + ENCODER_COMP, + ENCODER_CW_FREQUENCY, + ENCODER_CW_SPEED, + ENCODER_DIVERSITY_GAIN, + ENCODER_DIVERSITY_GAIN_COARSE, + ENCODER_DIVERSITY_GAIN_FINE, + ENCODER_DIVERSITY_PHASE, + ENCODER_DIVERSITY_PHASE_COARSE, + ENCODER_DIVERSITY_PHASE_FINE, + ENCODER_DRIVE, + ENCODER_IF_SHIFT, + ENCODER_IF_SHIFT_RX1, + ENCODER_IF_SHIFT_RX2, + ENCODER_IF_WIDTH, + ENCODER_IF_WIDTH_RX1, + ENCODER_IF_WIDTH_RX2, + ENCODER_LINEIN_GAIN, + ENCODER_MIC_GAIN, + ENCODER_PAN, + ENCODER_PANADAPTER_HIGH, + ENCODER_PANADAPTER_LOW, + ENCODER_PANADAPTER_STEP, + ENCODER_RF_GAIN, + ENCODER_RF_GAIN_RX1, + ENCODER_RF_GAIN_RX2, + ENCODER_RIT, + ENCODER_RIT_RX1, + ENCODER_RIT_RX2, + ENCODER_SQUELCH, + ENCODER_SQUELCH_RX1, + ENCODER_SQUELCH_RX2, + ENCODER_TUNE_DRIVE, + ENCODER_WATERFALL_HIGH, + ENCODER_WATERFALL_LOW, + ENCODER_XIT, + ENCODER_ZOOM, + ENCODER_ACTIONS +}; + +enum { + NO_ACTION=0, + A_TO_B, + A_SWAP_B, + AGC, + ANF, + B_TO_A, + BAND_MINUS, + BAND_PLUS, + BANDSTACK_MINUS, + BANDSTACK_PLUS, + CTUN, + DIVERSITY, + FILTER_MINUS, + FILTER_PLUS, + FUNCTION, + LOCK, + MENU_BAND, + MENU_BANDSTACK, + MENU_DIVERSITY, + MENU_FILTER, + MENU_FREQUENCY, + MENU_MEMORY, + MENU_MODE, + MENU_PS, + MODE_MINUS, + MODE_PLUS, + MOX, + MUTE, + NB, + NR, + PAN_MINUS, + PAN_PLUS, + PS, + RIT, + RIT_CLEAR, + SAT, + SNB, + SPLIT, + TUNE, + TWO_TONE, + XIT, + XIT_CLEAR, + ZOOM_MINUS, + ZOOM_PLUS, + SWITCH_ACTIONS +}; + +/* + * This is for use in sliders, to facilitate the merge + */ + +#define ZOOM ENCODER_ZOOM +#define PAN ENCODER_PAN +#define AGC_GAIN ENCODER_AGC_GAIN +#define ATTENUATION ENCODER_ATTENUATION +#define COMPRESSION ENCODER_COMP +#define DIVERSITY_PHASE ENCODER_DIVERSITY_PHASE +#define DIVERSITY_GAIN ENCODER_DIVERSITY_GAIN +#define SQUELCH ENCODER_SQUELCH +#define DRIVE ENCODER_DRIVE +#define LINEIN_GAIN ENCODER_LINEIN_GAIN +#define MIC_GAIN ENCODER_MIC_GAIN +#define IF_WIDTH ENCODER_IF_WIDTH +#define IF_SHIFT ENCODER_IF_SHIFT +#define AF_GAIN ENCODER_AF_GAIN +#define RF_GAIN ENCODER_RF_GAIN + +extern char *encoder_string[ENCODER_ACTIONS]; +extern char *sw_string[SWITCH_ACTIONS]; + diff --git a/alsa_midi.c b/alsa_midi.c index 2072f98..80d8383 100644 --- a/alsa_midi.c +++ b/alsa_midi.c @@ -149,37 +149,37 @@ static void *midi_thread(void *arg) { // a push-button if (arg2 == 0) { if(configure) { - NewMidiConfigureEvent(MIDI_EVENT_NOTE, chan, arg1, 0); + NewMidiConfigureEvent(MIDI_NOTE, chan, arg1, 0); } else { - NewMidiEvent(MIDI_EVENT_NOTE, chan, arg1, 0); + NewMidiEvent(MIDI_NOTE, chan, arg1, 0); } } else { if(configure) { - NewMidiConfigureEvent(MIDI_EVENT_NOTE, chan, arg1, 1); + NewMidiConfigureEvent(MIDI_NOTE, chan, arg1, 1); } else { - NewMidiEvent(MIDI_EVENT_NOTE, chan, arg1, 1); + NewMidiEvent(MIDI_NOTE, chan, arg1, 1); } } break; case CMD_NOTEOFF: if(configure) { - NewMidiConfigureEvent(MIDI_EVENT_NOTE, chan, arg1, 0); + NewMidiConfigureEvent(MIDI_NOTE, chan, arg1, 0); } else { - NewMidiEvent(MIDI_EVENT_NOTE, chan, arg1, 0); + NewMidiEvent(MIDI_NOTE, chan, arg1, 0); } break; case CMD_CTRL: if(configure) { - NewMidiConfigureEvent(MIDI_EVENT_CTRL, chan, arg1, arg2); + NewMidiConfigureEvent(MIDI_CTRL, chan, arg1, arg2); } else { - NewMidiEvent(MIDI_EVENT_CTRL, chan, arg1, arg2); + NewMidiEvent(MIDI_CTRL, chan, arg1, arg2); } break; case CMD_PITCH: if(configure) { - NewMidiConfigureEvent(MIDI_EVENT_PITCH, chan, 0, arg1+128*arg2); + NewMidiConfigureEvent(MIDI_PITCH, chan, 0, arg1+128*arg2); } else { - NewMidiEvent(MIDI_EVENT_PITCH, chan, 0, arg1+128*arg2); + NewMidiEvent(MIDI_PITCH, chan, 0, arg1+128*arg2); } break; } diff --git a/encoder_menu.c b/encoder_menu.c index 9a81678..56beca8 100644 --- a/encoder_menu.c +++ b/encoder_menu.c @@ -31,6 +31,7 @@ #include "receiver.h" #include "vfo.h" #include "button_text.h" +#include "actions.h" #include "gpio.h" #include "i2c.h" @@ -356,6 +357,7 @@ static gboolean select_cb (GtkWidget *widget, gpointer data) { } button=getRadioButton(action); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE); + return TRUE; } static gboolean top_select_cb (GtkWidget *widget, gpointer data) { @@ -378,6 +380,7 @@ static gboolean top_select_cb (GtkWidget *widget, gpointer data) { } button=getTopRadioButton(action); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE); + return TRUE; } void encoder_select(int pos) { @@ -516,6 +519,7 @@ void top_encoder_select(int pos) { e5_encoder_action=action; break; } + return TRUE; } static gboolean top_action_select_cb (GtkWidget *widget, gpointer data) { @@ -534,6 +538,7 @@ void top_encoder_select(int pos) { e5_top_encoder_action=action; break; } + return TRUE; } static gboolean enc2_cb(GtkWidget *widget, gpointer data) { diff --git a/ext.h b/ext.h index 66c74f9..3809182 100644 --- a/ext.h +++ b/ext.h @@ -31,6 +31,9 @@ extern int ext_remote_command(void *data); extern int ext_receiver_remote_update_display(void *data); #endif +extern int ext_menu_filter(void *data); +extern int ext_menu_mode(void *data); +extern int ext_num_pad(void *data); extern int ext_discovery(void *data); extern int ext_vfo_update(void *data); extern int ext_set_frequency(void *data); @@ -54,6 +57,8 @@ extern int ext_nr_update(void *data); extern int ext_nb_update(void *data); extern int ext_snb_update(void *data); extern int ext_anf_update(void *data); +extern int ext_band_select(void *data); + extern int ext_band_plus(void *data); extern int ext_band_minus(void *data); extern int ext_bandstack_plus(void *data); diff --git a/gpio.c b/gpio.c index f0aff16..a1cd23f 100644 --- a/gpio.c +++ b/gpio.c @@ -59,6 +59,7 @@ #include "iambic.h" #endif #include "zoompan.h" +#include "actions.h" // debounce settle time in ms #define DEFAULT_SETTLE_TIME 50 @@ -224,6 +225,7 @@ char *encoder_string[ENCODER_ACTIONS] = { "IF WIDTH", "IF WIDTH RX1", "IF WIDTH RX2", + "LINEIN GAIN", "MIC GAIN", "PAN", "PANADAPTER HIGH", diff --git a/gpio.h b/gpio.h index a30e797..fed0695 100644 --- a/gpio.h +++ b/gpio.h @@ -20,106 +20,6 @@ #ifndef _GPIO_H #define _GPIO_H -enum { - ENCODER_NO_ACTION=0, - ENCODER_AF_GAIN, - ENCODER_AF_GAIN_RX1, - ENCODER_AF_GAIN_RX2, - ENCODER_AGC_GAIN, - ENCODER_AGC_GAIN_RX1, - ENCODER_AGC_GAIN_RX2, - ENCODER_ATTENUATION, - ENCODER_COMP, - ENCODER_CW_FREQUENCY, - ENCODER_CW_SPEED, - ENCODER_DIVERSITY_GAIN, - ENCODER_DIVERSITY_GAIN_COARSE, - ENCODER_DIVERSITY_GAIN_FINE, - ENCODER_DIVERSITY_PHASE, - ENCODER_DIVERSITY_PHASE_COARSE, - ENCODER_DIVERSITY_PHASE_FINE, - ENCODER_DRIVE, - ENCODER_IF_SHIFT, - ENCODER_IF_SHIFT_RX1, - ENCODER_IF_SHIFT_RX2, - ENCODER_IF_WIDTH, - ENCODER_IF_WIDTH_RX1, - ENCODER_IF_WIDTH_RX2, - ENCODER_MIC_GAIN, - ENCODER_PAN, - ENCODER_PANADAPTER_HIGH, - ENCODER_PANADAPTER_LOW, - ENCODER_PANADAPTER_STEP, - ENCODER_RF_GAIN, - ENCODER_RF_GAIN_RX1, - ENCODER_RF_GAIN_RX2, - ENCODER_RIT, - ENCODER_RIT_RX1, - ENCODER_RIT_RX2, - ENCODER_SQUELCH, - ENCODER_SQUELCH_RX1, - ENCODER_SQUELCH_RX2, - ENCODER_TUNE_DRIVE, - ENCODER_WATERFALL_HIGH, - ENCODER_WATERFALL_LOW, - ENCODER_XIT, - ENCODER_ZOOM, - ENCODER_ACTIONS -}; - -extern char *encoder_string[ENCODER_ACTIONS]; - -enum { - NO_ACTION=0, - A_TO_B, - A_SWAP_B, - AGC, - ANF, - B_TO_A, - BAND_MINUS, - BAND_PLUS, - BANDSTACK_MINUS, - BANDSTACK_PLUS, - CTUN, - DIVERSITY, - FILTER_MINUS, - FILTER_PLUS, - FUNCTION, - LOCK, - MENU_BAND, - MENU_BANDSTACK, - MENU_DIVERSITY, - MENU_FILTER, - MENU_FREQUENCY, - MENU_MEMORY, - MENU_MODE, - MENU_PS, - MODE_MINUS, - MODE_PLUS, - MOX, - MUTE, - NB, - NR, - PAN_MINUS, - PAN_PLUS, - PS, - RIT, - RIT_CLEAR, - SAT, - SNB, - SPLIT, - TUNE, - TWO_TONE, - XIT, - XIT_CLEAR, - ZOOM_MINUS, - ZOOM_PLUS, - SWITCH_ACTIONS -}; - -extern char *sw_string[SWITCH_ACTIONS]; - - enum { CONTROLLER1_SW1=0, CONTROLLER1_SW2, diff --git a/i2c.c b/i2c.c index 7798b8e..0af85fb 100644 --- a/i2c.c +++ b/i2c.c @@ -1,3 +1,4 @@ +#ifdef GPIO #include #include #include @@ -11,6 +12,7 @@ #include //#include "i2c.h" #include "wiringPiI2C.h" +#include "actions.h" #include "gpio.h" #include "band.h" #include "band_menu.h" @@ -301,3 +303,4 @@ fprintf(stderr,"i2c_init: %s\n",i2c_device); } while(flags!=0); } +#endif diff --git a/mac_midi.c b/mac_midi.c index 459e2a1..696cd0b 100644 --- a/mac_midi.c +++ b/mac_midi.c @@ -35,6 +35,7 @@ #include "adc.h" #include "dac.h" #include "radio.h" +#include "actions.h" #include "midi.h" #include "midi_menu.h" #include "alsa_midi.h" @@ -136,37 +137,37 @@ static void ReadMIDIdevice(const MIDIPacketList *pktlist, void *refCon, void *co // a push-button. if (arg2 == 0) { if(configure) { - NewMidiConfigureEvent(MIDI_EVENT_NOTE, chan, arg1, 0); + NewMidiConfigureEvent(MIDI_NOTE, chan, arg1, 0); } else { - NewMidiEvent(MIDI_EVENT_NOTE, chan, arg1, 0); + NewMidiEvent(MIDI_NOTE, chan, arg1, 0); } } else { if(configure) { - NewMidiConfigureEvent(MIDI_EVENT_NOTE, chan, arg1, 1); + NewMidiConfigureEvent(MIDI_NOTE, chan, arg1, 1); } else { - NewMidiEvent(MIDI_EVENT_NOTE, chan, arg1, 1); + NewMidiEvent(MIDI_NOTE, chan, arg1, 1); } } break; case CMD_NOTEOFF: if(configure) { - NewMidiConfigureEvent(MIDI_EVENT_NOTE, chan, arg1, 0); + NewMidiConfigureEvent(MIDI_NOTE, chan, arg1, 0); } else { - NewMidiEvent(MIDI_EVENT_NOTE, chan, arg1, 0); + NewMidiEvent(MIDI_NOTE, chan, arg1, 0); } break; case CMD_CTRL: if(configure) { - NewMidiConfigureEvent(MIDI_EVENT_CTRL, chan, arg1, arg2); + NewMidiConfigureEvent(MIDI_CTRL, chan, arg1, arg2); } else { - NewMidiEvent(MIDI_EVENT_CTRL, chan, arg1, arg2); + NewMidiEvent(MIDI_CTRL, chan, arg1, arg2); } break; case CMD_PITCH: if(configure) { - NewMidiConfigureEvent(MIDI_EVENT_PITCH, chan, 0, arg1+128*arg2); + NewMidiConfigureEvent(MIDI_PITCH, chan, 0, arg1+128*arg2); } else { - NewMidiEvent(MIDI_EVENT_PITCH, chan, 0, arg1+128*arg2); + NewMidiEvent(MIDI_PITCH, chan, 0, arg1+128*arg2); } break; } diff --git a/midi.h b/midi.h index 3e09d48..8105c50 100644 --- a/midi.h +++ b/midi.h @@ -42,6 +42,9 @@ * must generate MIDI events on different channels */ +#ifndef _MIDI_H +#define _MIDI_H + // // MIDIaction encodes the "action" to be taken in Layer3 // (sorted alphabetically by the keyword). @@ -165,14 +168,14 @@ enum MIDIaction { // MIDItype encodes the type of MIDI control. This info // is passed from Layer-2 to Layer-3 // -// MIDI_TYPE_KEY has no parameters and indicates that some +// MIDI_KEY has no parameters and indicates that some // button has been pressed. // -// MIDI_TYPE_KNOB has a "value" parameter (between 0 and 100) +// MIDI_KNOB has a "value" parameter (between 0 and 100) // and indicates that some knob has been set to a specific // position. // -// MIDI_TYPE_WHEEL has a "direction" parameter and indicates that +// MIDI_WHEEL has a "direction" parameter and indicates that // some knob has been turned left/down or right/ip. The value // can be // @@ -185,10 +188,10 @@ enum MIDIaction { // enum MIDItype { - MIDI_TYPE_NONE =0, - MIDI_TYPE_KEY =1, // Button (press event) - MIDI_TYPE_KNOB =2, // Knob (value between 0 and 100) - MIDI_TYPE_WHEEL=4 // Wheel (direction and speed) + TYPE_NONE =0, + MIDI_KEY =1, // Button (press event) + MIDI_KNOB =2, // Knob (value between 0 and 100) + MIDI_WHEEL=4 // Wheel (direction and speed) }; extern gchar *midi_types[]; @@ -201,10 +204,10 @@ extern gchar *midi_events[]; // MIDI_KNOB or MIDI_WHEEL, depending on the device description. // enum MIDIevent { - MIDI_EVENT_NONE=0, - MIDI_EVENT_NOTE, - MIDI_EVENT_CTRL, - MIDI_EVENT_PITCH + EVENT_NONE=0, + MIDI_NOTE, + MIDI_CTRL, + MIDI_PITCH }; typedef struct _action_table { @@ -285,3 +288,5 @@ void MidiReleaseCommands(); // void DoTheMidi(enum MIDIaction code, enum MIDItype type, int val); + +#endif diff --git a/midi2.c b/midi2.c index 1dce648..640be8c 100644 --- a/midi2.c +++ b/midi2.c @@ -24,6 +24,7 @@ #include "transmitter.h" #include "radio.h" #include "main.h" +#include "actions.h" #include "midi.h" #include "alsa_midi.h" @@ -44,40 +45,40 @@ void NewMidiEvent(enum MIDIevent event, int channel, int note, int val) { //now=ts.tv_sec + 1E-9*ts.tv_nsec; //g_print("%s:%12.3f:EVENT=%d CHAN=%d NOTE=%d VAL=%d\n",__FUNCTION__,now,event,channel,note,val); - if (event == MIDI_EVENT_PITCH) { + if (event == MIDI_PITCH) { desc=MidiCommandsTable[128]; } else { desc=MidiCommandsTable[note]; } -//g_print("MIDI:init DESC=%p\n",desc); +//g_print("%s: init DESC=%p\n",__FUNCTION__,desc); while (desc) { -//g_print("DESC=%p next=%p CHAN=%d EVENT=%d\n", desc,desc->next,desc->channel,desc->event); +//g_print("%s: DESC=%p next=%p CHAN=%d EVENT=%d\n",__FUNCTION__,desc,desc->next,desc->channel,desc->event); if ((desc->channel == channel || desc->channel == -1) && (desc->event == event)) { // Found matching entry switch (desc->event) { - case MIDI_EVENT_NOTE: - if (desc->type == MIDI_TYPE_KEY) { + case MIDI_NOTE: + if (desc->type == MIDI_KEY) { switch (desc->action) { case MIDI_ACTION_CWLEFT: case MIDI_ACTION_CWRIGHT: case MIDI_ACTION_CWKEYER: case MIDI_ACTION_PTTKEYER: // deliver message for note-on and note-off - DoTheMidi(desc->action, desc->type, val); + DoTheMidi(desc->action, desc->type, val); break; default: // deliver only note-on messages - if (val == 1) DoTheMidi(desc->action, desc->type, val); + if (val == 1) DoTheMidi(desc->action, desc->type, val); break; } } - break; - case MIDI_EVENT_CTRL: - if (desc->type == MIDI_TYPE_KNOB) { + break; + case MIDI_CTRL: + if (desc->type == MIDI_KNOB) { // normalize value to range 0 - 100 new = (val*100)/127; DoTheMidi(desc->action, desc->type, new); - } else if (desc->type == MIDI_TYPE_WHEEL) { + } else if (desc->type == MIDI_WHEEL) { if (desc->delay > 0 && last_wheel_action == desc->action) { clock_gettime(CLOCK_MONOTONIC, &tp); delta=1000*(tp.tv_sec - last_wheel_tp.tv_sec); @@ -93,21 +94,22 @@ void NewMidiEvent(enum MIDIevent event, int channel, int note, int val) { if ((val >= desc->rgt1) && (val <= desc->rgt2)) new= 1; if ((val >= desc-> fr1) && (val <= desc-> fr2)) new= 4; if ((val >= desc->vfr1) && (val <= desc->vfr2)) new= 16; -// g_print("WHEEL: val=%d new=%d thrs=%d/%d, %d/%d, %d/%d, %d/%d, %d/%d, %d/%d\n", +// g_print("%s: WHEEL: val=%d new=%d thrs=%d/%d, %d/%d, %d/%d, %d/%d, %d/%d, %d/%d\n", +// __FUNCTION__, // val, new, desc->vfl1, desc->vfl2, desc->fl1, desc->fl2, desc->lft1, desc->lft2, // desc->rgt1, desc->rgt2, desc->fr1, desc->fr2, desc->vfr1, desc->vfr2); if (new != 0) DoTheMidi(desc->action, desc->type, new); last_wheel_action=desc->action; } break; - case MIDI_EVENT_PITCH: - if (desc->type == MIDI_TYPE_KNOB) { + case MIDI_PITCH: + if (desc->type == MIDI_KNOB) { // normalize value to 0 - 100 new = (val*100)/16383; DoTheMidi(desc->action, desc->type, new); } break; - case MIDI_EVENT_NONE: + case EVENT_NONE: break; } break; @@ -117,9 +119,9 @@ void NewMidiEvent(enum MIDIevent event, int channel, int note, int val) { } if (!desc) { // Nothing found. This is nothing to worry about, but log the key to stderr - if (event == MIDI_EVENT_PITCH) g_print("Unassigned PitchBend Value=%d\n", val); - if (event == MIDI_EVENT_NOTE ) g_print("Unassigned Key Note=%d Val=%d\n", note, val); - if (event == MIDI_EVENT_CTRL ) g_print("Unassigned Controller Ctl=%d Val=%d\n", note, val); + if (event == MIDI_PITCH) g_print("Unassigned PitchBend Value=%d\n", val); + if (event == MIDI_NOTE ) g_print("Unassigned Key Note=%d Val=%d\n", note, val); + if (event == MIDI_CTRL ) g_print("Unassigned Controller Ctl=%d Val=%d\n", note, val); } } @@ -136,117 +138,117 @@ gchar *midi_events[] = {"NONE","NOTE","CTRL","PITCH"}; */ ACTION_TABLE ActionTable[] = { - { MIDI_ACTION_NONE, "NONE", MIDI_TYPE_KEY|MIDI_TYPE_KNOB|MIDI_TYPE_WHEEL }, - { MIDI_ACTION_VFO_A2B, "A2B", MIDI_TYPE_KEY }, - { MIDI_ACTION_AF_GAIN, "AFGAIN", MIDI_TYPE_KNOB|MIDI_TYPE_WHEEL }, - { MIDI_ACTION_AGCATTACK, "AGCATTACK", MIDI_TYPE_KEY }, - { MIDI_ACTION_AGC, "AGCVAL", MIDI_TYPE_KNOB|MIDI_TYPE_WHEEL }, - { MIDI_ACTION_ANF, "ANF", MIDI_TYPE_KEY }, - { MIDI_ACTION_ATT, "ATT", MIDI_TYPE_KEY|MIDI_TYPE_KNOB|MIDI_TYPE_WHEEL }, - { MIDI_ACTION_VFO_B2A, "B2A", MIDI_TYPE_KEY }, - { MIDI_ACTION_BAND_10, "BAND10", MIDI_TYPE_KEY }, - { MIDI_ACTION_BAND_12, "BAND12", MIDI_TYPE_KEY }, - { MIDI_ACTION_BAND_1240, "BAND1240", MIDI_TYPE_KEY }, - { MIDI_ACTION_BAND_144, "BAND144", MIDI_TYPE_KEY }, - { MIDI_ACTION_BAND_15, "BAND15", MIDI_TYPE_KEY }, - { MIDI_ACTION_BAND_160, "BAND160", MIDI_TYPE_KEY }, - { MIDI_ACTION_BAND_17, "BAND17", MIDI_TYPE_KEY }, - { MIDI_ACTION_BAND_20, "BAND20", MIDI_TYPE_KEY }, - { MIDI_ACTION_BAND_220, "BAND220", MIDI_TYPE_KEY }, - { MIDI_ACTION_BAND_2300, "BAND2300", MIDI_TYPE_KEY }, - { MIDI_ACTION_BAND_30, "BAND30", MIDI_TYPE_KEY }, - { MIDI_ACTION_BAND_3400, "BAND3400", MIDI_TYPE_KEY }, - { MIDI_ACTION_BAND_40, "BAND40", MIDI_TYPE_KEY }, - { MIDI_ACTION_BAND_430, "BAND430", MIDI_TYPE_KEY }, - { MIDI_ACTION_BAND_6, "BAND6", MIDI_TYPE_KEY }, - { MIDI_ACTION_BAND_60, "BAND60", MIDI_TYPE_KEY }, - { MIDI_ACTION_BAND_70, "BAND70", MIDI_TYPE_KEY }, - { MIDI_ACTION_BAND_80, "BAND80", MIDI_TYPE_KEY }, - { MIDI_ACTION_BAND_902, "BAND902", MIDI_TYPE_KEY }, - { MIDI_ACTION_BAND_AIR, "BANDAIR", MIDI_TYPE_KEY }, - { MIDI_ACTION_BAND_DOWN, "BANDDOWN", MIDI_TYPE_KEY|MIDI_TYPE_KNOB|MIDI_TYPE_WHEEL }, - { MIDI_ACTION_BAND_GEN, "BANDGEN", MIDI_TYPE_KEY }, - { MIDI_ACTION_BAND_UP, "BANDUP", MIDI_TYPE_KEY|MIDI_TYPE_KNOB|MIDI_TYPE_WHEEL }, - { MIDI_ACTION_BAND_WWV, "BANDWWV", MIDI_TYPE_KEY }, - { MIDI_ACTION_COMPRESS, "COMPRESS", MIDI_TYPE_KNOB|MIDI_TYPE_WHEEL }, - { MIDI_ACTION_CTUN, "CTUN", MIDI_TYPE_KEY }, - { MIDI_ACTION_VFO, "CURRVFO", MIDI_TYPE_WHEEL }, - { MIDI_ACTION_CWKEYER, "CW(Keyer)", MIDI_TYPE_KEY }, - { MIDI_ACTION_CWLEFT, "CWLEFT", MIDI_TYPE_KEY }, - { MIDI_ACTION_CWRIGHT, "CWRIGHT", MIDI_TYPE_KEY }, - { MIDI_ACTION_CWSPEED, "CWSPEED", MIDI_TYPE_KNOB|MIDI_TYPE_WHEEL }, - { MIDI_ACTION_DIV_COARSEGAIN, "DIVCOARSEGAIN", MIDI_TYPE_KNOB|MIDI_TYPE_WHEEL }, - { MIDI_ACTION_DIV_COARSEPHASE, "DIVCOARSEPHASE", MIDI_TYPE_KNOB|MIDI_TYPE_WHEEL }, - { MIDI_ACTION_DIV_FINEGAIN, "DIVFINEGAIN", MIDI_TYPE_KNOB|MIDI_TYPE_WHEEL }, - { MIDI_ACTION_DIV_FINEPHASE, "DIVFINEPHASE", MIDI_TYPE_KNOB|MIDI_TYPE_WHEEL }, - { MIDI_ACTION_DIV_GAIN, "DIVGAIN", MIDI_TYPE_KNOB|MIDI_TYPE_WHEEL }, - { MIDI_ACTION_DIV_PHASE, "DIVPHASE", MIDI_TYPE_KNOB|MIDI_TYPE_WHEEL }, - { MIDI_ACTION_DIV_TOGGLE, "DIVTOGGLE", MIDI_TYPE_KEY }, - { MIDI_ACTION_DUP, "DUP", MIDI_TYPE_KEY }, - { MIDI_ACTION_FILTER_DOWN, "FILTERDOWN", MIDI_TYPE_KEY|MIDI_TYPE_KNOB|MIDI_TYPE_WHEEL }, - { MIDI_ACTION_FILTER_UP, "FILTERUP", MIDI_TYPE_KEY|MIDI_TYPE_KNOB|MIDI_TYPE_WHEEL }, - { MIDI_ACTION_LOCK, "LOCK", MIDI_TYPE_KEY }, - { MIDI_ACTION_MEM_RECALL_M0, "RECALLM0", MIDI_TYPE_KEY }, - { MIDI_ACTION_MEM_RECALL_M1, "RECALLM1", MIDI_TYPE_KEY }, - { MIDI_ACTION_MEM_RECALL_M2, "RECALLM2", MIDI_TYPE_KEY }, - { MIDI_ACTION_MEM_RECALL_M3, "RECALLM3", MIDI_TYPE_KEY }, - { MIDI_ACTION_MEM_RECALL_M4, "RECALLM4", MIDI_TYPE_KEY }, - { MIDI_ACTION_MENU_FILTER, "MENU_FILTER", MIDI_TYPE_KEY }, - { MIDI_ACTION_MENU_MODE, "MENU_MODE", MIDI_TYPE_KEY }, - { MIDI_ACTION_MIC_VOLUME, "MICGAIN", MIDI_TYPE_KNOB|MIDI_TYPE_WHEEL }, - { MIDI_ACTION_MODE_DOWN, "MODEDOWN", MIDI_TYPE_KEY|MIDI_TYPE_KNOB|MIDI_TYPE_WHEEL }, - { MIDI_ACTION_MODE_UP, "MODEUP", MIDI_TYPE_KEY|MIDI_TYPE_KNOB|MIDI_TYPE_WHEEL }, - { MIDI_ACTION_MOX, "MOX", MIDI_TYPE_KEY }, - { MIDI_ACTION_MUTE, "MUTE", MIDI_TYPE_KEY }, - { MIDI_ACTION_NB, "NOISEBLANKER", MIDI_TYPE_KEY }, - { MIDI_ACTION_NR, "NOISEREDUCTION", MIDI_TYPE_KEY }, - { MIDI_ACTION_NUMPAD_0, "NUMPAD0", MIDI_TYPE_KEY }, - { MIDI_ACTION_NUMPAD_1, "NUMPAD1", MIDI_TYPE_KEY }, - { MIDI_ACTION_NUMPAD_2, "NUMPAD2", MIDI_TYPE_KEY }, - { MIDI_ACTION_NUMPAD_3, "NUMPAD3", MIDI_TYPE_KEY }, - { MIDI_ACTION_NUMPAD_4, "NUMPAD4", MIDI_TYPE_KEY }, - { MIDI_ACTION_NUMPAD_5, "NUMPAD5", MIDI_TYPE_KEY }, - { MIDI_ACTION_NUMPAD_6, "NUMPAD6", MIDI_TYPE_KEY }, - { MIDI_ACTION_NUMPAD_7, "NUMPAD7", MIDI_TYPE_KEY }, - { MIDI_ACTION_NUMPAD_8, "NUMPAD8", MIDI_TYPE_KEY }, - { MIDI_ACTION_NUMPAD_9, "NUMPAD9", MIDI_TYPE_KEY }, - { MIDI_ACTION_NUMPAD_CL, "NUMPADCL", MIDI_TYPE_KEY }, - { MIDI_ACTION_NUMPAD_ENTER, "NUMPADENTER", MIDI_TYPE_KEY }, - { MIDI_ACTION_PAN, "PAN", MIDI_TYPE_KNOB|MIDI_TYPE_WHEEL }, - { MIDI_ACTION_PAN_HIGH, "PANHIGH", MIDI_TYPE_KNOB|MIDI_TYPE_WHEEL }, - { MIDI_ACTION_PAN_LOW, "PANLOW", MIDI_TYPE_KNOB|MIDI_TYPE_WHEEL }, - { MIDI_ACTION_PRE, "PREAMP", MIDI_TYPE_KEY }, - { MIDI_ACTION_PTTKEYER, "PTT(Keyer)", MIDI_TYPE_KEY }, - { MIDI_ACTION_PS, "PURESIGNAL", MIDI_TYPE_KEY }, - { MIDI_ACTION_RF_GAIN, "RFGAIN", MIDI_TYPE_KNOB|MIDI_TYPE_WHEEL }, - { MIDI_ACTION_TX_DRIVE, "RFPOWER", MIDI_TYPE_KNOB|MIDI_TYPE_WHEEL }, - { MIDI_ACTION_RIT_CLEAR, "RITCLEAR", MIDI_TYPE_KEY }, - { MIDI_ACTION_RIT_STEP, "RITSTEP", MIDI_TYPE_KEY|MIDI_TYPE_WHEEL }, - { MIDI_ACTION_RIT_TOGGLE, "RITTOGGLE", MIDI_TYPE_KEY }, - { MIDI_ACTION_RIT_VAL, "RITVAL", MIDI_TYPE_KNOB|MIDI_TYPE_WHEEL }, - { MIDI_ACTION_SAT, "SAT", MIDI_TYPE_KEY }, - { MIDI_ACTION_SNB, "SNB", MIDI_TYPE_KEY }, - { MIDI_ACTION_SPLIT, "SPLIT", MIDI_TYPE_KEY }, - { MIDI_ACTION_MEM_STORE_M0, "STOREM0", MIDI_TYPE_KEY }, - { MIDI_ACTION_MEM_STORE_M1, "STOREM1", MIDI_TYPE_KEY }, - { MIDI_ACTION_MEM_STORE_M2, "STOREM2", MIDI_TYPE_KEY }, - { MIDI_ACTION_MEM_STORE_M3, "STOREM3", MIDI_TYPE_KEY }, - { MIDI_ACTION_MEM_STORE_M4, "STOREM4", MIDI_TYPE_KEY }, - { MIDI_ACTION_SWAP_RX, "SWAPRX", MIDI_TYPE_KEY }, - { MIDI_ACTION_SWAP_VFO, "SWAPVFO", MIDI_TYPE_KEY }, - { MIDI_ACTION_TUNE, "TUNE", MIDI_TYPE_KEY }, - { MIDI_ACTION_VFOA, "VFOA", MIDI_TYPE_WHEEL }, - { MIDI_ACTION_VFOB, "VFOB", MIDI_TYPE_WHEEL }, - { MIDI_ACTION_VFO_STEP_UP, "VFOSTEPUP", MIDI_TYPE_KEY|MIDI_TYPE_WHEEL }, - { MIDI_ACTION_VFO_STEP_DOWN, "VFOSTEPDOWN", MIDI_TYPE_KEY|MIDI_TYPE_WHEEL }, - { MIDI_ACTION_VOX, "VOX", MIDI_TYPE_KEY }, - { MIDI_ACTION_VOXLEVEL, "VOXLEVEL", MIDI_TYPE_KNOB|MIDI_TYPE_WHEEL }, - { MIDI_ACTION_XIT_CLEAR, "XITCLEAR", MIDI_TYPE_KEY }, - { MIDI_ACTION_XIT_VAL, "XITVAL", MIDI_TYPE_KNOB|MIDI_TYPE_WHEEL }, - { MIDI_ACTION_ZOOM, "ZOOM", MIDI_TYPE_KNOB|MIDI_TYPE_WHEEL }, - { MIDI_ACTION_ZOOM_UP, "ZOOMUP", MIDI_TYPE_KEY|MIDI_TYPE_WHEEL }, - { MIDI_ACTION_ZOOM_DOWN, "ZOOMDOWN", MIDI_TYPE_KEY|MIDI_TYPE_WHEEL }, - { MIDI_ACTION_LAST, "NONE", MIDI_TYPE_NONE }, + { MIDI_ACTION_NONE, "NONE", MIDI_KEY|MIDI_KNOB|MIDI_WHEEL }, + { MIDI_ACTION_VFO_A2B, "A2B", MIDI_KEY }, + { MIDI_ACTION_AF_GAIN, "AFGAIN", MIDI_KNOB|MIDI_WHEEL }, + { MIDI_ACTION_AGCATTACK, "AGCATTACK", MIDI_KEY }, + { MIDI_ACTION_AGC, "AGCVAL", MIDI_KNOB|MIDI_WHEEL }, + { MIDI_ACTION_ANF, "ANF", MIDI_KEY }, + { MIDI_ACTION_ATT, "ATT", MIDI_KEY|MIDI_KNOB|MIDI_WHEEL }, + { MIDI_ACTION_VFO_B2A, "B2A", MIDI_KEY }, + { MIDI_ACTION_BAND_10, "BAND10", MIDI_KEY }, + { MIDI_ACTION_BAND_12, "BAND12", MIDI_KEY }, + { MIDI_ACTION_BAND_1240, "BAND1240", MIDI_KEY }, + { MIDI_ACTION_BAND_144, "BAND144", MIDI_KEY }, + { MIDI_ACTION_BAND_15, "BAND15", MIDI_KEY }, + { MIDI_ACTION_BAND_160, "BAND160", MIDI_KEY }, + { MIDI_ACTION_BAND_17, "BAND17", MIDI_KEY }, + { MIDI_ACTION_BAND_20, "BAND20", MIDI_KEY }, + { MIDI_ACTION_BAND_220, "BAND220", MIDI_KEY }, + { MIDI_ACTION_BAND_2300, "BAND2300", MIDI_KEY }, + { MIDI_ACTION_BAND_30, "BAND30", MIDI_KEY }, + { MIDI_ACTION_BAND_3400, "BAND3400", MIDI_KEY }, + { MIDI_ACTION_BAND_40, "BAND40", MIDI_KEY }, + { MIDI_ACTION_BAND_430, "BAND430", MIDI_KEY }, + { MIDI_ACTION_BAND_6, "BAND6", MIDI_KEY }, + { MIDI_ACTION_BAND_60, "BAND60", MIDI_KEY }, + { MIDI_ACTION_BAND_70, "BAND70", MIDI_KEY }, + { MIDI_ACTION_BAND_80, "BAND80", MIDI_KEY }, + { MIDI_ACTION_BAND_902, "BAND902", MIDI_KEY }, + { MIDI_ACTION_BAND_AIR, "BANDAIR", MIDI_KEY }, + { MIDI_ACTION_BAND_DOWN, "BANDDOWN", MIDI_KEY|MIDI_KNOB|MIDI_WHEEL }, + { MIDI_ACTION_BAND_GEN, "BANDGEN", MIDI_KEY }, + { MIDI_ACTION_BAND_UP, "BANDUP", MIDI_KEY|MIDI_KNOB|MIDI_WHEEL }, + { MIDI_ACTION_BAND_WWV, "BANDWWV", MIDI_KEY }, + { MIDI_ACTION_COMPRESS, "COMPRESS", MIDI_KNOB|MIDI_WHEEL }, + { MIDI_ACTION_CTUN, "CTUN", MIDI_KEY }, + { MIDI_ACTION_VFO, "CURRVFO", MIDI_WHEEL }, + { MIDI_ACTION_CWKEYER, "CW(Keyer)", MIDI_KEY }, + { MIDI_ACTION_CWLEFT, "CWLEFT", MIDI_KEY }, + { MIDI_ACTION_CWRIGHT, "CWRIGHT", MIDI_KEY }, + { MIDI_ACTION_CWSPEED, "CWSPEED", MIDI_KNOB|MIDI_WHEEL }, + { MIDI_ACTION_DIV_COARSEGAIN, "DIVCOARSEGAIN", MIDI_KNOB|MIDI_WHEEL }, + { MIDI_ACTION_DIV_COARSEPHASE, "DIVCOARSEPHASE", MIDI_KNOB|MIDI_WHEEL }, + { MIDI_ACTION_DIV_FINEGAIN, "DIVFINEGAIN", MIDI_KNOB|MIDI_WHEEL }, + { MIDI_ACTION_DIV_FINEPHASE, "DIVFINEPHASE", MIDI_KNOB|MIDI_WHEEL }, + { MIDI_ACTION_DIV_GAIN, "DIVGAIN", MIDI_KNOB|MIDI_WHEEL }, + { MIDI_ACTION_DIV_PHASE, "DIVPHASE", MIDI_KNOB|MIDI_WHEEL }, + { MIDI_ACTION_DIV_TOGGLE, "DIVTOGGLE", MIDI_KEY }, + { MIDI_ACTION_DUP, "DUP", MIDI_KEY }, + { MIDI_ACTION_FILTER_DOWN, "FILTERDOWN", MIDI_KEY|MIDI_KNOB|MIDI_WHEEL }, + { MIDI_ACTION_FILTER_UP, "FILTERUP", MIDI_KEY|MIDI_KNOB|MIDI_WHEEL }, + { MIDI_ACTION_LOCK, "LOCK", MIDI_KEY }, + { MIDI_ACTION_MEM_RECALL_M0, "RECALLM0", MIDI_KEY }, + { MIDI_ACTION_MEM_RECALL_M1, "RECALLM1", MIDI_KEY }, + { MIDI_ACTION_MEM_RECALL_M2, "RECALLM2", MIDI_KEY }, + { MIDI_ACTION_MEM_RECALL_M3, "RECALLM3", MIDI_KEY }, + { MIDI_ACTION_MEM_RECALL_M4, "RECALLM4", MIDI_KEY }, + { MIDI_ACTION_MENU_FILTER, "MENU_FILTER", MIDI_KEY }, + { MIDI_ACTION_MENU_MODE, "MENU_MODE", MIDI_KEY }, + { MIDI_ACTION_MIC_VOLUME, "MICGAIN", MIDI_KNOB|MIDI_WHEEL }, + { MIDI_ACTION_MODE_DOWN, "MODEDOWN", MIDI_KEY|MIDI_KNOB|MIDI_WHEEL }, + { MIDI_ACTION_MODE_UP, "MODEUP", MIDI_KEY|MIDI_KNOB|MIDI_WHEEL }, + { MIDI_ACTION_MOX, "MOX", MIDI_KEY }, + { MIDI_ACTION_MUTE, "MUTE", MIDI_KEY }, + { MIDI_ACTION_NB, "NOISEBLANKER", MIDI_KEY }, + { MIDI_ACTION_NR, "NOISEREDUCTION", MIDI_KEY }, + { MIDI_ACTION_NUMPAD_0, "NUMPAD0", MIDI_KEY }, + { MIDI_ACTION_NUMPAD_1, "NUMPAD1", MIDI_KEY }, + { MIDI_ACTION_NUMPAD_2, "NUMPAD2", MIDI_KEY }, + { MIDI_ACTION_NUMPAD_3, "NUMPAD3", MIDI_KEY }, + { MIDI_ACTION_NUMPAD_4, "NUMPAD4", MIDI_KEY }, + { MIDI_ACTION_NUMPAD_5, "NUMPAD5", MIDI_KEY }, + { MIDI_ACTION_NUMPAD_6, "NUMPAD6", MIDI_KEY }, + { MIDI_ACTION_NUMPAD_7, "NUMPAD7", MIDI_KEY }, + { MIDI_ACTION_NUMPAD_8, "NUMPAD8", MIDI_KEY }, + { MIDI_ACTION_NUMPAD_9, "NUMPAD9", MIDI_KEY }, + { MIDI_ACTION_NUMPAD_CL, "NUMPADCL", MIDI_KEY }, + { MIDI_ACTION_NUMPAD_ENTER, "NUMPADENTER", MIDI_KEY }, + { MIDI_ACTION_PAN, "PAN", MIDI_KNOB|MIDI_WHEEL }, + { MIDI_ACTION_PAN_HIGH, "PANHIGH", MIDI_KNOB|MIDI_WHEEL }, + { MIDI_ACTION_PAN_LOW, "PANLOW", MIDI_KNOB|MIDI_WHEEL }, + { MIDI_ACTION_PRE, "PREAMP", MIDI_KEY }, + { MIDI_ACTION_PTTKEYER, "PTT(Keyer)", MIDI_KEY }, + { MIDI_ACTION_PS, "PURESIGNAL", MIDI_KEY }, + { MIDI_ACTION_RF_GAIN, "RFGAIN", MIDI_KNOB|MIDI_WHEEL }, + { MIDI_ACTION_TX_DRIVE, "RFPOWER", MIDI_KNOB|MIDI_WHEEL }, + { MIDI_ACTION_RIT_CLEAR, "RITCLEAR", MIDI_KEY }, + { MIDI_ACTION_RIT_STEP, "RITSTEP", MIDI_KEY|MIDI_WHEEL }, + { MIDI_ACTION_RIT_TOGGLE, "RITTOGGLE", MIDI_KEY }, + { MIDI_ACTION_RIT_VAL, "RITVAL", MIDI_KNOB|MIDI_WHEEL }, + { MIDI_ACTION_SAT, "SAT", MIDI_KEY }, + { MIDI_ACTION_SNB, "SNB", MIDI_KEY }, + { MIDI_ACTION_SPLIT, "SPLIT", MIDI_KEY }, + { MIDI_ACTION_MEM_STORE_M0, "STOREM0", MIDI_KEY }, + { MIDI_ACTION_MEM_STORE_M1, "STOREM1", MIDI_KEY }, + { MIDI_ACTION_MEM_STORE_M2, "STOREM2", MIDI_KEY }, + { MIDI_ACTION_MEM_STORE_M3, "STOREM3", MIDI_KEY }, + { MIDI_ACTION_MEM_STORE_M4, "STOREM4", MIDI_KEY }, + { MIDI_ACTION_SWAP_RX, "SWAPRX", MIDI_KEY }, + { MIDI_ACTION_SWAP_VFO, "SWAPVFO", MIDI_KEY }, + { MIDI_ACTION_TUNE, "TUNE", MIDI_KEY }, + { MIDI_ACTION_VFOA, "VFOA", MIDI_WHEEL }, + { MIDI_ACTION_VFOB, "VFOB", MIDI_WHEEL }, + { MIDI_ACTION_VFO_STEP_UP, "VFOSTEPUP", MIDI_KEY|MIDI_WHEEL }, + { MIDI_ACTION_VFO_STEP_DOWN, "VFOSTEPDOWN", MIDI_KEY|MIDI_WHEEL }, + { MIDI_ACTION_VOX, "VOX", MIDI_KEY }, + { MIDI_ACTION_VOXLEVEL, "VOXLEVEL", MIDI_KNOB|MIDI_WHEEL }, + { MIDI_ACTION_XIT_CLEAR, "XITCLEAR", MIDI_KEY }, + { MIDI_ACTION_XIT_VAL, "XITVAL", MIDI_KNOB|MIDI_WHEEL }, + { MIDI_ACTION_ZOOM, "ZOOM", MIDI_KNOB|MIDI_WHEEL }, + { MIDI_ACTION_ZOOM_UP, "ZOOMUP", MIDI_KEY|MIDI_WHEEL }, + { MIDI_ACTION_ZOOM_DOWN, "ZOOMDOWN", MIDI_KEY|MIDI_WHEEL }, + { MIDI_ACTION_LAST, "NONE", TYPE_NONE }, }; @@ -380,8 +382,8 @@ int MIDIstartup(char *filename) { t5= 0; t6= 63; t7=65; t8=127; t9 = t10 = t11 = t12 = -1; - event=MIDI_EVENT_NONE; - type=MIDI_TYPE_NONE; + event=EVENT_NONE; + type=TYPE_NONE; key=0; delay=0; @@ -392,25 +394,25 @@ int MIDIstartup(char *filename) { // if ((cp = strstr(zeile, "KEY="))) { sscanf(cp+4, "%d", &key); - event=MIDI_EVENT_NOTE; - type=MIDI_TYPE_KEY; + event=MIDI_NOTE; + type=MIDI_KEY; //g_print("%s: MIDI:KEY:%d\n",__FUNCTION__, key); } if ((cp = strstr(zeile, "CTRL="))) { sscanf(cp+5, "%d", &key); - event=MIDI_EVENT_CTRL; - type=MIDI_TYPE_KNOB; + event=MIDI_CTRL; + type=MIDI_KNOB; //g_print("%s: MIDI:CTL:%d\n",__FUNCTION__, key); } if ((cp = strstr(zeile, "PITCH "))) { - event=MIDI_EVENT_PITCH; - type=MIDI_TYPE_KNOB; + event=MIDI_PITCH; + type=MIDI_KNOB; //g_print("%s: MIDI:PITCH\n",__FUNCTION__); } // // If event is still undefined, skip line // - if (event == MIDI_EVENT_NONE) { + if (event == EVENT_NONE) { //g_print("%s: no event found: %s\n", __FUNCTION__, zeile); continue; } @@ -427,9 +429,9 @@ int MIDIstartup(char *filename) { if (chan<0 || chan>15) chan=-1; //g_print("%s:CHAN:%d\n",__FUNCTION__,chan); } - if ((cp = strstr(zeile, "WHEEL")) && (type == MIDI_TYPE_KNOB)) { - // change type from MIDI_TYPE_KNOB to MIDI_TYPE_WHEEL - type=MIDI_TYPE_WHEEL; + if ((cp = strstr(zeile, "WHEEL")) && (type == MIDI_KNOB)) { + // change type from MIDI_KNOB to MIDI_WHEEL + type=MIDI_WHEEL; //g_print("%s:WHEEL\n",__FUNCTION__); } if ((cp = strstr(zeile, "DELAY="))) { @@ -446,8 +448,8 @@ int MIDIstartup(char *filename) { cq=cp+7; while (*cq != 0 && *cq != '\n' && *cq != ' ' && *cq != '\t') cq++; *cq=0; - action = keyword2action(cp+7); - //g_print("MIDI:ACTION:%s (%d)\n",cp+7, action); + action = keyword2action(cp+7); +//g_print("MIDI:ACTION:%s (%d)\n",cp+7, action); } // // All data for a descriptor has been read. Construct it! @@ -475,11 +477,11 @@ int MIDIstartup(char *filename) { // insert descriptor into linked list. // We have a linked list for each key value to speed up searches // - if (event == MIDI_EVENT_PITCH) { + if (event == MIDI_PITCH) { //g_print("%s: Insert desc=%p in CMDS[128] table\n",__FUNCTION__,desc); MidiAddCommand(128, desc); } - if (event == MIDI_EVENT_NOTE || event == MIDI_EVENT_CTRL) { + if (event == MIDI_NOTE || event == MIDI_CTRL) { //g_print("%s: Insert desc=%p in CMDS[%d] table\n",__FUNCTION__,desc,key); MidiAddCommand(key, desc); } diff --git a/midi3.c b/midi3.c index 0b5b7ee..f632586 100644 --- a/midi3.c +++ b/midi3.c @@ -6,9 +6,9 @@ * * In most cases, a certain action only makes sense for a specific * type. For example, changing the VFO frequency will only be implemeted - * for MIDI_TYPE_WHEEL, and TUNE off/on only with MIDI_TYPE_KNOB. + * for MIDI_WHEEL, and TUNE off/on only with MIDI_KNOB. * - * However, changing the volume makes sense both with MIDI_TYPE_KNOB and MIDI_TYPE_WHEEL. + * However, changing the volume makes sense both with MIDI_KNOB and MIDI_WHEEL. */ #include @@ -130,10 +130,10 @@ int DoTheRestOfTheMIDI(void *data) { /////////////////////////////////////////////////////////// "AFGAIN" case MIDI_ACTION_AF_GAIN: // knob or wheel supported switch (type) { - case MIDI_TYPE_KNOB: + case MIDI_KNOB: active_receiver->volume = 0.01*val; break; - case MIDI_TYPE_WHEEL: + case MIDI_WHEEL: dnew=active_receiver->volume += 0.01*val; if (dnew < 0.0) dnew=0.0; if (dnew > 1.0) dnew=1.0; active_receiver->volume = dnew; @@ -156,10 +156,10 @@ int DoTheRestOfTheMIDI(void *data) { /////////////////////////////////////////////////////////// "AGCVAL" case MIDI_ACTION_AGC: // knob or wheel supported switch (type) { - case MIDI_TYPE_KNOB: + case MIDI_KNOB: dnew = -20.0 + 1.4*val; break; - case MIDI_TYPE_WHEEL: + case MIDI_WHEEL: dnew=active_receiver->agc_gain + val; if (dnew < -20.0) dnew = -20.0; if (dnew > 120.0) dnew = 120.0; @@ -187,7 +187,7 @@ int DoTheRestOfTheMIDI(void *data) { /////////////////////////////////////////////////////////// "ATT" case MIDI_ACTION_ATT: // Key for ALEX attenuator, wheel or knob for slider switch(type) { - case MIDI_TYPE_KEY: + case MIDI_KEY: if (filter_board == ALEX && active_receiver->adc == 0) { new=active_receiver->alex_attenuation + 1; if (new > 3) new=0; @@ -195,7 +195,7 @@ int DoTheRestOfTheMIDI(void *data) { update_att_preamp(); } break; - case MIDI_TYPE_WHEEL: + case MIDI_WHEEL: dnew=adc[active_receiver->adc].attenuation + val; if(have_rx_gain) { if(dnew < -12.0) { @@ -212,7 +212,7 @@ int DoTheRestOfTheMIDI(void *data) { } set_attenuation_value(dnew); break; - case MIDI_TYPE_KNOB: + case MIDI_KNOB: if (have_rx_gain) { dnew = -12.0 + 0.6*val; } else { @@ -314,13 +314,13 @@ int DoTheRestOfTheMIDI(void *data) { case MIDI_ACTION_BAND_DOWN: case MIDI_ACTION_BAND_UP: switch (type) { - case MIDI_TYPE_KEY: + case MIDI_KEY: new=(action == MIDI_ACTION_BAND_UP) ? 1 : -1; break; - case MIDI_TYPE_WHEEL: + case MIDI_WHEEL: new=val > 0 ? 1 : -1; break; - case MIDI_TYPE_KNOB: + case MIDI_KNOB: // cycle through the bands new = ((BANDS-1) * val) / 100 - vfo[active_receiver->id].band; break; @@ -344,12 +344,12 @@ int DoTheRestOfTheMIDI(void *data) { /////////////////////////////////////////////////////////// "COMPRESS" case MIDI_ACTION_COMPRESS: // wheel or knob switch (type) { - case MIDI_TYPE_WHEEL: + case MIDI_WHEEL: dnew=transmitter->compressor_level + val; if (dnew > 20.0) dnew=20.0; if (dnew < 0 ) dnew=0; break; - case MIDI_TYPE_KNOB: + case MIDI_KNOB: dnew=(20.0*val)/100.0; break; default: @@ -384,11 +384,11 @@ int DoTheRestOfTheMIDI(void *data) { /////////////////////////////////////////////////////////// "CWSPEED" case MIDI_ACTION_CWSPEED: // knob or wheel switch (type) { - case MIDI_TYPE_KNOB: + case MIDI_KNOB: // speed between 5 and 35 wpm new= (int) (5.0 + (double) val * 0.3); break; - case MIDI_TYPE_WHEEL: + case MIDI_WHEEL: // here we allow from 1 to 60 wpm new = cw_keyer_speed + val; if (new < 1) new=1; @@ -411,7 +411,7 @@ int DoTheRestOfTheMIDI(void *data) { case MIDI_ACTION_DIV_FINEGAIN: // knob or wheel supported case MIDI_ACTION_DIV_GAIN: // knob or wheel supported switch (type) { - case MIDI_TYPE_KNOB: + case MIDI_KNOB: if (action == MIDI_ACTION_DIV_COARSEGAIN || action == MIDI_ACTION_DIV_GAIN) { // -25 to +25 dB in steps of 0.5 dB dnew = 10.0*(-25.0 + 0.5*val - div_gain); @@ -421,7 +421,7 @@ int DoTheRestOfTheMIDI(void *data) { dnew = 10.0*((double) new + 0.01*val - 0.5 - div_gain); } break; - case MIDI_TYPE_WHEEL: + case MIDI_WHEEL: // coarse: increaments in steps of 0.25 dB, medium: steps of 0.1 dB fine: in steps of 0.01 dB if (action == MIDI_ACTION_DIV_GAIN) { dnew = val*0.5; @@ -446,7 +446,7 @@ int DoTheRestOfTheMIDI(void *data) { case MIDI_ACTION_DIV_PHASE: // knob or wheel supported dnew=0.0; switch (type) { - case MIDI_TYPE_KNOB: + case MIDI_KNOB: // coarse: change phase from -180 to 180 // fine: change from -5 to 5 if (action == MIDI_ACTION_DIV_COARSEPHASE || action == MIDI_ACTION_DIV_PHASE) { @@ -458,7 +458,7 @@ int DoTheRestOfTheMIDI(void *data) { dnew = (double) new + 0.1*val -5.0 -div_phase; } break; - case MIDI_TYPE_WHEEL: + case MIDI_WHEEL: if (action == MIDI_ACTION_DIV_PHASE) { dnew = val*0.5; } else if (action == MIDI_ACTION_DIV_COARSEPHASE) { @@ -496,13 +496,13 @@ int DoTheRestOfTheMIDI(void *data) { // Therefore let MIDI_ACTION_FILTER_UP move down. // switch (type) { - case MIDI_TYPE_KEY: + case MIDI_KEY: new=(action == MIDI_ACTION_FILTER_UP) ? -1 : 1; break; - case MIDI_TYPE_WHEEL: + case MIDI_WHEEL: new=val > 0 ? -1 : 1; break; - case MIDI_TYPE_KNOB: + case MIDI_KNOB: // cycle through all the filters: val=100 maps to filter #0 new = ((FILTERS-1) * (val-100)) / 100 - vfo[active_receiver->id].filter; break; @@ -536,10 +536,10 @@ int DoTheRestOfTheMIDI(void *data) { case MIDI_ACTION_MIC_VOLUME: // knob or wheel supported // TODO: possibly adjust linein value if that is effective switch (type) { - case MIDI_TYPE_KNOB: + case MIDI_KNOB: dnew = -10.0 + 0.6*val; break; - case MIDI_TYPE_WHEEL: + case MIDI_WHEEL: dnew = mic_gain + val; if (dnew < -10.0) dnew = -10.0; if (dnew > 50.0) dnew = 50.0; @@ -557,13 +557,13 @@ int DoTheRestOfTheMIDI(void *data) { case MIDI_ACTION_MODE_DOWN: case MIDI_ACTION_MODE_UP: switch (type) { - case MIDI_TYPE_KEY: + case MIDI_KEY: new=(action == MIDI_ACTION_MODE_UP) ? 1 : -1; break; - case MIDI_TYPE_WHEEL: + case MIDI_WHEEL: new=val > 0 ? 1 : -1; break; - case MIDI_TYPE_KNOB: + case MIDI_KNOB: // cycle through all the modes new = ((MODES-1) * val) / 100 - vfo[active_receiver->id].mode; break; @@ -666,10 +666,10 @@ int DoTheRestOfTheMIDI(void *data) { /////////////////////////////////////////////////////////// "PAN" case MIDI_ACTION_PAN: // wheel and knob switch (type) { - case MIDI_TYPE_WHEEL: + case MIDI_WHEEL: update_pan(val*10.0); break; - case MIDI_TYPE_KNOB: + case MIDI_KNOB: if(active_receiver->zoom>1) { int pos=GPOINTER_TO_INT(data); double pan=(double)((active_receiver->zoom-1)*active_receiver->width)*((double)pos/100.0); @@ -684,7 +684,7 @@ int DoTheRestOfTheMIDI(void *data) { /////////////////////////////////////////////////////////// "PANHIGH" case MIDI_ACTION_PAN_HIGH: // wheel or knob switch (type) { - case MIDI_TYPE_WHEEL: + case MIDI_WHEEL: if (mox) { // TX panadapter affected transmitter->panadapter_high += val; @@ -692,7 +692,7 @@ int DoTheRestOfTheMIDI(void *data) { active_receiver->panadapter_high += val; } break; - case MIDI_TYPE_KNOB: + case MIDI_KNOB: // Adjust "high water" in the range -50 ... 0 dBm new = -50 + val/2; if (mox) { @@ -711,7 +711,7 @@ int DoTheRestOfTheMIDI(void *data) { /////////////////////////////////////////////////////////// "PANLOW" case MIDI_ACTION_PAN_LOW: // wheel and knob switch (type) { - case MIDI_TYPE_WHEEL: + case MIDI_WHEEL: if (isTransmitting()) { // TX panadapter affected transmitter->panadapter_low += val; @@ -719,7 +719,7 @@ int DoTheRestOfTheMIDI(void *data) { active_receiver->panadapter_low += val; } break; - case MIDI_TYPE_KNOB: + case MIDI_KNOB: if (isTransmitting()) { // TX panadapter: use values -100 through -50 new = -100 + val/2; @@ -804,10 +804,10 @@ int DoTheRestOfTheMIDI(void *data) { /////////////////////////////////////////////////////////// "RFGAIN" case MIDI_ACTION_RF_GAIN: // knob or wheel supported switch (type) { - case MIDI_TYPE_KNOB: + case MIDI_KNOB: dnew=val; break; - case MIDI_TYPE_WHEEL: + case MIDI_WHEEL: dnew=adc[active_receiver->id].gain+val; break; default: @@ -822,10 +822,10 @@ int DoTheRestOfTheMIDI(void *data) { /////////////////////////////////////////////////////////// "RFPOWER" case MIDI_ACTION_TX_DRIVE: // knob or wheel supported switch (type) { - case MIDI_TYPE_KNOB: + case MIDI_KNOB: dnew = val; break; - case MIDI_TYPE_WHEEL: + case MIDI_WHEEL: dnew=transmitter->drive + val; if (dnew < 0.0) dnew=0.0; if (dnew > 100.0) dnew=100.0; break; @@ -848,11 +848,11 @@ int DoTheRestOfTheMIDI(void *data) { case MIDI_ACTION_RIT_STEP: // key or wheel supported // This cycles between RIT increments 1, 10, 100, 1, 10, 100, ... switch (type) { - case MIDI_TYPE_KEY: + case MIDI_KEY: // key cycles through in upward direction val=1; /* FALLTHROUGH */ - case MIDI_TYPE_WHEEL: + case MIDI_WHEEL: // wheel cycles upward or downward if (val > 0) { rit_increment=10*rit_increment; @@ -878,7 +878,7 @@ int DoTheRestOfTheMIDI(void *data) { /////////////////////////////////////////////////////////// "RITVAL" case MIDI_ACTION_RIT_VAL: // wheel or knob switch (type) { - case MIDI_TYPE_WHEEL: + case MIDI_WHEEL: // This changes the RIT value incrementally, // but we restrict the change to +/ 9.999 kHz new = vfo[active_receiver->id].rit + val*rit_increment; @@ -886,7 +886,7 @@ int DoTheRestOfTheMIDI(void *data) { if (new < -9999) new= -9999; vfo[active_receiver->id].rit = new; break; - case MIDI_TYPE_KNOB: + case MIDI_KNOB: // knob: adjust in the range +/ 50*rit_increment new = (val-50) * rit_increment; vfo[active_receiver->id].rit = new; @@ -985,11 +985,11 @@ int DoTheRestOfTheMIDI(void *data) { case MIDI_ACTION_VFO_STEP_DOWN: // key or wheel supported case MIDI_ACTION_VFO_STEP_UP: switch (type) { - case MIDI_TYPE_KEY: + case MIDI_KEY: new = (action == MIDI_ACTION_VFO_STEP_UP) ? 1 : -1; update_vfo_step(new); break; - case MIDI_TYPE_WHEEL: + case MIDI_WHEEL: new = (val > 0) ? 1 : -1; update_vfo_step(new); break; @@ -1010,14 +1010,14 @@ int DoTheRestOfTheMIDI(void *data) { /////////////////////////////////////////////////////////// "VOXLEVEL" case MIDI_ACTION_VOXLEVEL: // knob or wheel supported switch (type) { - case MIDI_TYPE_WHEEL: + case MIDI_WHEEL: // This changes the value incrementally, // but stay within limits (0.0 through 1.0) vox_threshold += (double) val * 0.01; if (vox_threshold > 1.0) vox_threshold=1.0; if (vox_threshold < 0.0) vox_threshold=0.0; break; - case MIDI_TYPE_KNOB: + case MIDI_KNOB: vox_threshold = 0.01 * (double) val; break; default: @@ -1040,7 +1040,7 @@ int DoTheRestOfTheMIDI(void *data) { case MIDI_ACTION_XIT_VAL: // wheel and knob supported. if (can_transmit) { switch (type) { - case MIDI_TYPE_WHEEL: + case MIDI_WHEEL: // This changes the XIT value incrementally, // but we restrict the change to +/ 9.999 kHz new = transmitter->xit + val*rit_increment; @@ -1048,7 +1048,7 @@ int DoTheRestOfTheMIDI(void *data) { if (new < -9999) new = -9999; transmitter->xit = new; break; - case MIDI_TYPE_KNOB: + case MIDI_KNOB: // knob: adjust in the range +/ 50*rit_increment new = (val-50) * rit_increment; transmitter->xit = new; @@ -1074,16 +1074,16 @@ int DoTheRestOfTheMIDI(void *data) { case MIDI_ACTION_ZOOM_UP: // key, wheel, knob case MIDI_ACTION_ZOOM_DOWN: // key, wheel, knob switch (type) { - case MIDI_TYPE_KEY: + case MIDI_KEY: if (action == MIDI_ACTION_ZOOM) break; dnew = (action == MIDI_ACTION_ZOOM_UP) ? 1.0 :-1.0; update_zoom(dnew); break; - case MIDI_TYPE_WHEEL: + case MIDI_WHEEL: dnew = (val > 0) ? 1.0 : -1.0; update_zoom(dnew); break; - case MIDI_TYPE_KNOB: + case MIDI_KNOB: dnew= 1.0+ 0.07*val; // from 1.0 to 8.0 if((int)dnew != active_receiver->zoom) { set_zoom(active_receiver->id, dnew); diff --git a/midi_menu.c b/midi_menu.c index 71d5794..9842887 100644 --- a/midi_menu.c +++ b/midi_menu.c @@ -78,7 +78,7 @@ static GtkWidget *update_b; static GtkWidget *delete_b; static GtkWidget *device_b[MAX_MIDI_DEVICES]; -static enum MIDIevent thisEvent=MIDI_EVENT_NONE; +static enum MIDIevent thisEvent=EVENT_NONE; static int thisChannel; static int thisNote; static int thisVal; @@ -178,7 +178,7 @@ static void update_wheelparams(gpointer user_data) { // thre current type is a wheel. If it is a wheel, // set spin buttons to current values. // - if (thisType==MIDI_TYPE_WHEEL) { + if (thisType==MIDI_WHEEL) { gtk_spin_button_set_value(GTK_SPIN_BUTTON(set_delay),(double) thisDelay); gtk_spin_button_set_value(GTK_SPIN_BUTTON(set_vfl1 ),(double) thisVfl1 ); gtk_spin_button_set_value(GTK_SPIN_BUTTON(set_vfl2 ),(double) thisVfl2 ); @@ -218,17 +218,17 @@ static void type_changed_cb(GtkWidget *widget, gpointer data) { gtk_widget_hide(newAction_knob); gtk_widget_hide(newAction_wheel); if (strcmp(type,"NONE")==0) { - thisType=MIDI_TYPE_NONE; + thisType=TYPE_NONE; } else if(strcmp(type,"KEY")==0) { - thisType=MIDI_TYPE_KEY; + thisType=MIDI_KEY; gtk_widget_show(newAction_key); gtk_combo_box_set_active(GTK_COMBO_BOX(newAction_key),key_list[thisAction]); } else if(strcmp(type,"KNOB/SLIDER")==0) { - thisType=MIDI_TYPE_KNOB; + thisType=MIDI_KNOB; gtk_widget_show(newAction_knob); gtk_combo_box_set_active(GTK_COMBO_BOX(newAction_knob),knob_list[thisAction]); } else if(strcmp(type,"WHEEL")==0) { - thisType=MIDI_TYPE_WHEEL; + thisType=MIDI_WHEEL; gtk_widget_show(newAction_wheel); gtk_combo_box_set_active(GTK_COMBO_BOX(newAction_wheel),wheel_list[thisAction]); } @@ -262,13 +262,13 @@ static void tree_selection_changed_cb (GtkTreeSelection *selection, gpointer dat if(str_event!=NULL && str_channel!=NULL && str_note!=NULL && str_type!=NULL && str_action!=NULL) { if(strcmp(str_event,"CTRL")==0) { - thisEvent=MIDI_EVENT_CTRL; + thisEvent=MIDI_CTRL; } else if(strcmp(str_event,"PITCH")==0) { - thisEvent=MIDI_EVENT_PITCH; + thisEvent=MIDI_PITCH; } else if(strcmp(str_event,"NOTE")==0) { - thisEvent=MIDI_EVENT_NOTE; + thisEvent=MIDI_NOTE; } else { - thisEvent=MIDI_EVENT_NONE; + thisEvent=EVENT_NONE; } if (!strncmp(str_channel,"Any", 3)) { thisChannel=-1; @@ -280,13 +280,13 @@ static void tree_selection_changed_cb (GtkTreeSelection *selection, gpointer dat thisMin=0; thisMax=0; if(strcmp(str_type,"KEY")==0) { - thisType=MIDI_TYPE_KEY; + thisType=MIDI_KEY; } else if(strcmp(str_type,"KNOB/SLIDER")==0) { - thisType=MIDI_TYPE_KNOB; + thisType=MIDI_KNOB; } else if(strcmp(str_type,"WHEEL")==0) { - thisType=MIDI_TYPE_WHEEL; + thisType=MIDI_WHEEL; } else { - thisType=MIDI_TYPE_NONE; + thisType=TYPE_NONE; } thisAction=MIDI_ACTION_NONE; int i=0; @@ -322,7 +322,7 @@ static void wheelparam_cb(GtkWidget *widget, gpointer user_data) { int val=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget)); int newval=val; - if (thisType != MIDI_TYPE_WHEEL) { + if (thisType != MIDI_WHEEL) { // we should never arrive here return; } @@ -489,16 +489,16 @@ static void add_store(int key,struct desc *cmd) { //g_print("%s: key=%d desc=%p\n",__FUNCTION__,key,cmd); switch(cmd->event) { - case MIDI_EVENT_NONE: + case EVENT_NONE: strcpy(str_event,"NONE"); break; - case MIDI_EVENT_NOTE: + case MIDI_NOTE: strcpy(str_event,"NOTE"); break; - case MIDI_EVENT_CTRL: + case MIDI_CTRL: strcpy(str_event,"CTRL"); break; - case MIDI_EVENT_PITCH: + case MIDI_PITCH: strcpy(str_event,"PITCH"); break; } @@ -509,16 +509,16 @@ static void add_store(int key,struct desc *cmd) { } sprintf(str_note,"%d",key); switch(cmd->type) { - case MIDI_TYPE_NONE: + case TYPE_NONE: strcpy(str_type,"NONE"); break; - case MIDI_TYPE_KEY: + case MIDI_KEY: strcpy(str_type,"KEY"); break; - case MIDI_TYPE_KNOB: + case MIDI_KNOB: strcpy(str_type,"KNOB/SLIDER"); break; - case MIDI_TYPE_WHEEL: + case MIDI_WHEEL: strcpy(str_type,"WHEEL"); break; } @@ -570,16 +570,16 @@ static void add_cb(GtkButton *widget,gpointer user_data) { } if(strcmp(str_type,"KEY")==0) { - type=MIDI_TYPE_KEY; + type=MIDI_KEY; str_action=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(newAction_key)); } else if(strcmp(str_type,"KNOB/SLIDER")==0) { - type=MIDI_TYPE_KNOB; + type=MIDI_KNOB; str_action=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(newAction_knob)); } else if(strcmp(str_type,"WHEEL")==0) { - type=MIDI_TYPE_WHEEL; + type=MIDI_WHEEL; str_action=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(newAction_wheel)); } else { - type=MIDI_TYPE_NONE; + type=TYPE_NONE; str_action="NONE"; } @@ -646,16 +646,16 @@ static void update_cb(GtkButton *widget,gpointer user_data) { gchar *str_action; if(strcmp(str_type,"KEY")==0) { - thisType=MIDI_TYPE_KEY; + thisType=MIDI_KEY; str_action=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(newAction_key)); } else if(strcmp(str_type,"KNOB/SLIDER")==0) { - thisType=MIDI_TYPE_KNOB; + thisType=MIDI_KNOB; str_action=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(newAction_knob)); } else if(strcmp(str_type,"WHEEL")==0) { - thisType=MIDI_TYPE_WHEEL; + thisType=MIDI_WHEEL; str_action=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(newAction_wheel)); } else { - thisType=MIDI_TYPE_NONE; + thisType=TYPE_NONE; str_action="NONE"; } //g_print("%s: type=%s action=%s\n",__FUNCTION__,str_type,str_action); @@ -689,16 +689,16 @@ static void update_cb(GtkButton *widget,gpointer user_data) { current_cmd->vfr2 =thisVfr2; switch(current_cmd->event) { - case MIDI_EVENT_NONE: + case EVENT_NONE: strcpy(str_event,"NONE"); break; - case MIDI_EVENT_NOTE: + case MIDI_NOTE: strcpy(str_event,"NOTE"); break; - case MIDI_EVENT_CTRL: + case MIDI_CTRL: strcpy(str_event,"CTRL"); break; - case MIDI_EVENT_PITCH: + case MIDI_PITCH: strcpy(str_event,"PITCH"); break; } @@ -954,15 +954,15 @@ void midi_menu(GtkWidget *parent) { key_list[i]=0; knob_list[i]=0; wheel_list[i]=0; - if(ActionTable[i].type&MIDI_TYPE_KEY) { + if(ActionTable[i].type&MIDI_KEY) { gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(newAction_key),NULL,ActionTable[i].str); key_list[i]=jkey++; } - if(ActionTable[i].type&MIDI_TYPE_KNOB) { + if(ActionTable[i].type&MIDI_KNOB) { gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(newAction_knob),NULL,ActionTable[i].str); knob_list[i]=jknob++; } - if(ActionTable[i].type&MIDI_TYPE_WHEEL) { + if(ActionTable[i].type&MIDI_WHEEL) { gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(newAction_wheel),NULL,ActionTable[i].str); wheel_list[i]=jwheel++; } @@ -1209,16 +1209,16 @@ static int update(void *data) { case UPDATE_NEW: g_print("%s: UPDATE_NEW\n",__FUNCTION__); switch(thisEvent) { - case MIDI_EVENT_NONE: + case EVENT_NONE: gtk_label_set_text(GTK_LABEL(newEvent),"NONE"); break; - case MIDI_EVENT_NOTE: + case MIDI_NOTE: gtk_label_set_text(GTK_LABEL(newEvent),"NOTE"); break; - case MIDI_EVENT_CTRL: + case MIDI_CTRL: gtk_label_set_text(GTK_LABEL(newEvent),"CTRL"); break; - case MIDI_EVENT_PITCH: + case MIDI_PITCH: gtk_label_set_text(GTK_LABEL(newEvent),"PITCH"); break; } @@ -1233,15 +1233,15 @@ static int update(void *data) { gtk_combo_box_text_remove_all(GTK_COMBO_BOX_TEXT(newType)); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(newType),NULL,"NONE"); switch(thisEvent) { - case MIDI_EVENT_NONE: + case EVENT_NONE: gtk_combo_box_set_active (GTK_COMBO_BOX(newType),0); break; - case MIDI_EVENT_NOTE: - case MIDI_EVENT_PITCH: + case MIDI_NOTE: + case MIDI_PITCH: gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(newType),NULL,"KEY"); gtk_combo_box_set_active (GTK_COMBO_BOX(newType),1); break; - case MIDI_EVENT_CTRL: + case MIDI_CTRL: gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(newType),NULL,"KNOB/SLIDER"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(newType),NULL,"WHEEL"); gtk_combo_box_set_active (GTK_COMBO_BOX(newType),0); @@ -1273,16 +1273,16 @@ static int update(void *data) { case UPDATE_EXISTING: g_print("%s: UPDATE_EXISTING Type=%d Action=%d\n",__FUNCTION__,thisType,thisAction); switch(thisEvent) { - case MIDI_EVENT_NONE: + case EVENT_NONE: gtk_label_set_text(GTK_LABEL(newEvent),"NONE"); break; - case MIDI_EVENT_NOTE: + case MIDI_NOTE: gtk_label_set_text(GTK_LABEL(newEvent),"NOTE"); break; - case MIDI_EVENT_CTRL: + case MIDI_CTRL: gtk_label_set_text(GTK_LABEL(newEvent),"CTRL"); break; - case MIDI_EVENT_PITCH: + case MIDI_PITCH: gtk_label_set_text(GTK_LABEL(newEvent),"PITCH"); break; } @@ -1297,26 +1297,26 @@ static int update(void *data) { gtk_combo_box_text_remove_all(GTK_COMBO_BOX_TEXT(newType)); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(newType),NULL,"NONE"); switch(thisEvent) { - case MIDI_EVENT_NONE: + case EVENT_NONE: gtk_combo_box_set_active (GTK_COMBO_BOX(newType),0); break; - case MIDI_EVENT_NOTE: - case MIDI_EVENT_PITCH: + case MIDI_NOTE: + case MIDI_PITCH: gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(newType),NULL,"KEY"); - if(thisType==MIDI_TYPE_NONE) { + if(thisType==TYPE_NONE) { gtk_combo_box_set_active (GTK_COMBO_BOX(newType),0); - } else if(thisType==MIDI_TYPE_KEY) { + } else if(thisType==MIDI_KEY) { gtk_combo_box_set_active (GTK_COMBO_BOX(newType),1); } break; - case MIDI_EVENT_CTRL: + case MIDI_CTRL: gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(newType),NULL,"KNOB/SLIDER"); gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(newType),NULL,"WHEEL"); - if(thisType==MIDI_TYPE_NONE) { + if(thisType==TYPE_NONE) { gtk_combo_box_set_active (GTK_COMBO_BOX(newType),0); - } else if(thisType==MIDI_TYPE_KNOB) { + } else if(thisType==MIDI_KNOB) { gtk_combo_box_set_active (GTK_COMBO_BOX(newType),1); - } else if(thisType==MIDI_TYPE_WHEEL) { + } else if(thisType==MIDI_WHEEL) { gtk_combo_box_set_active (GTK_COMBO_BOX(newType),2); } break; @@ -1388,7 +1388,7 @@ void NewMidiConfigureEvent(enum MIDIevent event, int channel, int note, int val) thisVal=val; thisMin=val; thisMax=val; - thisType=MIDI_TYPE_NONE; + thisType=TYPE_NONE; thisAction=MIDI_ACTION_NONE; // // set default values for wheel parameters @@ -1420,13 +1420,13 @@ void NewMidiConfigureEvent(enum MIDIevent event, int channel, int note, int val) if(str_event!=NULL && str_channel!=NULL && str_note!=NULL && str_type!=NULL && str_action!=NULL) { if(strcmp(str_event,"CTRL")==0) { - tree_event=MIDI_EVENT_CTRL; + tree_event=MIDI_CTRL; } else if(strcmp(str_event,"PITCH")==0) { - tree_event=MIDI_EVENT_PITCH; + tree_event=MIDI_PITCH; } else if(strcmp(str_event,"NOTE")==0) { - tree_event=MIDI_EVENT_NOTE; + tree_event=MIDI_NOTE; } else { - tree_event=MIDI_EVENT_NONE; + tree_event=EVENT_NONE; } if (!strncmp(str_channel,"Any", 3)) { tree_channel=-1; @@ -1440,13 +1440,13 @@ void NewMidiConfigureEvent(enum MIDIevent event, int channel, int note, int val) thisMin=0; thisMax=0; if(strcmp(str_type,"KEY")==0) { - thisType=MIDI_TYPE_KEY; + thisType=MIDI_KEY; } else if(strcmp(str_type,"KNOB/SLIDER")==0) { - thisType=MIDI_TYPE_KNOB; + thisType=MIDI_KNOB; } else if(strcmp(str_type,"WHEEL")==0) { - thisType=MIDI_TYPE_WHEEL; + thisType=MIDI_WHEEL; } else { - thisType=MIDI_TYPE_NONE; + thisType=TYPE_NONE; } thisAction=MIDI_ACTION_NONE; int i=1; @@ -1523,7 +1523,7 @@ void midi_save_state() { // For wheels, also store the additional parameters, // but do so only if they deviate from the default values. // - if (cmd->type == MIDI_TYPE_WHEEL) { + if (cmd->type == MIDI_WHEEL) { if (cmd->delay > 0) { sprintf(name,"midi[%d].index[%d].delay",i,index); sprintf(value,"%d",cmd->delay); @@ -1619,7 +1619,6 @@ void midi_restore_state() { // set the "active" flag, and the devices will be opened in // radio.c when it is appropriate // - for(int i=0; iadc); @@ -295,13 +296,13 @@ void set_agc_gain(int rx,double value) { gtk_range_set_value (GTK_RANGE(agc_scale),receiver[rx]->agc_gain); } else { if(scale_status!=AGC_GAIN || scale_rx!=rx) { - if(scale_status!=NO_FUNCTION) { + if(scale_status!=NO_ACTION) { g_source_remove(scale_timer); gtk_widget_destroy(scale_dialog); - scale_status=NO_FUNCTION; + scale_status=NO_ACTION; } } - if(scale_status==NO_FUNCTION) { + if(scale_status==NO_ACTION) { scale_status=AGC_GAIN; scale_rx=rx; char title[64]; @@ -348,20 +349,19 @@ void update_af_gain() { } void set_af_gain(int rx,double value) { - g_print("%s\n",__FUNCTION__); receiver[rx]->volume=value; SetRXAPanelGain1 (receiver[rx]->id, receiver[rx]->volume); if(display_sliders) { gtk_range_set_value (GTK_RANGE(af_gain_scale),receiver[rx]->volume*100.0); } else { if(scale_status!=AF_GAIN || scale_rx!=rx) { - if(scale_status!=NO_FUNCTION) { + if(scale_status!=NO_ACTION) { g_source_remove(scale_timer); gtk_widget_destroy(scale_dialog); - scale_status=NO_FUNCTION; + scale_status=NO_ACTION; } } - if(scale_status==NO_FUNCTION) { + if(scale_status==NO_ACTION) { scale_status=AF_GAIN; scale_rx=rx; char title[64]; @@ -415,13 +415,13 @@ void set_rf_gain(int rx,double value) { gtk_range_set_value (GTK_RANGE(rf_gain_scale),adc[receiver[rx]->id].gain); } else { if(scale_status!=RF_GAIN || scale_rx!=rx) { - if(scale_status!=NO_FUNCTION) { + if(scale_status!=NO_ACTION) { g_source_remove(scale_timer); gtk_widget_destroy(scale_dialog); - scale_status=NO_FUNCTION; + scale_status=NO_ACTION; } } - if(scale_status==NO_FUNCTION) { + if(scale_status==NO_ACTION) { scale_status=RF_GAIN; scale_rx=rx; char title[64]; @@ -448,15 +448,15 @@ void set_rf_gain(int rx,double value) { void set_filter_width(int rx,int width) { g_print("%s\n",__FUNCTION__); - if(scale_status!=FILTER_WIDTH || scale_rx!=rx) { - if(scale_status!=NO_FUNCTION) { + if(scale_status!=IF_WIDTH || scale_rx!=rx) { + if(scale_status!=NO_ACTION) { g_source_remove(scale_timer); gtk_widget_destroy(scale_dialog); - scale_status=NO_FUNCTION; + scale_status=NO_ACTION; } } - if(scale_status==NO_FUNCTION) { - scale_status=FILTER_WIDTH; + if(scale_status==NO_ACTION) { + scale_status=IF_WIDTH; scale_rx=rx; char title[64]; sprintf(title,"Filter Width RX %d (Hz)",rx); @@ -479,15 +479,15 @@ void set_filter_width(int rx,int width) { void set_filter_shift(int rx,int shift) { g_print("%s\n",__FUNCTION__); - if(scale_status!=FILTER_SHIFT || scale_rx!=rx) { - if(scale_status!=NO_FUNCTION) { + if(scale_status!=IF_SHIFT || scale_rx!=rx) { + if(scale_status!=NO_ACTION) { g_source_remove(scale_timer); gtk_widget_destroy(scale_dialog); - scale_status=NO_FUNCTION; + scale_status=NO_ACTION; } } - if(scale_status==NO_FUNCTION) { - scale_status=FILTER_SHIFT; + if(scale_status==NO_ACTION) { + scale_status=IF_SHIFT; scale_rx=rx; char title[64]; sprintf(title,"Filter SHIFT RX %d (Hz)",rx); @@ -526,13 +526,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!=NO_FUNCTION) { + if(scale_status!=NO_ACTION) { g_source_remove(scale_timer); gtk_widget_destroy(scale_dialog); - scale_status=NO_FUNCTION; + scale_status=NO_ACTION; } } - if(scale_status==NO_FUNCTION) { + if(scale_status==NO_ACTION) { 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)); @@ -560,13 +560,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!=NO_FUNCTION) { + if(scale_status!=NO_ACTION) { g_source_remove(scale_timer); gtk_widget_destroy(scale_dialog); - scale_status=NO_FUNCTION; + scale_status=NO_ACTION; } } - if(scale_status==NO_FUNCTION) { + if(scale_status==NO_ACTION) { 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)); @@ -599,13 +599,13 @@ void set_drive(double value) { gtk_range_set_value (GTK_RANGE(drive_scale),value); } else { if(scale_status!=DRIVE) { - if(scale_status!=NO_FUNCTION) { + if(scale_status!=NO_ACTION) { g_source_remove(scale_timer); gtk_widget_destroy(scale_dialog); - scale_status=NO_FUNCTION; + scale_status=NO_ACTION; } } - if(scale_status==NO_FUNCTION) { + if(scale_status==NO_ACTION) { 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)); @@ -684,13 +684,13 @@ void set_squelch() { } else { #endif if(scale_status!=SQUELCH) { - if(scale_status!=NO_FUNCTION) { + if(scale_status!=NO_ACTION) { g_source_remove(scale_timer); gtk_widget_destroy(scale_dialog); - scale_status=NO_FUNCTION; + scale_status=NO_ACTION; } } - if(scale_status==NO_FUNCTION) { + if(scale_status==NO_ACTION) { scale_status=SQUELCH; char title[64]; sprintf(title,"Squelch RX %d (Hz)",active_receiver->id); @@ -723,15 +723,15 @@ void set_compression(TRANSMITTER* tx) { gtk_range_set_value (GTK_RANGE(comp_scale),tx->compressor_level); } else { #endif - if(scale_status!=COMP) { - if(scale_status!=NO_FUNCTION) { + if(scale_status!=COMPRESSION) { + if(scale_status!=NO_ACTION) { g_source_remove(scale_timer); gtk_widget_destroy(scale_dialog); - scale_status=NO_FUNCTION; + scale_status=NO_ACTION; } } - if(scale_status==NO_FUNCTION) { - scale_status=COMP; + if(scale_status==NO_ACTION) { + scale_status=COMPRESSION; 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)); comp_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,0.0, 20.0, 1.00); @@ -755,13 +755,13 @@ void set_compression(TRANSMITTER* tx) { void show_diversity_gain() { g_print("%s\n",__FUNCTION__); if(scale_status!=DIVERSITY_GAIN) { - if(scale_status!=NO_FUNCTION) { + if(scale_status!=NO_ACTION) { g_source_remove(scale_timer); gtk_widget_destroy(scale_dialog); - scale_status=NO_FUNCTION; + scale_status=NO_ACTION; } } - if(scale_status==NO_FUNCTION) { + if(scale_status==NO_ACTION) { 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)); @@ -783,13 +783,13 @@ void show_diversity_gain() { void show_diversity_phase() { g_print("%s\n",__FUNCTION__); if(scale_status!=DIVERSITY_PHASE) { - if(scale_status!=NO_FUNCTION) { + if(scale_status!=NO_ACTION) { g_source_remove(scale_timer); gtk_widget_destroy(scale_dialog); - scale_status=NO_FUNCTION; + scale_status=NO_ACTION; } } - if(scale_status==NO_FUNCTION) { + if(scale_status==NO_ACTION) { 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)); diff --git a/sliders.h b/sliders.h index 7c981c7..877abf6 100644 --- a/sliders.h +++ b/sliders.h @@ -22,25 +22,6 @@ #include "receiver.h" #include "transmitter.h" -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, - ZOOM, - PAN -}; - extern gint scale_timer; extern gint scale_status; extern gint scale_rx; diff --git a/soapy_discovery.c b/soapy_discovery.c index 4d0918c..f571f5b 100644 --- a/soapy_discovery.c +++ b/soapy_discovery.c @@ -118,44 +118,20 @@ static void get_info(char *driver) { } - int sample_rate=0; + int sample_rate=768000; SoapySDRRange *rx_rates=SoapySDRDevice_getSampleRateRange(sdr, SOAPY_SDR_RX, 0, &rx_rates_length); fprintf(stderr,"Rx sample rates: "); for (size_t i = 0; i < rx_rates_length; i++) { fprintf(stderr,"%f -> %f (%f),", rx_rates[i].minimum, rx_rates[i].maximum, rx_rates[i].minimum/48000.0); - if(sample_rate==0) { - if(rx_rates[i].minimum==rx_rates[i].maximum) { - if(((int)rx_rates[i].minimum%48000)==0) { - sample_rate=(int)rx_rates[i].minimum; - } - } else { - if((384000.0>=rx_rates[i].minimum) && (384000<=(int)rx_rates[i].maximum)) { - sample_rate=384000; - } - if((768000.0>=rx_rates[i].minimum) && (768000<=(int)rx_rates[i].maximum)) { - sample_rate=768000; - } - } - } } - fprintf(stderr,"\n"); - free(rx_rates); - - if(strcmp(driver,"lime")==0) { - sample_rate=768000; - } else if(strcmp(driver,"plutosdr")==0) { - sample_rate=768000; - } else if(strcmp(driver,"rtlsdr")==0) { + if(strcmp(driver,"rtlsdr")==0) { sample_rate=1536000; - } else if(strcmp(driver,"sdrplay")==0) { - //sample_rate=96000; - sample_rate=768000; } else if(strcmp(driver,"radioberry")==0) { sample_rate=48000; - } else { - sample_rate=1048576; } + fprintf(stderr,"\n"); + free(rx_rates); fprintf(stderr,"sample_rate selected %d\n",sample_rate); if(tx_channels>0) { diff --git a/switch_menu.c b/switch_menu.c index 68b71c2..6008d43 100644 --- a/switch_menu.c +++ b/switch_menu.c @@ -31,6 +31,7 @@ #include "receiver.h" #include "vfo.h" #include "button_text.h" +#include "actions.h" #include "gpio.h" #include "i2c.h" diff --git a/toolbar.c b/toolbar.c index fce5c88..ceb49c6 100644 --- a/toolbar.c +++ b/toolbar.c @@ -23,6 +23,7 @@ #include #include #include +#include "actions.h" #ifdef GPIO #include "gpio.h" #endif diff --git a/zoompan.c b/zoompan.c index 2052e48..0e18ead 100644 --- a/zoompan.c +++ b/zoompan.c @@ -32,6 +32,7 @@ #ifdef CLIENT_SERVER #include "client_server.h" #endif +#include "actions.h" static int width; static int height; @@ -102,14 +103,14 @@ void set_zoom(int rx,double value) { gtk_range_set_value (GTK_RANGE(zoom_scale),receiver[rx]->zoom); } else { if(scale_status!=ZOOM || scale_rx!=rx) { - if(scale_status!=NO_FUNCTION) { + if(scale_status!=NO_ACTION) { g_source_remove(scale_timer); gtk_widget_destroy(scale_dialog); - scale_status=NO_FUNCTION; + scale_status=NO_ACTION; } } receiver_change_zoom(active_receiver,value); - if(scale_status==NO_FUNCTION) { + if(scale_status==NO_ACTION) { scale_status=ZOOM; scale_rx=rx; char title[64]; @@ -174,14 +175,14 @@ g_print("set_pan: %f\n",value); gtk_range_set_value (GTK_RANGE(pan_scale),receiver[rx]->pan); } else { if(scale_status!=PAN || scale_rx!=rx) { - if(scale_status!=NO_FUNCTION) { + if(scale_status!=NO_ACTION) { g_source_remove(scale_timer); gtk_widget_destroy(scale_dialog); - scale_status=NO_FUNCTION; + scale_status=NO_ACTION; } } receiver_change_pan(active_receiver,value); - if(scale_status==NO_FUNCTION) { + if(scale_status==NO_ACTION) { scale_status=PAN; scale_rx=rx; char title[64]; -- 2.45.2