]> git.rkrishnan.org Git - pihpsdr.git/commitdiff
manual merge with John's updates
authorc vw <dl1ycf@darc.de>
Mon, 3 Feb 2020 18:27:09 +0000 (19:27 +0100)
committerc vw <dl1ycf@darc.de>
Mon, 3 Feb 2020 18:27:09 +0000 (19:27 +0100)
Makefile
configure.c
discovery.c
gpio.c
gpio.h
i2c.c
i2c.h
main.c
pa_menu.c
release/pihpsdr/pihpsdr
version.c

index cfa1059968b7b1557262f81acc3d5bb94690aff4..1e6c5104607c91e6fb4bd0b81aa450d66a7568ac 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@
 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)
+# uncomment the line below to include GPIO (For original piHPSDR Controller and Controller2 with i2c)
 GPIO_INCLUDE=GPIO
 
 # uncomment the line below to include USB Ozy support
@@ -12,7 +12,7 @@ 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
@@ -104,20 +104,20 @@ ifeq ($(GPIO_INCLUDE),GPIO)
   GPIO_OPTIONS=-D GPIO
   GPIO_LIBS=-lwiringPi -li2c
   GPIO_SOURCES= \
+  configure.c \
   i2c.c \
-  gpio_menu.c \
   gpio.c \
   encoder_menu.c \
   switch_menu.c
   GPIO_HEADERS= \
+  configure.h \
   i2c.h \
-  gpio_menu.h \
   gpio.h \
   encoder_menu.h \
   switch_menu.h
   GPIO_OBJS= \
+  configure.o \
   i2c.o \
-  gpio_menu.o \
   gpio.o \
   encoder_menu.o \
   switch_menu.o
@@ -378,8 +378,8 @@ $(PROGRAM):  $(OBJS) $(REMOTE_OBJS) $(USBOZY_OBJS) $(SOAPYSDR_OBJS) \
 all:   prebuild  $(PROGRAM) $(HEADERS) $(REMOTE_HEADERS) $(USBOZY_HEADERS) $(SOAPYSDR_HEADERS) \
        $(LOCALCW_HEADERS) $(GPIO_HEADERS) \
        $(PURESIGNAL_HEADERS) $(MIDI_HEADERS) $(STEMLAB_HEADERS) $(SOURCES) $(REMOTE_SOURCES) \
-       $(USBOZY_SOURCES) $(SOAPYSDR_SOURCES) $(GPIO_SOURCES) \
-       $(PURESIGNAL_SOURCES) $(MIDI_SOURCES) $(LOCALCW_SOURCES) $(STEMLAB_SOURCES)
+       $(USBOZY_SOURCES) $(SOAPYSDR_SOURCES) $(LOCALCW_SOURCE) $(GPIO_SOURCES) \
+       $(PURESIGNAL_SOURCES) $(MIDI_SOURCES) $(STEMLAB_SOURCES)
 
 .PHONY:        prebuild
 prebuild:
index 05f343833b75688204e289582f07d5a68a818d91..c9c496d1be7e58e3b33c55fb1685f43acc57352b 100644 (file)
@@ -30,8 +30,8 @@
 #include "main.h"
 #include "channel.h"
 #include "discovered.h"
-//#include "radio.h"
 #include "gpio.h"
+#include "i2c.h"
 
 
 #ifdef GPIO
@@ -50,58 +50,83 @@ static   GtkWidget *E2_a;
 static   GtkWidget *E2_b_label;
 static   GtkWidget *E2_b;
 static   GtkWidget *b_enable_E2_pullup;
+static GtkWidget *b_enable_E2_top_encoder;
+static   GtkWidget *E2_top_a_label;
+static   GtkWidget *E2_top_a;
+static   GtkWidget *E2_top_b_label;
+static   GtkWidget *E2_top_b;
+static GtkWidget *E2_sw_label;
+static   GtkWidget *E2_sw;
 static GtkWidget *b_enable_E3_encoder;
 static   GtkWidget *E3_a_label;
 static   GtkWidget *E3_a;
 static   GtkWidget *E3_b_label;
 static   GtkWidget *E3_b;
 static   GtkWidget *b_enable_E3_pullup;
+static GtkWidget *b_enable_E3_top_encoder;
+static   GtkWidget *E3_top_a_label;
+static   GtkWidget *E3_top_a;
+static   GtkWidget *E3_top_b_label;
+static   GtkWidget *E3_top_b;
+static GtkWidget *E3_sw_label;
+static   GtkWidget *E3_sw;
 static GtkWidget *b_enable_E4_encoder;
 static   GtkWidget *E4_a_label;
 static   GtkWidget *E4_a;
 static   GtkWidget *E4_b_label;
 static   GtkWidget *E4_b;
 static   GtkWidget *b_enable_E4_pullup;
-#if defined (CONTROLLER2_V2) || defined (CONTROLLER2_V1)
+static GtkWidget *b_enable_E4_top_encoder;
+static   GtkWidget *E4_top_a_label;
+static   GtkWidget *E4_top_a;
+static   GtkWidget *E4_top_b_label;
+static   GtkWidget *E4_top_b;
+static GtkWidget *E4_sw_label;
+static   GtkWidget *E4_sw;
 static GtkWidget *b_enable_E5_encoder;
 static   GtkWidget *E5_a_label;
 static   GtkWidget *E5_a;
 static   GtkWidget *E5_b_label;
 static   GtkWidget *E5_b;
 static   GtkWidget *b_enable_E5_pullup;
-#endif
+static GtkWidget *b_enable_E5_top_encoder;
+static   GtkWidget *E5_top_a_label;
+static   GtkWidget *E5_top_a;
+static   GtkWidget *E5_top_b_label;
+static   GtkWidget *E5_top_b;
+static GtkWidget *E5_sw_label;
+static   GtkWidget *E5_sw;
+
 static GtkWidget *b_enable_mox;
 static   GtkWidget *mox_label;
 static   GtkWidget *mox;
-
 static GtkWidget *b_enable_S1;
 static   GtkWidget *S1_label;
 static   GtkWidget *S1;
-
 static GtkWidget *b_enable_S2;
 static   GtkWidget *S2_label;
 static   GtkWidget *S2;
-
 static GtkWidget *b_enable_S3;
 static   GtkWidget *S3_label;
 static   GtkWidget *S3;
-
 static GtkWidget *b_enable_S4;
 static   GtkWidget *S4_label;
 static   GtkWidget *S4;
-
 static GtkWidget *b_enable_S5;
 static   GtkWidget *S5_label;
 static   GtkWidget *S5;
-
 static GtkWidget *b_enable_S6;
 static   GtkWidget *S6_label;
 static   GtkWidget *S6;
-
 static GtkWidget *b_enable_function;
 static   GtkWidget *function_label;
 static   GtkWidget *function;
 
+static GtkWidget *i2c_device_text;
+static GtkWidget *i2c_address;
+static GtkWidget *i2c_sw_text[16];
+
+
 #ifdef LOCALCW
 static GtkWidget *cwl_label;
 static GtkWidget *cwl;
@@ -125,19 +150,37 @@ static gboolean save_cb (GtkWidget *widget, GdkEventButton *event, gpointer data
     E2_ENCODER_A=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(E2_a));
     E2_ENCODER_B=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(E2_b));
     ENABLE_E2_PULLUP=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(b_enable_E2_pullup))?1:0;
+    E2_FUNCTION=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(E2_sw));
 
     ENABLE_E3_ENCODER=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(b_enable_E3_encoder))?1:0;
     E3_ENCODER_A=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(E3_a));
     E3_ENCODER_B=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(E3_b));
     ENABLE_E3_PULLUP=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(b_enable_E3_pullup))?1:0;
+    E3_FUNCTION=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(E3_sw));
 
     ENABLE_E4_ENCODER=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(b_enable_E4_encoder))?1:0;
     E4_ENCODER_A=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(E4_a));
     E4_ENCODER_B=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(E4_b));
     ENABLE_E4_PULLUP=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(b_enable_E4_pullup))?1:0;
-
-
-/*
+    E4_FUNCTION=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(E4_sw));
+
+    if(controller==CONTROLLER2_V1 || controller==CONTROLLER2_V2 || controller==CUSTOM_CONTROLLER) {
+      ENABLE_E5_ENCODER=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(b_enable_E5_encoder))?1:0;
+      E5_ENCODER_A=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(E5_a));
+      E5_ENCODER_B=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(E5_b));
+      ENABLE_E5_PULLUP=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(b_enable_E5_pullup))?1:0;
+      E5_FUNCTION=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(E5_sw));
+
+      const char *temp=gtk_entry_get_text(GTK_ENTRY(i2c_device_text));
+      i2c_device=g_new(char,strlen(temp)+1);
+      strcpy(i2c_device,temp);
+      i2c_address_1=(unsigned int)strtol(gtk_entry_get_text(GTK_ENTRY(i2c_address)),NULL,16);
+      for(int i=0;i<16;i++) {
+        i2c_sw[i]=(unsigned int)strtol(gtk_entry_get_text(GTK_ENTRY(i2c_sw_text[i])),NULL,16);
+      }
+    }
+
+  if(controller==CONTROLLER1) {
     ENABLE_MOX_BUTTON=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(b_enable_mox))?1:0;
     MOX_BUTTON=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(mox));
 
@@ -161,7 +204,8 @@ static gboolean save_cb (GtkWidget *widget, GdkEventButton *event, gpointer data
 
     ENABLE_FUNCTION_BUTTON=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(b_enable_function))?1:0;
     FUNCTION_BUTTON=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(function));
-*/
+  }
+
 #ifdef LOCALCW
     ENABLE_CW_BUTTONS=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(b_enable_cwlr))?1:0;
     CW_ACTIVE_LOW=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(b_cw_active_low))?1:0;
@@ -185,6 +229,8 @@ static gboolean cancel_cb (GtkWidget *widget, GdkEventButton *event, gpointer da
 }
 
 void configure_gpio(GtkWidget *parent) {
+  int row;
+
   gpio_restore_state();
 
   dialog=gtk_dialog_new_with_buttons("Configure GPIO (WiringPi pin numbers)",GTK_WINDOW(parent),GTK_DIALOG_DESTROY_WITH_PARENT,NULL,NULL);
@@ -193,363 +239,470 @@ void configure_gpio(GtkWidget *parent) {
   //gtk_grid_set_column_homogeneous(GTK_GRID(grid),TRUE);
   gtk_grid_set_row_homogeneous(GTK_GRID(grid),TRUE);
 
-  int y=0;
-
-  b_enable_vfo_encoder=gtk_check_button_new_with_label("Enable VFO");
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b_enable_vfo_encoder), ENABLE_VFO_ENCODER);
-  gtk_widget_show(b_enable_vfo_encoder);
-  gtk_grid_attach(GTK_GRID(grid),b_enable_vfo_encoder,0,y,1,1);
-
-  vfo_a_label=gtk_label_new("GPIO A:");
-  gtk_widget_show(vfo_a_label);
-  gtk_grid_attach(GTK_GRID(grid),vfo_a_label,1,y,1,1);
-
-  vfo_a=gtk_spin_button_new_with_range (0.0,100.0,1.0);
-  gtk_spin_button_set_value (GTK_SPIN_BUTTON(vfo_a),VFO_ENCODER_A);
-  gtk_widget_show(vfo_a);
-  gtk_grid_attach(GTK_GRID(grid),vfo_a,2,y,1,1);
-
-  vfo_b_label=gtk_label_new("GPIO B:");
-  gtk_widget_show(vfo_b_label);
-  gtk_grid_attach(GTK_GRID(grid),vfo_b_label,3,y,1,1);
-
-  vfo_b=gtk_spin_button_new_with_range (0.0,100.0,1.0);
-  gtk_spin_button_set_value (GTK_SPIN_BUTTON(vfo_b),VFO_ENCODER_B);
-  gtk_widget_show(vfo_b);
-  gtk_grid_attach(GTK_GRID(grid),vfo_b,4,y,1,1);
-
-  b_enable_vfo_pullup=gtk_check_button_new_with_label("Enable Pull-up");
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b_enable_vfo_pullup), ENABLE_VFO_PULLUP);
-  gtk_widget_show(b_enable_vfo_pullup);
-  gtk_grid_attach(GTK_GRID(grid),b_enable_vfo_pullup,5,y,1,1);
-
-
-  y++;
-
-  b_enable_E2_encoder=gtk_check_button_new_with_label("Enable E2");
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b_enable_E2_encoder), ENABLE_E2_ENCODER);
-  gtk_widget_show(b_enable_E2_encoder);
-  gtk_grid_attach(GTK_GRID(grid),b_enable_E2_encoder,0,y,1,1);
-
-  E2_a_label=gtk_label_new("GPIO A:");
-  gtk_widget_show(E2_a_label);
-  gtk_grid_attach(GTK_GRID(grid),E2_a_label,1,y,1,1);
-
-  E2_a=gtk_spin_button_new_with_range (0.0,100.0,1.0);
-  gtk_spin_button_set_value (GTK_SPIN_BUTTON(E2_a),E2_ENCODER_A);
-  gtk_widget_show(E2_a);
-  gtk_grid_attach(GTK_GRID(grid),E2_a,2,y,1,1);
-
-  E2_b_label=gtk_label_new("GPIO B:");
-  gtk_widget_show(E2_b_label);
-  gtk_grid_attach(GTK_GRID(grid),E2_b_label,3,y,1,1);
-
-  E2_b=gtk_spin_button_new_with_range (0.0,100.0,1.0);
-  gtk_spin_button_set_value (GTK_SPIN_BUTTON(E2_b),E2_ENCODER_B);
-  gtk_widget_show(E2_b);
-  gtk_grid_attach(GTK_GRID(grid),E2_b,4,y,1,1);
-
-  b_enable_E2_pullup=gtk_check_button_new_with_label("Enable Pull-up");
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b_enable_E2_pullup), ENABLE_E2_PULLUP);
-  gtk_widget_show(b_enable_E2_pullup);
-  gtk_grid_attach(GTK_GRID(grid),b_enable_E2_pullup,5,y,1,1);
-
-
-  y++;
-
-  b_enable_E3_encoder=gtk_check_button_new_with_label("Enable E3");
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b_enable_E3_encoder), ENABLE_E3_ENCODER);
-  gtk_widget_show(b_enable_E3_encoder);
-  gtk_grid_attach(GTK_GRID(grid),b_enable_E3_encoder,0,y,1,1);
-
-  E3_a_label=gtk_label_new("GPIO A:");
-  gtk_widget_show(E3_a_label);
-  gtk_grid_attach(GTK_GRID(grid),E3_a_label,1,y,1,1);
-
-  E3_a=gtk_spin_button_new_with_range (0.0,100.0,1.0);
-  gtk_spin_button_set_value (GTK_SPIN_BUTTON(E3_a),E3_ENCODER_A);
-  gtk_widget_show(E3_a);
-  gtk_grid_attach(GTK_GRID(grid),E3_a,2,y,1,1);
-
-  E3_b_label=gtk_label_new("GPIO B:");
-  gtk_widget_show(E3_b_label);
-  gtk_grid_attach(GTK_GRID(grid),E3_b_label,3,y,1,1);
-
-  E3_b=gtk_spin_button_new_with_range (0.0,100.0,1.0);
-  gtk_spin_button_set_value (GTK_SPIN_BUTTON(E3_b),E3_ENCODER_B);
-  gtk_widget_show(E3_b);
-  gtk_grid_attach(GTK_GRID(grid),E3_b,4,y,1,1);
-
-  b_enable_E3_pullup=gtk_check_button_new_with_label("Enable Pull-up");
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b_enable_E3_pullup), ENABLE_E3_PULLUP);
-  gtk_widget_show(b_enable_E3_pullup);
-  gtk_grid_attach(GTK_GRID(grid),b_enable_E3_pullup,5,y,1,1);
-
-  y++;
-
-  b_enable_E4_encoder=gtk_check_button_new_with_label("Enable E4");
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b_enable_E4_encoder), ENABLE_E4_ENCODER);
-  gtk_widget_show(b_enable_E4_encoder);
-  gtk_grid_attach(GTK_GRID(grid),b_enable_E4_encoder,0,y,1,1);
-
-  E4_a_label=gtk_label_new("GPIO A:");
-  gtk_widget_show(E4_a_label);
-  gtk_grid_attach(GTK_GRID(grid),E4_a_label,1,y,1,1);
-
-  E4_a=gtk_spin_button_new_with_range (0.0,100.0,1.0);
-  gtk_spin_button_set_value (GTK_SPIN_BUTTON(E4_a),E4_ENCODER_A);
-  gtk_widget_show(E4_a);
-  gtk_grid_attach(GTK_GRID(grid),E4_a,2,y,1,1);
-
-  E4_b_label=gtk_label_new("GPIO B:");
-  gtk_widget_show(E4_b_label);
-  gtk_grid_attach(GTK_GRID(grid),E4_b_label,3,y,1,1);
-
-  E4_b=gtk_spin_button_new_with_range (0.0,100.0,1.0);
-  gtk_spin_button_set_value (GTK_SPIN_BUTTON(E4_b),E4_ENCODER_B);
-  gtk_widget_show(E4_b);
-  gtk_grid_attach(GTK_GRID(grid),E4_b,4,y,1,1);
+  GtkWidget *notebook=gtk_notebook_new();
 
-  b_enable_E4_pullup=gtk_check_button_new_with_label("Enable Pull-up");
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b_enable_E4_pullup), ENABLE_E4_PULLUP);
-  gtk_widget_show(b_enable_E4_pullup);
-  gtk_grid_attach(GTK_GRID(grid),b_enable_E4_pullup,5,y,1,1);
+  GtkWidget *grid0=gtk_grid_new();
+  gtk_grid_set_column_spacing (GTK_GRID(grid0),10);
 
-  y++;
-
-#if defined (CONTROLLER2_V2) || defined (CONTROLLER2_V1)
-  b_enable_E5_encoder=gtk_check_button_new_with_label("Enable E5");
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b_enable_E5_encoder), ENABLE_E5_ENCODER);
-  gtk_widget_show(b_enable_E5_encoder);
-  gtk_grid_attach(GTK_GRID(grid),b_enable_E5_encoder,0,y,1,1);
-
-  E5_a_label=gtk_label_new("GPIO A:");
-  gtk_widget_show(E5_a_label);
-  gtk_grid_attach(GTK_GRID(grid),E5_a_label,1,y,1,1);
-
-  E5_a=gtk_spin_button_new_with_range (0.0,100.0,1.0);
-  gtk_spin_button_set_value (GTK_SPIN_BUTTON(E5_a),E5_ENCODER_A);
-  gtk_widget_show(E5_a);
-  gtk_grid_attach(GTK_GRID(grid),E5_a,2,y,1,1);
-
-  E5_b_label=gtk_label_new("GPIO B:");
-  gtk_widget_show(E5_b_label);
-  gtk_grid_attach(GTK_GRID(grid),E5_b_label,3,y,1,1);
-
-  E5_b=gtk_spin_button_new_with_range (0.0,100.0,1.0);
-  gtk_spin_button_set_value (GTK_SPIN_BUTTON(E5_b),E5_ENCODER_B);
-  gtk_widget_show(E5_b);
-  gtk_grid_attach(GTK_GRID(grid),E5_b,4,y,1,1);
-
-  b_enable_E5_pullup=gtk_check_button_new_with_label("Enable Pull-up");
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b_enable_E5_pullup), ENABLE_E5_PULLUP);
-  gtk_widget_show(b_enable_E5_pullup);
-  gtk_grid_attach(GTK_GRID(grid),b_enable_E5_pullup,5,y,1,1);
-
-  y++;
-
-#endif
-
-#if !defined (CONTROLLER2_V2) && !defined(CONTROLLER2_V1)
-  b_enable_mox=gtk_check_button_new_with_label("Enable MOX/TUN");
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b_enable_mox), ENABLE_MOX_BUTTON);
-  gtk_widget_show(b_enable_mox);
-  gtk_grid_attach(GTK_GRID(grid),b_enable_mox,0,y,1,1);
-
-  mox_label=gtk_label_new("GPIO:");
-  gtk_widget_show(mox_label);
-  gtk_grid_attach(GTK_GRID(grid),mox_label,1,y,1,1);
-
-  mox=gtk_spin_button_new_with_range (0.0,100.0,1.0);
-  gtk_spin_button_set_value (GTK_SPIN_BUTTON(mox),MOX_BUTTON);
-  gtk_widget_show(mox);
-  gtk_grid_attach(GTK_GRID(grid),mox,2,y,1,1);
-
-  y++;
+  GtkWidget *save_b=gtk_button_new_with_label("Save");
+  g_signal_connect (save_b, "button_press_event", G_CALLBACK(save_cb), NULL);
+  gtk_grid_attach(GTK_GRID(grid0),save_b,0,0,1,1);
 
-  b_enable_S1=gtk_check_button_new_with_label("Enable S1");
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b_enable_S1), ENABLE_S1_BUTTON);
-  gtk_widget_show(b_enable_S1);
-  gtk_grid_attach(GTK_GRID(grid),b_enable_S1,0,y,1,1);
+  GtkWidget *cancel_b=gtk_button_new_with_label("Cancel");
+  g_signal_connect (cancel_b, "button_press_event", G_CALLBACK(cancel_cb), NULL);
+  gtk_grid_attach(GTK_GRID(grid0),cancel_b,1,0,1,1);
+
+
+  if(controller!=NO_CONTROLLER) {
+
+    // Encoders
+  
+    GtkWidget *grid1=gtk_grid_new();
+    gtk_grid_set_column_spacing (GTK_GRID(grid1),10);
+    row=0;
+  
+    b_enable_vfo_encoder=gtk_check_button_new_with_label("Enable VFO");
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b_enable_vfo_encoder), ENABLE_VFO_ENCODER);
+    gtk_widget_show(b_enable_vfo_encoder);
+    gtk_grid_attach(GTK_GRID(grid1),b_enable_vfo_encoder,0,row,1,1);
+  
+    vfo_a_label=gtk_label_new("GPIO A:");
+    gtk_widget_show(vfo_a_label);
+    gtk_grid_attach(GTK_GRID(grid1),vfo_a_label,1,row,1,1);
+  
+    vfo_a=gtk_spin_button_new_with_range (0.0,100.0,1.0);
+    gtk_spin_button_set_value (GTK_SPIN_BUTTON(vfo_a),VFO_ENCODER_A);
+    gtk_widget_show(vfo_a);
+    gtk_grid_attach(GTK_GRID(grid1),vfo_a,2,row,1,1);
+  
+    vfo_b_label=gtk_label_new("GPIO B:");
+    gtk_widget_show(vfo_b_label);
+    gtk_grid_attach(GTK_GRID(grid1),vfo_b_label,3,row,1,1);
+  
+    vfo_b=gtk_spin_button_new_with_range (0.0,100.0,1.0);
+    gtk_spin_button_set_value (GTK_SPIN_BUTTON(vfo_b),VFO_ENCODER_B);
+    gtk_widget_show(vfo_b);
+    gtk_grid_attach(GTK_GRID(grid1),vfo_b,4,row,1,1);
+
+    b_enable_vfo_pullup=gtk_check_button_new_with_label("Enable Pull-up");
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b_enable_vfo_pullup), ENABLE_VFO_PULLUP);
+    gtk_widget_show(b_enable_vfo_pullup);
+    gtk_grid_attach(GTK_GRID(grid1),b_enable_vfo_pullup,7,row,1,1);
+  
+  
+    row++;
+  
+    b_enable_E2_encoder=gtk_check_button_new_with_label("Enable E2");
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b_enable_E2_encoder), ENABLE_E2_ENCODER);
+    gtk_widget_show(b_enable_E2_encoder);
+    gtk_grid_attach(GTK_GRID(grid1),b_enable_E2_encoder,0,row,1,1);
+  
+    E2_a_label=gtk_label_new("GPIO A:");
+    gtk_widget_show(E2_a_label);
+    gtk_grid_attach(GTK_GRID(grid1),E2_a_label,1,row,1,1);
+  
+    E2_a=gtk_spin_button_new_with_range (0.0,100.0,1.0);
+    gtk_spin_button_set_value (GTK_SPIN_BUTTON(E2_a),E2_ENCODER_A);
+    gtk_widget_show(E2_a);
+    gtk_grid_attach(GTK_GRID(grid1),E2_a,2,row,1,1);
+  
+    E2_b_label=gtk_label_new("GPIO B:");
+    gtk_widget_show(E2_b_label);
+    gtk_grid_attach(GTK_GRID(grid1),E2_b_label,3,row,1,1);
+  
+    E2_b=gtk_spin_button_new_with_range (0.0,100.0,1.0);
+    gtk_spin_button_set_value (GTK_SPIN_BUTTON(E2_b),E2_ENCODER_B);
+    gtk_widget_show(E2_b);
+    gtk_grid_attach(GTK_GRID(grid1),E2_b,4,row,1,1);
+  
+    E2_sw_label=gtk_label_new("SW:");
+    gtk_widget_show(E2_sw_label);
+    gtk_grid_attach(GTK_GRID(grid1),E2_sw_label,5,row,1,1);
+  
+    E2_sw=gtk_spin_button_new_with_range (0.0,100.0,1.0);
+    gtk_spin_button_set_value (GTK_SPIN_BUTTON(E2_sw),E2_FUNCTION);
+    gtk_widget_show(E2_sw);
+    gtk_grid_attach(GTK_GRID(grid1),E2_sw,6,row,1,1);
+  
+    b_enable_E2_pullup=gtk_check_button_new_with_label("Enable Pull-up");
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b_enable_E2_pullup), ENABLE_E2_PULLUP);
+    gtk_widget_show(b_enable_E2_pullup);
+    gtk_grid_attach(GTK_GRID(grid1),b_enable_E2_pullup,7,row,1,1);
+  
+  
+    row++;
+  
+    b_enable_E3_encoder=gtk_check_button_new_with_label("Enable E3");
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b_enable_E3_encoder), ENABLE_E3_ENCODER);
+    gtk_widget_show(b_enable_E3_encoder);
+    gtk_grid_attach(GTK_GRID(grid1),b_enable_E3_encoder,0,row,1,1);
+  
+    E3_a_label=gtk_label_new("GPIO A:");
+    gtk_widget_show(E3_a_label);
+    gtk_grid_attach(GTK_GRID(grid1),E3_a_label,1,row,1,1);
+  
+    E3_a=gtk_spin_button_new_with_range (0.0,100.0,1.0);
+    gtk_spin_button_set_value (GTK_SPIN_BUTTON(E3_a),E3_ENCODER_A);
+    gtk_widget_show(E3_a);
+    gtk_grid_attach(GTK_GRID(grid1),E3_a,2,row,1,1);
+  
+    E3_b_label=gtk_label_new("GPIO B:");
+    gtk_widget_show(E3_b_label);
+    gtk_grid_attach(GTK_GRID(grid1),E3_b_label,3,row,1,1);
+  
+    E3_b=gtk_spin_button_new_with_range (0.0,100.0,1.0);
+    gtk_spin_button_set_value (GTK_SPIN_BUTTON(E3_b),E3_ENCODER_B);
+    gtk_widget_show(E3_b);
+    gtk_grid_attach(GTK_GRID(grid1),E3_b,4,row,1,1);
+  
+    E3_sw_label=gtk_label_new("SW:");
+    gtk_widget_show(E3_sw_label);
+    gtk_grid_attach(GTK_GRID(grid1),E3_sw_label,5,row,1,1);
+  
+    E3_sw=gtk_spin_button_new_with_range (0.0,100.0,1.0);
+    gtk_spin_button_set_value (GTK_SPIN_BUTTON(E3_sw),E3_FUNCTION);
+    gtk_widget_show(E3_sw);
+    gtk_grid_attach(GTK_GRID(grid1),E3_sw,6,row,1,1);
+  
+    b_enable_E3_pullup=gtk_check_button_new_with_label("Enable Pull-up");
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b_enable_E3_pullup), ENABLE_E3_PULLUP);
+    gtk_widget_show(b_enable_E3_pullup);
+    gtk_grid_attach(GTK_GRID(grid1),b_enable_E3_pullup,7,row,1,1);
+  
+    row++;
+  
+    b_enable_E4_encoder=gtk_check_button_new_with_label("Enable E4");
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b_enable_E4_encoder), ENABLE_E4_ENCODER);
+    gtk_widget_show(b_enable_E4_encoder);
+    gtk_grid_attach(GTK_GRID(grid1),b_enable_E4_encoder,0,row,1,1);
+  
+    E4_a_label=gtk_label_new("GPIO A:");
+    gtk_widget_show(E4_a_label);
+    gtk_grid_attach(GTK_GRID(grid1),E4_a_label,1,row,1,1);
+  
+    E4_a=gtk_spin_button_new_with_range (0.0,100.0,1.0);
+    gtk_spin_button_set_value (GTK_SPIN_BUTTON(E4_a),E4_ENCODER_A);
+    gtk_widget_show(E4_a);
+    gtk_grid_attach(GTK_GRID(grid1),E4_a,2,row,1,1);
+  
+    E4_b_label=gtk_label_new("GPIO B:");
+    gtk_widget_show(E4_b_label);
+    gtk_grid_attach(GTK_GRID(grid1),E4_b_label,3,row,1,1);
+  
+    E4_b=gtk_spin_button_new_with_range (0.0,100.0,1.0);
+    gtk_spin_button_set_value (GTK_SPIN_BUTTON(E4_b),E4_ENCODER_B);
+    gtk_widget_show(E4_b);
+    gtk_grid_attach(GTK_GRID(grid1),E4_b,4,row,1,1);
+  
+    E4_sw_label=gtk_label_new("SW:");
+    gtk_widget_show(E4_sw_label);
+    gtk_grid_attach(GTK_GRID(grid1),E4_sw_label,5,row,1,1);
+  
+    E4_sw=gtk_spin_button_new_with_range (0.0,100.0,1.0);
+    gtk_spin_button_set_value (GTK_SPIN_BUTTON(E4_sw),E4_FUNCTION);
+    gtk_widget_show(E4_sw);
+    gtk_grid_attach(GTK_GRID(grid1),E4_sw,6,row,1,1);
+  
+    b_enable_E4_pullup=gtk_check_button_new_with_label("Enable Pull-up");
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b_enable_E4_pullup), ENABLE_E4_PULLUP);
+    gtk_widget_show(b_enable_E4_pullup);
+    gtk_grid_attach(GTK_GRID(grid1),b_enable_E4_pullup,7,row,1,1);
+  
+    row++;
+  
+    if(controller==CONTROLLER2_V1 || controller==CONTROLLER2_V2 || controller==CUSTOM_CONTROLLER) {
+      b_enable_E5_encoder=gtk_check_button_new_with_label("Enable E5");
+      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b_enable_E5_encoder), ENABLE_E5_ENCODER);
+      gtk_widget_show(b_enable_E5_encoder);
+      gtk_grid_attach(GTK_GRID(grid1),b_enable_E5_encoder,0,row,1,1);
+  
+      E5_a_label=gtk_label_new("GPIO A:");
+      gtk_widget_show(E5_a_label);
+      gtk_grid_attach(GTK_GRID(grid1),E5_a_label,1,row,1,1);
+  
+      E5_a=gtk_spin_button_new_with_range (0.0,100.0,1.0);
+      gtk_spin_button_set_value (GTK_SPIN_BUTTON(E5_a),E5_ENCODER_A);
+      gtk_widget_show(E5_a);
+      gtk_grid_attach(GTK_GRID(grid1),E5_a,2,row,1,1);
+  
+      E5_b_label=gtk_label_new("GPIO B:");
+      gtk_widget_show(E5_b_label);
+      gtk_grid_attach(GTK_GRID(grid1),E5_b_label,3,row,1,1);
+  
+      E5_b=gtk_spin_button_new_with_range (0.0,100.0,1.0);
+      gtk_spin_button_set_value (GTK_SPIN_BUTTON(E5_b),E5_ENCODER_B);
+      gtk_widget_show(E5_b);
+      gtk_grid_attach(GTK_GRID(grid1),E5_b,4,row,1,1);
+
+      E5_sw_label=gtk_label_new("SW:");
+      gtk_widget_show(E5_sw_label);
+      gtk_grid_attach(GTK_GRID(grid1),E5_sw_label,5,row,1,1);
+    
+      E5_sw=gtk_spin_button_new_with_range (0.0,100.0,1.0);
+      gtk_spin_button_set_value (GTK_SPIN_BUTTON(E5_sw),E5_FUNCTION);
+      gtk_widget_show(E5_sw);
+      gtk_grid_attach(GTK_GRID(grid1),E5_sw,6,row,1,1);
+  
+      b_enable_E5_pullup=gtk_check_button_new_with_label("Enable Pull-up");
+      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b_enable_E5_pullup), ENABLE_E5_PULLUP);
+      gtk_widget_show(b_enable_E5_pullup);
+      gtk_grid_attach(GTK_GRID(grid1),b_enable_E5_pullup,7,row,1,1);
+    }
+  
+    gtk_notebook_append_page(GTK_NOTEBOOK(notebook),grid1,gtk_label_new("Encoders"));
+  
+    // Switches
+  
+    GtkWidget *grid2=gtk_grid_new();
+    gtk_grid_set_column_spacing (GTK_GRID(grid2),10);
+    row=0;
+
+
+    if(controller==CONTROLLER1) {
+      b_enable_mox=gtk_check_button_new_with_label("Enable MOX/TUN");
+      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b_enable_mox), ENABLE_MOX_BUTTON);
+      gtk_widget_show(b_enable_mox);
+      gtk_grid_attach(GTK_GRID(grid2),b_enable_mox,0,row,1,1);
+  
+      mox_label=gtk_label_new("GPIO:");
+      gtk_widget_show(mox_label);
+      gtk_grid_attach(GTK_GRID(grid2),mox_label,1,row,1,1);
+  
+      mox=gtk_spin_button_new_with_range (0.0,100.0,1.0);
+      gtk_spin_button_set_value (GTK_SPIN_BUTTON(mox),MOX_BUTTON);
+      gtk_widget_show(mox);
+      gtk_grid_attach(GTK_GRID(grid2),mox,2,row,1,1);
+
+      row++;
+  
+      b_enable_S1=gtk_check_button_new_with_label("Enable S1");
+      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b_enable_S1), ENABLE_S1_BUTTON);
+      gtk_widget_show(b_enable_S1);
+      gtk_grid_attach(GTK_GRID(grid2),b_enable_S1,0,row,1,1);
+  
+      S1_label=gtk_label_new("GPIO:");
+      gtk_widget_show(S1_label);
+      gtk_grid_attach(GTK_GRID(grid2),S1_label,1,row,1,1);
+  
+      S1=gtk_spin_button_new_with_range (0.0,100.0,1.0);
+      gtk_spin_button_set_value (GTK_SPIN_BUTTON(S1),S1_BUTTON);
+      gtk_widget_show(S1);
+      gtk_grid_attach(GTK_GRID(grid2),S1,2,row,1,1);
+
+      row++;
+
+      b_enable_S2=gtk_check_button_new_with_label("Enable S2");
+      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b_enable_S2), ENABLE_S2_BUTTON);
+      gtk_widget_show(b_enable_S2);
+      gtk_grid_attach(GTK_GRID(grid),b_enable_S2,0,row,1,1);
+    
+      S2_label=gtk_label_new("GPIO:");
+      gtk_widget_show(S2_label);
+      gtk_grid_attach(GTK_GRID(grid),S2_label,1,row,1,1);
+  
+      S2=gtk_spin_button_new_with_range (0.0,100.0,1.0);
+      gtk_spin_button_set_value (GTK_SPIN_BUTTON(S2),S2_BUTTON);
+      gtk_widget_show(S2);
+      gtk_grid_attach(GTK_GRID(grid),S2,2,row,1,1);
+  
+      row++;
+  
+      b_enable_S3=gtk_check_button_new_with_label("Enable S3");
+      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b_enable_S3), ENABLE_S3_BUTTON);
+      gtk_widget_show(b_enable_S3);
+      gtk_grid_attach(GTK_GRID(grid),b_enable_S3,0,row,1,1);
+    
+      S3_label=gtk_label_new("GPIO:");
+      gtk_widget_show(S3_label);
+      gtk_grid_attach(GTK_GRID(grid),S3_label,1,row,1,1);
+    
+      S3=gtk_spin_button_new_with_range (0.0,100.0,1.0);
+      gtk_spin_button_set_value (GTK_SPIN_BUTTON(S3),S3_BUTTON);
+      gtk_widget_show(S3);
+      gtk_grid_attach(GTK_GRID(grid),S3,2,row,1,1);
+
+      row++;
+
+      b_enable_S4=gtk_check_button_new_with_label("Enable S4");
+      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b_enable_S4), ENABLE_S4_BUTTON);
+      gtk_widget_show(b_enable_S4);
+      gtk_grid_attach(GTK_GRID(grid2),b_enable_S4,0,row,1,1);
+    
+      S4_label=gtk_label_new("GPIO:");
+      gtk_widget_show(S4_label);
+      gtk_grid_attach(GTK_GRID(grid2),S4_label,1,row,1,1);
+    
+      S4=gtk_spin_button_new_with_range (0.0,100.0,1.0);
+      gtk_spin_button_set_value (GTK_SPIN_BUTTON(S4),S4_BUTTON);
+      gtk_widget_show(S4);
+      gtk_grid_attach(GTK_GRID(grid2),S4,2,row,1,1);
+    
+      row++;
+    
+      b_enable_S5=gtk_check_button_new_with_label("Enable S5");
+      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b_enable_S5), ENABLE_S5_BUTTON);
+      gtk_widget_show(b_enable_S5);
+      gtk_grid_attach(GTK_GRID(grid2),b_enable_S5,0,row,1,1);
+  
+      S5_label=gtk_label_new("GPIO:");
+      gtk_widget_show(S5_label);
+      gtk_grid_attach(GTK_GRID(grid2),S5_label,1,row,1,1);
+    
+      S5=gtk_spin_button_new_with_range (0.0,100.0,1.0);
+      gtk_spin_button_set_value (GTK_SPIN_BUTTON(S5),S5_BUTTON);
+      gtk_widget_show(S5);
+      gtk_grid_attach(GTK_GRID(grid2),S5,2,row,1,1);
+    
+      row++;
+    
+      b_enable_S6=gtk_check_button_new_with_label("Enable S6");
+      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b_enable_S6), ENABLE_S6_BUTTON);
+      gtk_widget_show(b_enable_S6);
+      gtk_grid_attach(GTK_GRID(grid2),b_enable_S6,0,row,1,1);
+    
+      S6_label=gtk_label_new("GPIO:");
+      gtk_widget_show(S6_label);
+      gtk_grid_attach(GTK_GRID(grid2),S6_label,1,row,1,1);
+    
+      S6=gtk_spin_button_new_with_range (0.0,100.0,1.0);
+      gtk_spin_button_set_value (GTK_SPIN_BUTTON(S6),S6_BUTTON);
+      gtk_widget_show(S6);
+      gtk_grid_attach(GTK_GRID(grid2),S6,2,row,1,1);
+    
+      row++;
+    
+      b_enable_function=gtk_check_button_new_with_label("Enable Function");
+      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b_enable_function), ENABLE_FUNCTION_BUTTON);
+      gtk_widget_show(b_enable_function);
+      gtk_grid_attach(GTK_GRID(grid2),b_enable_function,0,row,1,1);
+    
+      function_label=gtk_label_new("GPIO:");
+      gtk_widget_show(function_label);
+      gtk_grid_attach(GTK_GRID(grid2),function_label,1,row,1,1);
+    
+      function=gtk_spin_button_new_with_range (0.0,100.0,1.0);
+      gtk_spin_button_set_value (GTK_SPIN_BUTTON(function),FUNCTION_BUTTON);
+      gtk_widget_show(function);
+      gtk_grid_attach(GTK_GRID(grid2),function,2,row,1,1);
+
+      gtk_notebook_append_page(GTK_NOTEBOOK(notebook),grid2,gtk_label_new("Switches"));
+    } else {
+      char text[16];
+      GtkWidget *grid2=gtk_grid_new();
+      gtk_grid_set_column_spacing (GTK_GRID(grid2),10);
+      row=0;
+  
+      GtkWidget *label=gtk_label_new("I2C Device:");
+      gtk_widget_show(label);
+      gtk_grid_attach(GTK_GRID(grid2),label,0,row,1,1);
+  
+      i2c_device_text=gtk_entry_new();
+      gtk_widget_show(i2c_device_text);
+      gtk_entry_set_text (GTK_ENTRY(i2c_device_text),i2c_device);
+      gtk_grid_attach(GTK_GRID(grid2),i2c_device_text,1,row,1,1);
+     
+      label=gtk_label_new("I2C Address:");
+      gtk_widget_show(label);
+      gtk_grid_attach(GTK_GRID(grid2),label,2,row,1,1);
+  
+      i2c_address=gtk_entry_new();
+      sprintf(text,"0x%02X",i2c_address_1);
+      gtk_entry_set_text (GTK_ENTRY(i2c_address),text);
+      gtk_widget_show(i2c_address);
+      gtk_grid_attach(GTK_GRID(grid2),i2c_address,3,row,1,1);
+
+      row++;
+
+      for(int i=0;i<8;i++) {
+        sprintf(text,"SW_%d",i+2);
+        label=gtk_label_new(text);
+        gtk_widget_show(label);
+        gtk_grid_attach(GTK_GRID(grid2),label,0,row,1,1);
+
+        i2c_sw_text[i]=gtk_entry_new();
+        sprintf(text,"0x%04X",i2c_sw[i]);
+        gtk_entry_set_text (GTK_ENTRY(i2c_sw_text[i]),text);
+        gtk_widget_show(i2c_sw_text[i]);
+        gtk_grid_attach(GTK_GRID(grid2),i2c_sw_text[i],1,row,1,1);
+
+        sprintf(text,"SW_%d",i+10);
+        label=gtk_label_new(text);
+        gtk_widget_show(label);
+        gtk_grid_attach(GTK_GRID(grid2),label,2,row,1,1);
+
+        i2c_sw_text[i+8]=gtk_entry_new();
+        sprintf(text,"0x%04X",i2c_sw[i+8]);
+        gtk_entry_set_text (GTK_ENTRY(i2c_sw_text[i+8]),text);
+        gtk_widget_show(i2c_sw_text[i+8]);
+        gtk_grid_attach(GTK_GRID(grid2),i2c_sw_text[i+8],3,row,1,1);
+
+        row++;
+
+      }
+
+      gtk_notebook_append_page(GTK_NOTEBOOK(notebook),grid2,gtk_label_new("I2C"));
+    }
 
-  S1_label=gtk_label_new("GPIO:");
-  gtk_widget_show(S1_label);
-  gtk_grid_attach(GTK_GRID(grid),S1_label,1,y,1,1);
+  }
 
-  S1=gtk_spin_button_new_with_range (0.0,100.0,1.0);
-  gtk_spin_button_set_value (GTK_SPIN_BUTTON(S1),S1_BUTTON);
-  gtk_widget_show(S1);
-  gtk_grid_attach(GTK_GRID(grid),S1,2,y,1,1);
+#ifdef LOCALCW
+  // CW
 
-#endif
+  GtkWidget *grid3=gtk_grid_new();
+  gtk_grid_set_column_spacing (GTK_GRID(grid3),10);
+  row=0;
 
-#ifdef LOCALCW
-  // With LOCALCW, the menu got too long (does not fit on the screen)
-  // Therefore it has been moved to the right of S1/S2/S3
-  // The GPIO side tone is also configured here. Note that
-  // these setting are only active when doing local CW
   cwl_label=gtk_label_new("CWL GPIO:");
   gtk_widget_show(cwl_label);
-  gtk_grid_attach(GTK_GRID(grid),cwl_label,3,y,1,1);
+  gtk_grid_attach(GTK_GRID(grid3),cwl_label,0,row,1,1);
 
   cwl=gtk_spin_button_new_with_range (0.0,100.0,1.0);
   gtk_spin_button_set_value (GTK_SPIN_BUTTON(cwl),CWL_BUTTON);
   gtk_widget_show(cwl);
-  gtk_grid_attach(GTK_GRID(grid),cwl,4,y,1,1);
+  gtk_grid_attach(GTK_GRID(grid3),cwl,1,row,1,1);
 
   b_enable_cwlr=gtk_check_button_new_with_label("CWLR Enable");
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b_enable_cwlr), ENABLE_CW_BUTTONS);
   gtk_widget_show(b_enable_cwlr);
-  gtk_grid_attach(GTK_GRID(grid),b_enable_cwlr,5,y,1,1);
-
-#endif
-
-  y++;
+  gtk_grid_attach(GTK_GRID(grid3),b_enable_cwlr,2,row,1,1);
 
+  row++;
 
-#if !defined (CONTROLLER2_V2) && !defined (CONTROLLER2_V1)
-  b_enable_S2=gtk_check_button_new_with_label("Enable S2");
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b_enable_S2), ENABLE_S2_BUTTON);
-  gtk_widget_show(b_enable_S2);
-  gtk_grid_attach(GTK_GRID(grid),b_enable_S2,0,y,1,1);
-
-  S2_label=gtk_label_new("GPIO:");
-  gtk_widget_show(S2_label);
-  gtk_grid_attach(GTK_GRID(grid),S2_label,1,y,1,1);
-
-  S2=gtk_spin_button_new_with_range (0.0,100.0,1.0);
-  gtk_spin_button_set_value (GTK_SPIN_BUTTON(S2),S2_BUTTON);
-  gtk_widget_show(S2);
-  gtk_grid_attach(GTK_GRID(grid),S2,2,y,1,1);
-
-#endif
-
-#ifdef LOCALCW
   cwr_label=gtk_label_new("CWR GPIO:");
   gtk_widget_show(cwr_label);
-  gtk_grid_attach(GTK_GRID(grid),cwr_label,3,y,1,1);
+  gtk_grid_attach(GTK_GRID(grid3),cwr_label,0,row,1,1);
 
   cwr=gtk_spin_button_new_with_range (0.0,100.0,1.0);
   gtk_spin_button_set_value (GTK_SPIN_BUTTON(cwr),CWR_BUTTON);
   gtk_widget_show(cwr);
-  gtk_grid_attach(GTK_GRID(grid),cwr,4,y,1,1);
+  gtk_grid_attach(GTK_GRID(grid3),cwr,1,row,1,1);
 
   b_cw_active_low=gtk_check_button_new_with_label("CWLR active-low");
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b_cw_active_low), CW_ACTIVE_LOW);
   gtk_widget_show(b_cw_active_low);
-  gtk_grid_attach(GTK_GRID(grid),b_cw_active_low,5,y,1,1);
-#endif
-
-  y++;
-
-#if !defined (CONTROLLER2_V2) && !defined (CONTROLLER2_V1)
-  b_enable_S3=gtk_check_button_new_with_label("Enable S3");
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b_enable_S3), ENABLE_S3_BUTTON);
-  gtk_widget_show(b_enable_S3);
-  gtk_grid_attach(GTK_GRID(grid),b_enable_S3,0,y,1,1);
-
-  S3_label=gtk_label_new("GPIO:");
-  gtk_widget_show(S3_label);
-  gtk_grid_attach(GTK_GRID(grid),S3_label,1,y,1,1);
+  gtk_grid_attach(GTK_GRID(grid3),b_cw_active_low,2,row,1,1);
 
-  S3=gtk_spin_button_new_with_range (0.0,100.0,1.0);
-  gtk_spin_button_set_value (GTK_SPIN_BUTTON(S3),S3_BUTTON);
-  gtk_widget_show(S3);
-  gtk_grid_attach(GTK_GRID(grid),S3,2,y,1,1);
-#endif
+  row++;
 
-#ifdef LOCALCW
   cws_label=gtk_label_new("  SideTone GPIO:");
   gtk_widget_show(cws_label);
-  gtk_grid_attach(GTK_GRID(grid),cws_label,3,y,1,1);
+  gtk_grid_attach(GTK_GRID(grid3),cws_label,0,row,1,1);
 
   cws=gtk_spin_button_new_with_range (0.0,100.0,1.0);
   gtk_spin_button_set_value (GTK_SPIN_BUTTON(cws),SIDETONE_GPIO);
   gtk_widget_show(cws);
-  gtk_grid_attach(GTK_GRID(grid),cws,4,y,1,1);
+  gtk_grid_attach(GTK_GRID(grid3),cws,1,row,1,1);
 
   b_enable_cws=gtk_check_button_new_with_label("Enable");
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b_enable_cws), ENABLE_GPIO_SIDETONE);
   gtk_widget_show(b_enable_cws);
-  gtk_grid_attach(GTK_GRID(grid),b_enable_cws,5,y,1,1);
-#endif
+  gtk_grid_attach(GTK_GRID(grid3),b_enable_cws,2,row,1,1);
 
-#if !defined (CONTROLLER2_V2) && !defined (CONTROLLER2_V1)
-  y++;
-  b_enable_S4=gtk_check_button_new_with_label("Enable S4");
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b_enable_S4), ENABLE_S4_BUTTON);
-  gtk_widget_show(b_enable_S4);
-  gtk_grid_attach(GTK_GRID(grid),b_enable_S4,0,y,1,1);
-
-  S4_label=gtk_label_new("GPIO:");
-  gtk_widget_show(S4_label);
-  gtk_grid_attach(GTK_GRID(grid),S4_label,1,y,1,1);
-
-  S4=gtk_spin_button_new_with_range (0.0,100.0,1.0);
-  gtk_spin_button_set_value (GTK_SPIN_BUTTON(S4),S4_BUTTON);
-  gtk_widget_show(S4);
-  gtk_grid_attach(GTK_GRID(grid),S4,2,y,1,1);
-
-  y++;
-
-  b_enable_S5=gtk_check_button_new_with_label("Enable S5");
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b_enable_S5), ENABLE_S5_BUTTON);
-  gtk_widget_show(b_enable_S5);
-  gtk_grid_attach(GTK_GRID(grid),b_enable_S5,0,y,1,1);
-
-  S5_label=gtk_label_new("GPIO:");
-  gtk_widget_show(S5_label);
-  gtk_grid_attach(GTK_GRID(grid),S5_label,1,y,1,1);
-
-  S5=gtk_spin_button_new_with_range (0.0,100.0,1.0);
-  gtk_spin_button_set_value (GTK_SPIN_BUTTON(S5),S5_BUTTON);
-  gtk_widget_show(S5);
-  gtk_grid_attach(GTK_GRID(grid),S5,2,y,1,1);
-
-  y++;
-
-  b_enable_S6=gtk_check_button_new_with_label("Enable S6");
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b_enable_S6), ENABLE_S6_BUTTON);
-  gtk_widget_show(b_enable_S6);
-  gtk_grid_attach(GTK_GRID(grid),b_enable_S6,0,y,1,1);
-
-  S6_label=gtk_label_new("GPIO:");
-  gtk_widget_show(S6_label);
-  gtk_grid_attach(GTK_GRID(grid),S6_label,1,y,1,1);
-
-  S6=gtk_spin_button_new_with_range (0.0,100.0,1.0);
-  gtk_spin_button_set_value (GTK_SPIN_BUTTON(S6),S6_BUTTON);
-  gtk_widget_show(S6);
-  gtk_grid_attach(GTK_GRID(grid),S6,2,y,1,1);
-
-  y++;
-
-  b_enable_function=gtk_check_button_new_with_label("Enable Function");
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (b_enable_function), ENABLE_FUNCTION_BUTTON);
-  gtk_widget_show(b_enable_function);
-  gtk_grid_attach(GTK_GRID(grid),b_enable_function,0,y,1,1);
-
-  function_label=gtk_label_new("GPIO:");
-  gtk_widget_show(function_label);
-  gtk_grid_attach(GTK_GRID(grid),function_label,1,y,1,1);
-
-  function=gtk_spin_button_new_with_range (0.0,100.0,1.0);
-  gtk_spin_button_set_value (GTK_SPIN_BUTTON(function),FUNCTION_BUTTON);
-  gtk_widget_show(function);
-  gtk_grid_attach(GTK_GRID(grid),function,2,y,1,1);
+  gtk_notebook_append_page(GTK_NOTEBOOK(notebook),grid3,gtk_label_new("CW"));
 #endif
 
-  y++;
-
-  GtkWidget *save_b=gtk_button_new_with_label("Save");
-  g_signal_connect (save_b, "button_press_event", G_CALLBACK(save_cb), NULL);
-  gtk_grid_attach(GTK_GRID(grid),save_b,4,y,1,1);
-
-  GtkWidget *cancel_b=gtk_button_new_with_label("Cancel");
-  g_signal_connect (cancel_b, "button_press_event", G_CALLBACK(cancel_cb), NULL);
-  gtk_grid_attach(GTK_GRID(grid),cancel_b,5,y,1,1);
-
-  gtk_container_add(GTK_CONTAINER(content),grid);
+  gtk_grid_attach(GTK_GRID(grid0),notebook,0,1,6,1);
+  gtk_container_add(GTK_CONTAINER(content),grid0);
 
   gtk_widget_show_all(dialog);
   gtk_dialog_run(GTK_DIALOG(dialog));
index 30a8a763fc1ddb726bba737cb64d78c8215bb4a7..ff175a87c79e439b61add01fa99c7933188e4436 100644 (file)
@@ -51,8 +51,8 @@
 #include "ext.h"
 #ifdef GPIO
 #include "gpio.h"
-#endif
 #include "configure.h"
+#endif
 
 static GtkWidget *discovery_dialog;
 static DISCOVERED *d;
@@ -205,12 +205,10 @@ 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));
@@ -514,12 +512,6 @@ 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();
@@ -551,6 +543,13 @@ fprintf(stderr,"%p Protocol=%d name=%s\n",d,d->protocol,d->name);
 #endif
 
     i++;
+
+#ifdef GPIO
+    GtkWidget *gpio_b=gtk_button_new_with_label("Configure 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);
+#endif
+
     GtkWidget *tcp_b=gtk_button_new_with_label("Use new TCP Addr:");
     g_signal_connect (tcp_b, "button-press-event", G_CALLBACK(tcp_cb), NULL);
     gtk_grid_attach(GTK_GRID(grid),tcp_b,1,i,1,1);
diff --git a/gpio.c b/gpio.c
index afca5df07b7e0b1cac9735cad4fcfa069ea782e5..38a7e8474fa36b7e13da24d66ffc5c593ab192cd 100644 (file)
--- a/gpio.c
+++ b/gpio.c
@@ -105,11 +105,6 @@ 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;
@@ -126,10 +121,6 @@ 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;
@@ -839,10 +830,6 @@ g_print("gpio_set_defaults: %d\n",ctrlr);
       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;
@@ -886,10 +873,6 @@ g_print("gpio_set_defaults: %d\n",ctrlr);
       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;
@@ -933,10 +916,6 @@ g_print("gpio_set_defaults: %d\n",ctrlr);
       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;
@@ -1015,10 +994,6 @@ g_print("gpio_set_defaults: %d\n",ctrlr);
       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;
@@ -1204,20 +1179,12 @@ void gpio_restore_state() {
   value=getProperty("MOX_BUTTON");
   if(value) MOX_BUTTON=atoi(value);
 
-  value=getProperty("ENABLE_E2_BUTTON");
-  if(value) ENABLE_E2_BUTTON=atoi(value);
   value=getProperty("E2_FUNCTION");
   if(value) E2_FUNCTION=atoi(value);
-  value=getProperty("ENABLE_E3_BUTTON");
-  if(value) ENABLE_E3_BUTTON=atoi(value);
   value=getProperty("E3_FUNCTION");
   if(value) E3_FUNCTION=atoi(value);
-  value=getProperty("ENABLE_E4_BUTTON");
-  if(value) ENABLE_E4_BUTTON=atoi(value);
   value=getProperty("E4_FUNCTION");
   if(value) E4_FUNCTION=atoi(value);
-  value=getProperty("ENABLE_E5_BUTTON");
-  if(value) ENABLE_E5_BUTTON=atoi(value);
   value=getProperty("E5_FUNCTION");
   if(value) E5_FUNCTION=atoi(value);
 
@@ -1236,6 +1203,21 @@ void gpio_restore_state() {
  if(value) ENABLE_GPIO_SIDETONE=atoi(value);           
 #endif
 
+  if(controller!=CONTROLLER1) {
+    value=getProperty("i2c_device");
+    if(value) {
+      i2c_device=g_new(char,strlen(value)+1);
+      strcpy(i2c_device,value);
+    }
+    for(int i=0;i<16;i++) {
+      sprintf(name,"i2c_sw[%d]",i);
+      value=getProperty(name);
+      if(value) i2c_sw[i]=atoi(value);
+    }
+  }
+
+
 }
 
 void gpio_save_actions() {
@@ -1291,11 +1273,12 @@ g_print("gpio_save_actions: controller=%d\n",controller);
       setProperty(name,value);         
     }
   }
-g_print("e2_encoder_action: %d\n",e2_encoder_action);
+  
 }
 
 void gpio_save_state() {
   char value[80];
+  char name[80];
 
   clearProperties();
   sprintf(value,"%d",controller);
@@ -1373,22 +1356,27 @@ void gpio_save_state() {
   sprintf(value,"%d",MOX_BUTTON);
   setProperty("MOX_BUTTON",value);
 
-  sprintf(value,"%d",ENABLE_E2_BUTTON);
-  setProperty("ENABLE_E2_BUTTON",value);
   sprintf(value,"%d",E2_FUNCTION);
   setProperty("E2_FUNCTION",value);
-  sprintf(value,"%d",ENABLE_E3_BUTTON);
-  setProperty("ENABLE_E3_BUTTON",value);
   sprintf(value,"%d",E3_FUNCTION);
   setProperty("E3_FUNCTION",value);
-  sprintf(value,"%d",ENABLE_E4_BUTTON);
-  setProperty("ENABLE_E4_BUTTON",value);
   sprintf(value,"%d",E4_FUNCTION);
   setProperty("E4_FUNCTION",value);
-  sprintf(value,"%d",ENABLE_E5_BUTTON);
-  setProperty("ENABLE_E5_BUTTON",value);
   sprintf(value,"%d",E5_FUNCTION);
   setProperty("E5_FUNCTION",value);
+
+  if(controller!=CONTROLLER1) {
+    setProperty("i2c_device",i2c_device);              
+    sprintf(value,"%d",i2c_address_1);
+    setProperty("i2c_address_1",value);                
+    for(int i=0;i<16;i++) {
+      sprintf(name,"i2c_sw[%d]",i);
+      sprintf(value,"%d",i2c_sw[i]);
+      setProperty(name,value);         
+    }
+
+  }
+
 #ifdef LOCALCW         
   sprintf(value,"%d",ENABLE_CW_BUTTONS);               
   setProperty("ENABLE_CW_BUTTONS",value);              
diff --git a/gpio.h b/gpio.h
index a0fec5182be3a21c26434be2d00b5c4145061277..b976e2b88b983d5859e6a382f121dc2816718aaa 100644 (file)
--- a/gpio.h
+++ b/gpio.h
@@ -208,11 +208,6 @@ 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;
diff --git a/i2c.c b/i2c.c
index 1dc7b1eaaa32796ae4ad474994a388824d90f4e2..dc2e691f22fbd51d0fcdf54029c4083dabf50077 100644 (file)
--- a/i2c.c
+++ b/i2c.c
@@ -19,9 +19,9 @@
 #include "vfo.h"
 #include "ext.h"
 
-#define I2C_DEVICE "/dev/i2c-1"
-#define ADDRESS_1 0X20
-#define ADDRESS_2 0X23
+char *i2c_device="/dev/i2c-1";
+unsigned int i2c_address_1=0X20;
+unsigned int i2c_address_2=0X23;
 
 #define SW_2  0X8000
 #define SW_3  0X4000
 #define SW_16 0X0200
 #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 };
+
 static int write_byte_data(unsigned char addr,unsigned char reg, unsigned char data) {
   int fd;
   int rc;
 
-  if((fd=open(I2C_DEVICE, O_RDWR))<0) {
-    fprintf(stderr,"cannot open %s: %s\n",I2C_DEVICE,strerror(errno));
+  if((fd=open(i2c_device, O_RDWR))<0) {
+    fprintf(stderr,"cannot open %s: %s\n",i2c_device,strerror(errno));
     return(-1);
   }
 
@@ -69,8 +73,8 @@ static unsigned char read_byte_data(unsigned char addr,unsigned char reg) {
   int fd;
   int rc;
 
-  if((fd=open(I2C_DEVICE, O_RDWR))<0) {
-    fprintf(stderr,"cannot open %s: %s\n",I2C_DEVICE,strerror(errno));
+  if((fd=open(i2c_device, O_RDWR))<0) {
+    fprintf(stderr,"cannot open %s: %s\n",i2c_device,strerror(errno));
     exit(1);
   }
 
@@ -94,8 +98,8 @@ static unsigned int read_word_data(unsigned char addr,unsigned char reg) {
   int fd;
   int rc;
 
-  if((fd=open(I2C_DEVICE, O_RDWR))<0) {
-    fprintf(stderr,"c$cannot open %s: %s\n",I2C_DEVICE,strerror(errno));
+  if((fd=open(i2c_device, O_RDWR))<0) {
+    fprintf(stderr,"c$cannot open %s: %s\n",i2c_device,strerror(errno));
     exit(1);
   }
 
@@ -121,16 +125,20 @@ static void frequencyStep(int pos) {
 }
 
 void i2c_interrupt() {
-  int flags;
-  int ints;
+  unsigned int flags;
+  unsigned int ints;
 
   do {
-    flags=read_word_data(ADDRESS_1,0x0E);
+    flags=read_word_data(i2c_address_1,0x0E);
     if(flags) {
-      ints=read_word_data(ADDRESS_1,0x10);
+      ints=read_word_data(i2c_address_1,0x10);
 //g_print("i2c_interrupt: flags=%04X ints=%04X\n",flags,ints);
       if(ints) {
-        int i=-1;
+        int i;
+        for(i=0;i<16;i++) {
+          if(i2c_sw[i]==ints) break;
+        }
+/*
         switch(ints) {
           case SW_2:
             i=CONTROLLER2_SW2;
@@ -181,123 +189,126 @@ void i2c_interrupt() {
             i=CONTROLLER2_SW17;
             break;
         }
+*/
+        if(i<16) {
 //g_print("i1c_interrupt: sw=%d action=%d\n",i,sw_action[i]);
-        switch(sw_action[i]) {
-          case TUNE:
-            if(can_transmit) {
-              int tune=getTune();
-              if(tune==0) tune=1; else tune=0;
-              g_idle_add(ext_tune_update,GINT_TO_POINTER(tune));
-            }
-            break;
-          case MOX:
-            if(can_transmit) {
-              int mox=getMox();
-              if(mox==0) mox=1; else mox=0;
-              g_idle_add(ext_mox_update,GINT_TO_POINTER(mox));
-            }
-            break;
-          case PS:
+          switch(sw_action[i]) {
+            case TUNE:
+              if(can_transmit) {
+                int tune=getTune();
+                if(tune==0) tune=1; else tune=0;
+                  g_idle_add(ext_tune_update,GINT_TO_POINTER(tune));
+              }
+              break;
+            case MOX:
+              if(can_transmit) {
+                int mox=getMox();
+                if(mox==0) mox=1; else mox=0;
+                g_idle_add(ext_mox_update,GINT_TO_POINTER(mox));
+              }
+              break;
+            case PS:
 #ifdef PURESIGNAL
-            if(can_transmit) g_idle_add(ext_ps_update,NULL);
+              if(can_transmit) g_idle_add(ext_ps_update,NULL);
 #endif
-            break;
-          case TWO_TONE:
-            if(can_transmit) g_idle_add(ext_two_tone,NULL);
-            break;
-          case NR:
-            g_idle_add(ext_nr_update,NULL);
-            break;
-          case NB:
-            g_idle_add(ext_nb_update,NULL);
-            break;
-          case SNB:
-            g_idle_add(ext_snb_update,NULL);
-            break;
-          case RIT:
-            g_idle_add(ext_rit_update,NULL);
-            break;
-          case RIT_CLEAR:
-            g_idle_add(ext_rit_clear,NULL);
-            break;
-          case XIT:
-            if(can_transmit) g_idle_add(ext_xit_update,NULL);
-            break;
-          case XIT_CLEAR:
-            if(can_transmit) g_idle_add(ext_xit_clear,NULL);
-            break;
-          case BAND_PLUS:
-            g_idle_add(ext_band_plus,NULL);
-            break;
-          case BAND_MINUS:
-            g_idle_add(ext_band_minus,NULL);
-            break;
-          case BANDSTACK_PLUS:
-            g_idle_add(ext_bandstack_plus,NULL);
-            break;
-          case BANDSTACK_MINUS:
-            g_idle_add(ext_bandstack_minus,NULL);
-            break;
-          case MODE_PLUS:
-            g_idle_add(ext_mode_plus,NULL);
-            break;
-          case MODE_MINUS:
-            g_idle_add(ext_mode_minus,NULL);
-            break;
-          case FILTER_PLUS:
-            g_idle_add(ext_filter_plus,NULL);
-            break;
-          case FILTER_MINUS:
-            g_idle_add(ext_filter_minus,NULL);
-            break;
-          case A_TO_B:
-            g_idle_add(ext_vfo_a_to_b,NULL);
-            break;
-          case B_TO_A:
-            g_idle_add(ext_vfo_b_to_a,NULL);
-            break;
-          case A_SWAP_B:
-            g_idle_add(ext_vfo_a_swap_b,NULL);
-            break;
-          case LOCK:
-            g_idle_add(ext_lock_update,NULL);
-            break;
-          case CTUN:
-            g_idle_add(ext_ctun_update,NULL);
-            break;
-          case AGC:
-            g_idle_add(ext_agc_update,NULL);
-            break;
-          case SPLIT:
-            if(can_transmit) g_idle_add(ext_split_toggle,NULL);
-            break;
-          case DIVERSITY:
-            g_idle_add(ext_diversity_update,GINT_TO_POINTER(0));
-            break;
-          case SAT:
-            if(can_transmit) g_idle_add(ext_sat_update,NULL);
-            break;
-          case MENU_BAND:
-            g_idle_add(ext_band_update,NULL);
-            break;
-          case MENU_BANDSTACK:
-            g_idle_add(ext_bandstack_update,NULL);
-            break;
-          case MENU_MODE:
-            g_idle_add(ext_mode_update,NULL);
-            break;
-          case MENU_FILTER:
-            g_idle_add(ext_filter_update,NULL);
-            break;
-          case MENU_FREQUENCY:
-            g_idle_add(ext_frequency_update,NULL);
-            break;
-          case MENU_MEMORY:
-            g_idle_add(ext_memory_update,NULL);
-            break;
-          case MENU_DIVERSITY:
-            g_idle_add(ext_diversity_update,GINT_TO_POINTER(1));
-            break;
+              break;
+            case TWO_TONE:
+              if(can_transmit) g_idle_add(ext_two_tone,NULL);
+              break;
+            case NR:
+              g_idle_add(ext_nr_update,NULL);
+              break;
+            case NB:
+              g_idle_add(ext_nb_update,NULL);
+              break;
+            case SNB:
+              g_idle_add(ext_snb_update,NULL);
+              break;
+            case RIT:
+              g_idle_add(ext_rit_update,NULL);
+              break;
+            case RIT_CLEAR:
+              g_idle_add(ext_rit_clear,NULL);
+              break;
+            case XIT:
+              if(can_transmit) g_idle_add(ext_xit_update,NULL);
+              break;
+            case XIT_CLEAR:
+              if(can_transmit) g_idle_add(ext_xit_clear,NULL);
+              break;
+            case BAND_PLUS:
+              g_idle_add(ext_band_plus,NULL);
+              break;
+            case BAND_MINUS:
+              g_idle_add(ext_band_minus,NULL);
+              break;
+            case BANDSTACK_PLUS:
+              g_idle_add(ext_bandstack_plus,NULL);
+              break;
+            case BANDSTACK_MINUS:
+              g_idle_add(ext_bandstack_minus,NULL);
+              break;
+            case MODE_PLUS:
+              g_idle_add(ext_mode_plus,NULL);
+              break;
+            case MODE_MINUS:
+              g_idle_add(ext_mode_minus,NULL);
+              break;
+            case FILTER_PLUS:
+              g_idle_add(ext_filter_plus,NULL);
+              break;
+            case FILTER_MINUS:
+              g_idle_add(ext_filter_minus,NULL);
+              break;
+            case A_TO_B:
+              g_idle_add(ext_vfo_a_to_b,NULL);
+              break;
+            case B_TO_A:
+              g_idle_add(ext_vfo_b_to_a,NULL);
+              break;
+            case A_SWAP_B:
+              g_idle_add(ext_vfo_a_swap_b,NULL);
+              break;
+            case LOCK:
+              g_idle_add(ext_lock_update,NULL);
+              break;
+            case CTUN:
+              g_idle_add(ext_ctun_update,NULL);
+              break;
+            case AGC:
+              g_idle_add(ext_agc_update,NULL);
+              break;
+            case SPLIT:
+              if(can_transmit) g_idle_add(ext_split_toggle,NULL);
+              break;
+            case DIVERSITY:
+              g_idle_add(ext_diversity_update,GINT_TO_POINTER(0));
+              break;
+            case SAT:
+              if(can_transmit) g_idle_add(ext_sat_update,NULL);
+              break;
+            case MENU_BAND:
+              g_idle_add(ext_band_update,NULL);
+              break;
+            case MENU_BANDSTACK:
+              g_idle_add(ext_bandstack_update,NULL);
+              break;
+            case MENU_MODE:
+              g_idle_add(ext_mode_update,NULL);
+              break;
+            case MENU_FILTER:
+              g_idle_add(ext_filter_update,NULL);
+              break;
+            case MENU_FREQUENCY:
+              g_idle_add(ext_frequency_update,NULL);
+              break;
+            case MENU_MEMORY:
+              g_idle_add(ext_memory_update,NULL);
+              break;
+            case MENU_DIVERSITY:
+              g_idle_add(ext_diversity_update,GINT_TO_POINTER(1));
+              break;
+          }
         }
       }
     }
@@ -310,46 +321,46 @@ void i2c_init() {
 
 fprintf(stderr,"i2c_init\n");
   // setup i2c
-  if(write_byte_data(ADDRESS_1,0x0A,0x44)<0) return;
-  if(write_byte_data(ADDRESS_1,0x0B,0x44)<0) return;
+  if(write_byte_data(i2c_address_1,0x0A,0x44)<0) return;
+  if(write_byte_data(i2c_address_1,0x0B,0x44)<0) return;
 
   // disable interrupt
-  if(write_byte_data(ADDRESS_1,0x04,0x00)<0) return;
-  if(write_byte_data(ADDRESS_1,0x05,0x00)<0) return;
+  if(write_byte_data(i2c_address_1,0x04,0x00)<0) return;
+  if(write_byte_data(i2c_address_1,0x05,0x00)<0) return;
 
   // clear defaults
-  if(write_byte_data(ADDRESS_1,0x06,0x00)<0) return;
-  if(write_byte_data(ADDRESS_1,0x07,0x00)<0) return;
+  if(write_byte_data(i2c_address_1,0x06,0x00)<0) return;
+  if(write_byte_data(i2c_address_1,0x07,0x00)<0) return;
 
   // OLAT
-  if(write_byte_data(ADDRESS_1,0x14,0x00)<0) return;
-  if(write_byte_data(ADDRESS_1,0x15,0x00)<0) return;
+  if(write_byte_data(i2c_address_1,0x14,0x00)<0) return;
+  if(write_byte_data(i2c_address_1,0x15,0x00)<0) return;
 
   // set GPIOA for pullups
-  if(write_byte_data(ADDRESS_1,0x0C,0xFF)<0) return;
-  if(write_byte_data(ADDRESS_1,0x0D,0xFF)<0) return;
+  if(write_byte_data(i2c_address_1,0x0C,0xFF)<0) return;
+  if(write_byte_data(i2c_address_1,0x0D,0xFF)<0) return;
 
   // reverse polarity
-  if(write_byte_data(ADDRESS_1,0x02,0xFF)<0) return;
-  if(write_byte_data(ADDRESS_1,0x03,0xFF)<0) return;
+  if(write_byte_data(i2c_address_1,0x02,0xFF)<0) return;
+  if(write_byte_data(i2c_address_1,0x03,0xFF)<0) return;
 
   // set GPIOA/B for input
-  if(write_byte_data(ADDRESS_1,0x00,0xFF)<0) return;
-  if(write_byte_data(ADDRESS_1,0x01,0xFF)<0) return;
+  if(write_byte_data(i2c_address_1,0x00,0xFF)<0) return;
+  if(write_byte_data(i2c_address_1,0x01,0xFF)<0) return;
 
   // INTCON
-  if(write_byte_data(ADDRESS_1,0x08,0x00)<0) return;
-  if(write_byte_data(ADDRESS_1,0x09,0x00)<0) return;
+  if(write_byte_data(i2c_address_1,0x08,0x00)<0) return;
+  if(write_byte_data(i2c_address_1,0x09,0x00)<0) return;
 
   // setup for an MCP23017 interrupt
-  if(write_byte_data(ADDRESS_1,0x04,0xFF)<0) return;
-  if(write_byte_data(ADDRESS_1,0x05,0xFF)<0) return;
+  if(write_byte_data(i2c_address_1,0x04,0xFF)<0) return;
+  if(write_byte_data(i2c_address_1,0x05,0xFF)<0) return;
 
   // flush any interrupts
   do {
-    flags=read_word_data(ADDRESS_1,0x0E);
+    flags=read_word_data(i2c_address_1,0x0E);
     if(flags) {
-      ints=read_word_data(ADDRESS_1,0x10);
+      ints=read_word_data(i2c_address_1,0x10);
       fprintf(stderr,"flush interrupt: flags=%04X ints=%04X\n",flags,ints);
     }
   } while(flags!=0);
diff --git a/i2c.h b/i2c.h
index 3271c26c9da80e770be17bf01c848ec0728e46d7..d0eccd4e74393df69b890bae7b92aee33661912c 100644 (file)
--- a/i2c.h
+++ b/i2c.h
@@ -1,2 +1,7 @@
+extern unsigned int i2c_sw[16];
+extern unsigned int i2c_address_1;
+extern unsigned int i2c_address_2;
+extern char *i2c_device;
+
 extern void i2c_init();
 extern void i2c_interrupt();
diff --git a/main.c b/main.c
index 6fa9c1357206a25de97bbf328754fe8f0d54bcf4..546a875d01896df478b497b84bfa065a505aa4b4 100644 (file)
--- a/main.c
+++ b/main.c
@@ -152,7 +152,7 @@ gboolean main_delete (GtkWidget *widget) {
 static int init(void *data) {
   char wisdom_directory[1024];
 
-  //fprintf(stderr,"init\n");
+  fprintf(stderr,"init\n");
 
   audio_get_cards();
 
@@ -237,9 +237,8 @@ fprintf(stderr,"width=%d height=%d\n", display_width, display_height);
 
 fprintf(stderr,"display_width=%d display_height=%d\n", display_width, display_height);
 
-  //fprintf(stderr,"create top level window\n");
+  fprintf(stderr,"create top level window\n");
   top_window = gtk_application_window_new (app);
-fprintf(stderr,"top_window=%p\n",top_window);
   if(full_screen) {
     fprintf(stderr,"full screen\n");
     gtk_window_fullscreen(GTK_WINDOW(top_window));
@@ -248,7 +247,7 @@ fprintf(stderr,"top_window=%p\n",top_window);
   gtk_window_set_title (GTK_WINDOW (top_window), "piHPSDR");
   gtk_window_set_position(GTK_WINDOW(top_window),GTK_WIN_POS_CENTER_ALWAYS);
   gtk_window_set_resizable(GTK_WINDOW(top_window), FALSE);
-  //fprintf(stderr,"setting top window icon\n");
+  fprintf(stderr,"setting top window icon\n");
   GError *error;
   if(!gtk_window_set_icon_from_file (GTK_WINDOW(top_window), "hpsdr.png", &error)) {
     fprintf(stderr,"Warning: failed to set icon for top_window\n");
@@ -266,61 +265,47 @@ fprintf(stderr,"top_window=%p\n",top_window);
   g_signal_connect(top_window, "key_press_event", G_CALLBACK(keypress_cb), NULL);
 
 
-//fprintf(stderr,"create fixed container\n");
-  //fixed=gtk_fixed_new();
-  //gtk_container_add(GTK_CONTAINER(top_window), fixed);
-
-//fprintf(stderr,"create grid\n");
+fprintf(stderr,"create grid\n");
   grid = gtk_grid_new();
   gtk_widget_set_size_request(grid, display_width, display_height);
   gtk_grid_set_row_homogeneous(GTK_GRID(grid),FALSE);
   gtk_grid_set_column_homogeneous(GTK_GRID(grid),FALSE);
-//fprintf(stderr,"add grid\n");
+fprintf(stderr,"add grid\n");
   gtk_container_add (GTK_CONTAINER (top_window), grid);
 
-//fprintf(stderr,"create image\n");
+fprintf(stderr,"create image\n");
   GtkWidget  *image=gtk_image_new_from_file("hpsdr.png");
-//fprintf(stderr,"add image to grid\n");
+fprintf(stderr,"add image to grid\n");
   gtk_grid_attach(GTK_GRID(grid), image, 0, 0, 1, 4);
 
-//fprintf(stderr,"create pi label\n");
-  char build[64];
+fprintf(stderr,"create pi label\n");
+  char build[128];
   sprintf(build,"build: %s %s",build_date, version);
   GtkWidget *pi_label=gtk_label_new("piHPSDR by John Melton g0orx/n6lyt");
   gtk_label_set_justify(GTK_LABEL(pi_label),GTK_JUSTIFY_LEFT);
   gtk_widget_show(pi_label);
-//fprintf(stderr,"add pi label to grid\n");
+fprintf(stderr,"add pi label to grid\n");
   gtk_grid_attach(GTK_GRID(grid),pi_label,1,0,1,1);
 
-//fprintf(stderr,"create build label\n");
+fprintf(stderr,"create build label\n");
   GtkWidget *build_date_label=gtk_label_new(build);
   gtk_label_set_justify(GTK_LABEL(build_date_label),GTK_JUSTIFY_LEFT);
   gtk_widget_show(build_date_label);
-//fprintf(stderr,"add build label to grid\n");
+fprintf(stderr,"add build label to grid\n");
   gtk_grid_attach(GTK_GRID(grid),build_date_label,1,1,1,1);
 
-//fprintf(stderr,"create status\n");
+fprintf(stderr,"create status\n");
   status=gtk_label_new("");
   gtk_label_set_justify(GTK_LABEL(status),GTK_JUSTIFY_LEFT);
   //gtk_widget_override_font(status, pango_font_description_from_string("FreeMono 18"));
   gtk_widget_show(status);
-//fprintf(stderr,"add status to grid\n");
+fprintf(stderr,"add status to grid\n");
   gtk_grid_attach(GTK_GRID(grid), status, 1, 3, 1, 1);
 
-/*
-fprintf(stderr,"create exit button\n");
-  GtkWidget *button = gtk_button_new_with_label ("Exit");
-  //g_signal_connect (button, "clicked", G_CALLBACK (print_hello), NULL);
-  g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_widget_destroy), top_window);
-fprintf(stderr,"add exit button to grid\n");
-  gtk_grid_attach(GTK_GRID(grid), button, 1, 4, 1, 1);
-*/
-
   gtk_widget_show_all(top_window);
 
+fprintf(stderr,"g_idle_add: init\n");
   g_idle_add(init,NULL);
-  //g_idle_add(discovery,NULL);
-
 
 }
 
index 868ec193c9a5f94f750a170a2862a7252aaac188..4470b114c1251533f4540beb1907b4ddf2a2e3c4 100644 (file)
--- a/pa_menu.c
+++ b/pa_menu.c
@@ -108,7 +108,7 @@ static void show_W(int watts,gboolean reset) {
   }
 
   for(i=1;i<11;i++) {
-    sprintf(text,"<b>%dW</b>",pa_trim[i]);
+    sprintf(text,"<b>%dW</b>",i*increment);
     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);
index c22bfb8644d2dd65ab9ebb10d0f24af9d4ac9281..bfcc049d06ca0974379b3e2748abcc5257760a24 100755 (executable)
Binary files a/release/pihpsdr/pihpsdr and b/release/pihpsdr/pihpsdr differ
index dab40955df69f2e2b29c0cc348ff3bc8d3ce5f84..37c7524709f68a58b0015832a8f539ee921482bd 100644 (file)
--- a/version.c
+++ b/version.c
@@ -36,5 +36,9 @@ char version[]="2.0.0-RC1"
 #ifdef MIDI
 " MIDI"
 #endif
+#ifdef LOCALCW
+" LOCALCW"
+#endif
+
 
 ;