From 291dcc9c5451334eac787ebbfcc89943e5ee4e8d Mon Sep 17 00:00:00 2001 From: John Melton G0ORX <john.d.melton@googlemail.com> Date: Fri, 12 Mar 2021 15:07:28 +0000 Subject: [PATCH] Fix Controller2 switch configuration --- gpio.c | 13 +++++++++++++ i2c.c | 15 +++++++++++---- switch_menu.c | 4 ++++ transmitter.c | 2 +- 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/gpio.c b/gpio.c index 4ec00a8..f38d86f 100644 --- a/gpio.c +++ b/gpio.c @@ -575,6 +575,7 @@ static void process_edge(int offset,int value) { if(t<switches[i].switch_debounce) { return; } +g_print("%s: switches=%p function=%d (%s)\n",__FUNCTION__,switches,switches[i].switch_function,sw_string[switches[i].switch_function]); switches[i].switch_debounce=t+settle_time; SWITCH_ACTION *a=g_new(SWITCH_ACTION,1); a->action=switches[i].switch_function; @@ -777,7 +778,11 @@ void gpio_save_state() { } } +<<<<<<< HEAD if(controller==CONTROLLER2_V1 || controller==CONTROLLER2_V2) { +======= + if(controller!=CONTROLLER1) { +>>>>>>> 98419181d3881fcaa1986ff14175d74cb9e1bccf for(int i=0;i<MAX_SWITCHES;i++) { sprintf(name,"switches[%d].switch_enabled",i); sprintf(value,"%d",switches[i].switch_enabled); @@ -818,7 +823,11 @@ void gpio_restore_actions() { if(value) switches_controller1[f][i].switch_function=atoi(value); } } +<<<<<<< HEAD if(controller==CONTROLLER2_V1 || controller==CONTROLLER2_V2) { +======= + if(controller!=CONTROLLER1) { +>>>>>>> 98419181d3881fcaa1986ff14175d74cb9e1bccf for(int i=0;i<MAX_SWITCHES;i++) { sprintf(name,"switches[%d].switch_function",i); value=getProperty(name); @@ -851,7 +860,11 @@ void gpio_save_actions() { setProperty(name,value); } } +<<<<<<< HEAD if(controller==CONTROLLER2_V1 || controller==CONTROLLER2_V2) { +======= + if(controller!=CONTROLLER1) { +>>>>>>> 98419181d3881fcaa1986ff14175d74cb9e1bccf for(int i=0;i<MAX_SWITCHES;i++) { sprintf(name,"switches[%d].switch_function",i); sprintf(value,"%d",switches[i].switch_function); diff --git a/i2c.c b/i2c.c index fe1ab34..084be2f 100644 --- a/i2c.c +++ b/i2c.c @@ -45,8 +45,8 @@ static int fd; #define SW_17 0X0100 unsigned int i2c_sw[16]= - { SW_2,SW_3,SW_4,SW_5,SW_6,SW_7,SW_8,SW_9, - SW_10,SW_11,SW_12,SW_13,SW_14,SW_15,SW_16,SW_17 }; + { SW_2,SW_3,SW_4,SW_5,SW_6,SW_14,SW_15,SW_13, + SW_12,SW_11,SW_10,SW_9,SW_7,SW_8,SW_16,SW_17 }; static int write_byte_data(unsigned char reg, unsigned char data) { int rc; @@ -85,14 +85,20 @@ void i2c_interrupt() { flags=read_word_data(0x0E); if(flags) { ints=read_word_data(0x10); -//g_print("i2c_interrupt: flags=%04X ints=%04X\n",flags,ints); +g_print("%s: flags=%04X ints=%04X\n",__FUNCTION__,flags,ints); if(ints) { int i; for(i=0;i<16;i++) { if(i2c_sw[i]==ints) break; } if(i<16) { -//g_print("i1c_interrupt: sw=%d action=%d\n",i,switches[i].switch_function); +g_print("%s: switches=%p sw=%d action=%d\n",__FUNCTION__,switches,i,switches[i].switch_function); + SWITCH_ACTION *a=g_new(SWITCH_ACTION,1); + a->action=switches[i].switch_function; + a->state=PRESSED; + g_idle_add(switch_action,a); + +/* switch(switches[i].switch_function) { case TUNE: if(can_transmit) { @@ -233,6 +239,7 @@ void i2c_interrupt() { g_idle_add(ext_zoom_update,GINT_TO_POINTER(1)); break; } +*/ } } } diff --git a/switch_menu.c b/switch_menu.c index e03908c..43ea0ee 100644 --- a/switch_menu.c +++ b/switch_menu.c @@ -77,6 +77,7 @@ void switch_page_cb(GtkNotebook *notebook,GtkWidget *page,guint page_num,gpointe static void switch_select_cb(GtkWidget *widget, gpointer data) { char text[128]; CHOICE *choice=(CHOICE *)data; +g_print("%s: temp_switches=%p\n",__FUNCTION__,temp_switches); temp_switches[choice->sw].switch_function=choice->action; GtkWidget *label=gtk_bin_get_child(GTK_BIN(choice->button)); sprintf(text,"<span size=\"smaller\">%s</span>",sw_string[choice->action]); @@ -129,6 +130,7 @@ void switch_menu(GtkWidget *parent) { GtkWidget *widget; gint function=0; +g_print("%s: switches_no_controller=%p switches_controller1=%p switches_controller2_v1=%p switches_controller2_v2=%p\n",__FUNCTION__,&switches_no_controller,&switches_controller1,&switches_controller2_v1,&switches_controller2_v2); dialog=gtk_dialog_new_with_buttons("piHPSDR - Switch Actions",GTK_WINDOW(parent),GTK_DIALOG_DESTROY_WITH_PARENT,("OK"),GTK_RESPONSE_ACCEPT,NULL); g_signal_connect (dialog, "response", G_CALLBACK (response_event), NULL); @@ -173,6 +175,8 @@ next_function_set: break; } + g_print("%s: temp_switches=%p\n",temp_switches); + int original_row=row; if(controller==CONTROLLER2_V1 || controller==CONTROLLER2_V2) { diff --git a/transmitter.c b/transmitter.c index a51a22c..99af708 100644 --- a/transmitter.c +++ b/transmitter.c @@ -1223,7 +1223,7 @@ void add_mic_sample(TRANSMITTER *tx,float mic_sample) { // side tone ramp=cwramp48[cw_shape]; cwsample=0.00197 * getNextSideToneSample() * cw_keyer_sidetone_volume * ramp; - cw_audio_write(active_receiver,cwsample); + if(active_receiver->local_audio) cw_audio_write(active_receiver,cwsample); cw_shape_buffer48[tx->samples]=ramp; // // In the new protocol, we MUST maintain a constant flow of audio samples to the radio -- 2.45.2