From 32af94de740eb6c39a31c3bf212d10263e42c506 Mon Sep 17 00:00:00 2001 From: DL1YCF Date: Sat, 22 Aug 2020 12:31:24 +0200 Subject: [PATCH] Reverted storing the "Alex Attenuator" settings for each band, since the step attenuator also are not treated like this. --- Makefile.mac | 4 ++-- client_server.c | 5 ----- client_server.h | 1 - equalizer_menu.c | 5 ++++- ext.c | 5 +---- freqent_menu.c | 9 +++++---- general_menu.c | 2 +- radio.c | 25 ++++++++++--------------- radio.h | 2 +- radio_menu.c | 18 +++++++++++++----- receiver.c | 2 +- rx_menu.c | 14 ++++++-------- sliders.c | 4 +--- vfo.c | 7 ++----- 14 files changed, 47 insertions(+), 56 deletions(-) diff --git a/Makefile.mac b/Makefile.mac index d5d0cd1..89fd8d2 100644 --- a/Makefile.mac +++ b/Makefile.mac @@ -12,7 +12,7 @@ PURESIGNAL_INCLUDE=PURESIGNAL LOCALCW_INCLUDE=LOCALCW # uncomment the line below for SoapySDR -SOAPYSDR_INCLUDE=SOAPYSDR +#SOAPYSDR_INCLUDE=SOAPYSDR # uncomment the line to below include support for sx1509 i2c expander #SX1509_INCLUDE=sx1509 @@ -150,7 +150,7 @@ OPTIONS=$(MIDI_OPTIONS) $(PURESIGNAL_OPTIONS) $(REMOTE_OPTIONS) $(USBOZY_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) $(GTKLIBS) $(SOAPYSDRLIBS) $(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) diff --git a/client_server.c b/client_server.c index aace4b8..5692538 100644 --- a/client_server.c +++ b/client_server.c @@ -1306,11 +1306,6 @@ g_print("send_squelch rx=%d enable=%d squelch=%d\n",rx,enable,squelch); } } -void send_eq(int s, int rxeq, int txeq) { - // inform client about RX/TX equalizer status - // NOT-YET -} - void send_noise(int s,int rx,int nb,int nb2,int nr,int nr2,int anf,int snb) { NOISE_COMMAND command; g_print("send_noise rx=%d nb=%d nb2=%d nr=%d nr2=%d anf=%d snb=%d\n",rx,nb,nb2,nr,nr2,anf,snb); diff --git a/client_server.h b/client_server.h index 6287f74..926b93f 100644 --- a/client_server.h +++ b/client_server.h @@ -488,7 +488,6 @@ extern void send_agc_gain(int s,int rx,int gain,int hang,int thresh); extern void send_attenuation(int s,int rx,int attenuation); extern void send_squelch(int s,int rx,int enable,int squelch); extern void send_noise(int s,int rx,int nb,int nb2,int nr,int nr2,int anf,int snb); -extern void send_eq(int s, int rxeq, int txeq); extern void send_band(int s,int rx,int band); extern void send_mode(int s,int rx,int mode); extern void send_filter(int s,int rx,int filter); diff --git a/equalizer_menu.c b/equalizer_menu.c index fdfea86..f51ef33 100644 --- a/equalizer_menu.c +++ b/equalizer_menu.c @@ -98,7 +98,10 @@ void set_eq() { void update_eq() { #ifdef CLIENT_SERVER if(radio_is_remote) { - send_eq(client_socket,enable_rx_eq, enable_tx_equalizer); + // + // insert here any function to inform the client of equalizer setting + // changes, if this becomes part of the protocol + // } else { #endif set_eq(); diff --git a/ext.c b/ext.c index 41ad26f..6cdf986 100644 --- a/ext.c +++ b/ext.c @@ -310,10 +310,7 @@ int ext_update_att_preamp(void *data) { int ext_set_alex_attenuation(void *data) { int val=GPOINTER_TO_INT(data); - BAND *band=band_get_band(vfo[VFO_A].band); - // store changed attenuation in "band" info - band->alexAttenuation=val; - set_alex_attenuation(); + set_alex_attenuation(val); return 0; } diff --git a/freqent_menu.c b/freqent_menu.c index 9de8a11..d1a57b6 100644 --- a/freqent_menu.c +++ b/freqent_menu.c @@ -130,12 +130,13 @@ static gboolean freqent_select_cb (GtkWidget *widget, gpointer data) { FILTER* band_filters=filters[entry->mode]; FILTER* band_filter=&band_filters[entry->filter]; set_filter(active_receiver,band_filter->low,band_filter->high); + if(active_receiver->id==0) { + set_alex_rx_antenna(); + set_alex_tx_antenna(); + // set_alex_attenuation(band->alexAttenuation); // nowhere maintained + } } setFrequency(f); - // defer set_alex.. until here since setFrequency sets the VFO.band - set_alex_rx_antenna(); - set_alex_tx_antenna(); - set_alex_attenuation(); g_idle_add(ext_vfo_update,NULL); } set = 1; diff --git a/general_menu.c b/general_menu.c index 01e173f..c7c9b68 100644 --- a/general_menu.c +++ b/general_menu.c @@ -110,7 +110,7 @@ static void alex_cb(GtkWidget *widget, gpointer data) { if(active_receiver->id==0) { set_alex_rx_antenna(band->alexRxAntenna); set_alex_tx_antenna(band->alexTxAntenna); - set_alex_attenuation(band->alexAttenuation); + // set_alex_attenuation(band->alexAttenuation); // nowhere maintained } } } diff --git a/radio.c b/radio.c index ded66cb..4a04e69 100644 --- a/radio.c +++ b/radio.c @@ -184,7 +184,11 @@ double mic_gain=0.0; int binaural=0; int mic_linein=0; -int linein_gain=16; // 0..31 +// +// linein_gain = 0...31 maps onto -34.5dB ... +12 dB +// (in 1.5 dB steps), and 0 dB corresponds to linein_gain=23 +// +int linein_gain=23; int mic_boost=0; int mic_bias_enabled=0; int mic_ptt_enabled=0; @@ -1852,21 +1856,12 @@ void set_alex_tx_antenna() { // // For HPSDR, only receiver[0]->alex_attenuation has an effect -// Set this from the attenuation stored "per band" // -void set_alex_attenuation() { - BAND *band; - switch (protocol) { - case ORIGINAL_PROTOCOL: - band=band_get_band(vfo[VFO_A].band); - receiver[0]->alex_attenuation=band->alexAttenuation; - break; - case NEW_PROTOCOL: - band=band_get_band(vfo[VFO_A].band); - receiver[0]->alex_attenuation=band->alexAttenuation; - schedule_high_priority(); - break; - } +void set_alex_attenuation(int v) { + receiver[0]->alex_attenuation=v; + if(protocol==NEW_PROTOCOL) { + schedule_high_priority(); + } } void radioRestoreState() { diff --git a/radio.h b/radio.h index 1d199c1..3772e2c 100644 --- a/radio.h +++ b/radio.h @@ -337,7 +337,7 @@ extern void setSquelch(RECEIVER *rx); extern void set_attenuation(int value); extern void set_alex_rx_antenna(void); extern void set_alex_tx_antenna(void); -extern void set_alex_attenuation(void); +extern void set_alex_attenuation(int v); extern int isTransmitting(); diff --git a/radio_menu.c b/radio_menu.c index aa43bcb..9400f2b 100644 --- a/radio_menu.c +++ b/radio_menu.c @@ -288,13 +288,21 @@ void load_filters(void) { filter_board_changed(); } - // - // This should not be necessary HERE - // - if(filter_board==ALEX || filter_board==APOLLO || filter_board==CHARLY25) { + if(filter_board==ALEX || filter_board==APOLLO) { + BAND *band=band_get_current_band(); + // mode and filters have nothing to do with the filter board + //BANDSTACK_ENTRY* entry=bandstack_entry_get_current(); + //setFrequency(entry->frequency); + //setMode(entry->mode); + //set_mode(active_receiver,entry->mode); + //FILTER* band_filters=filters[entry->mode]; + //FILTER* band_filter=&band_filters[entry->filter]; + //set_filter(active_receiver,band_filter->low,band_filter->high); + if(active_receiver->id==0) { set_alex_rx_antenna(); set_alex_tx_antenna(); - set_alex_attenuation(); + //set_alex_attenuation(band->alexAttenuation); // nowhere maintained + } } att_type_changed(); } diff --git a/receiver.c b/receiver.c index 898f43b..a097579 100644 --- a/receiver.c +++ b/receiver.c @@ -1027,7 +1027,7 @@ fprintf(stderr,"create_receiver: id=%d default adc=%d\n",rx->id, rx->adc); BAND *b=band_get_band(vfo[rx->id].band); rx->alex_antenna=b->alexRxAntenna; - rx->alex_attenuation=b->alexAttenuation; + //rx->alex_attenuation=b->alexAttenuation; // nowhere maintained rx->agc=AGC_MEDIUM; rx->agc_gain=80.0; diff --git a/rx_menu.c b/rx_menu.c index c56a5e4..3fff413 100644 --- a/rx_menu.c +++ b/rx_menu.c @@ -33,7 +33,6 @@ #include "receiver.h" #include "sliders.h" #include "new_protocol.h" -#include "vfo.h" static GtkWidget *parent_window=NULL; static GtkWidget *menu_b=NULL; @@ -81,12 +80,8 @@ static void preamp_cb(GtkWidget *widget, gpointer data) { } static void alex_att_cb(GtkWidget *widget, gpointer data) { - BAND *band; if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) { - // store value in the "band" info - band=band_get_band(vfo[VFO_A].band); - band->alexAttenuation=GPOINTER_TO_INT(data); - set_alex_attenuation(); + set_alex_attenuation((intptr_t) data); update_att_preamp(); } } @@ -314,7 +309,7 @@ void rx_menu(GtkWidget *parent) { #ifdef USBOZY (protocol==ORIGINAL_PROTOCOL && device == DEVICE_OZY) || #endif - (protocol==NEW_PROTOCOL && device == NEW_DEVICE_ATLAS)) { + (protocol==NEW_PROTOCOL && device == NEW_DEVICE_ATLAS)) { GtkWidget *preamp_b=gtk_check_button_new_with_label("Preamp"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (preamp_b), active_receiver->preamp); gtk_grid_attach(GTK_GRID(grid),preamp_b,x,4,1,1); @@ -324,6 +319,9 @@ 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))) { + // + // The "Alex ATT" value is stored in receiver[0] no matter how the ADCs are selected + // 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); @@ -332,7 +330,7 @@ void rx_menu(GtkWidget *parent) { gchar button_text[] = "xx dB"; sprintf(button_text, "%d dB", i*10); GtkWidget *alex_att_b=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(last_alex_att_b), button_text); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(alex_att_b), active_receiver->alex_attenuation == i); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(alex_att_b), receiver[0]->alex_attenuation == i); gtk_grid_attach(GTK_GRID(grid), alex_att_b, x, 6 + i, 1, 1); g_signal_connect(alex_att_b, "toggled", G_CALLBACK(alex_att_cb), GINT_TO_POINTER(i)); last_alex_att_b = alex_att_b; diff --git a/sliders.c b/sliders.c index 07b55a4..0b306c5 100644 --- a/sliders.c +++ b/sliders.c @@ -250,9 +250,7 @@ static void c25_att_combobox_changed(GtkWidget *widget, gpointer data) { // this button is only valid for the first receiver // store attenuation, such that in meter.c the correct level is displayed adc_attenuation[active_receiver->adc] = 12*val; - BAND* band = band_get_band(vfo[VFO_A].band); - band->alexAttenuation=val; - set_alex_attenuation(); + set_alex_attenuation(val); } else { // always show "0 dB" on the button if the second RX is active if (val != 0) { diff --git a/vfo.c b/vfo.c index cb13f64..fefa670 100644 --- a/vfo.c +++ b/vfo.c @@ -410,6 +410,7 @@ void vfo_band_changed(int id,int b) { switch(id) { case 0: bandstack->current_entry=vfo[id].bandstack; + // set_alex_attenuation(band->alexAttenuation); // nowhere maintained receiver_vfo_changed(receiver[0]); break; case 1: @@ -418,7 +419,6 @@ void vfo_band_changed(int id,int b) { } break; } - set_alex_attenuation(); set_alex_rx_antenna(); if(can_transmit) { @@ -461,6 +461,7 @@ void vfo_bandstack_changed(int b) { switch(id) { case 0: bandstack->current_entry=vfo[id].bandstack; + // set_alex_attenuation(band->alexAttenuation); // nowhere maintained receiver_vfo_changed(receiver[0]); break; case 1: @@ -471,7 +472,6 @@ void vfo_bandstack_changed(int b) { } set_alex_rx_antenna(); - set_alex_attenuation(); if(can_transmit) { set_alex_tx_antenna(); tx_set_mode(transmitter,get_tx_mode()); @@ -590,7 +590,6 @@ void vfo_a_to_b() { receiver_vfo_changed(receiver[1]); } set_alex_rx_antenna(); - set_alex_attenuation(); if(can_transmit) { set_alex_tx_antenna(); tx_set_mode(transmitter,get_tx_mode()); @@ -611,7 +610,6 @@ void vfo_b_to_a() { vfo[VFO_A].rit=vfo[VFO_B].rit; receiver_vfo_changed(receiver[0]); set_alex_rx_antenna(); - set_alex_attenuation(); if(can_transmit) { set_alex_tx_antenna(); tx_set_mode(transmitter,get_tx_mode()); @@ -666,7 +664,6 @@ void vfo_a_swap_b() { receiver_vfo_changed(receiver[1]); } set_alex_rx_antenna(); - set_alex_attenuation(); if(can_transmit) { set_alex_tx_antenna(); tx_set_mode(transmitter,get_tx_mode()); -- 2.45.2