]> git.rkrishnan.org Git - pihpsdr.git/commitdiff
merge in i2c controller code
authorYour Name <john.d.melton@googlemail.com>
Tue, 8 Dec 2020 12:01:05 +0000 (12:01 +0000)
committerYour Name <john.d.melton@googlemail.com>
Tue, 8 Dec 2020 12:01:05 +0000 (12:01 +0000)
13 files changed:
Makefile
discovery.c
gpio.c
gpio.h
i2c_controller.c
i2c_controller.h
i2c_controller_menu.c
main.h
new_menu.c
oc_menu.c
radio.c
radio_menu.c
toolbar.c

index bef62670799e60b51431e77968e9ff39e04a679a..76f947e624012dd328bfa80367d33f7f07160604 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -10,12 +10,16 @@ endif
 # uncomment the following line to force 480x320 screen
 #SMALL_SCREEN_OPTIONS=-D SMALL_SCREEN
 
-# uncomment the line below to include GPIO (For original piHPSDR Controller and Controller2 with i2c)
+# uncomment the line below to include GPIO
+# For support of:
+#    CONTROLLER1 (Original Controller)
+#    CONTROLLER2_V1 single encoders with MCP23017 switches
+#    CONTROLLER2_V2 dual encoders with MCP23017 switches
+#    CONTORLLER_I2C i2c controller using 7 I2C Encoder V2.1 boards from http://www.duppa.net/i2c-encoder-v2-1/
+#                   7 encoders and 16 switches one LED
+#
 GPIO_INCLUDE=GPIO
 
-# uncomment the following line to include support for the new i2c controller
-#I2C_CONTROLLER_INCLUDE=I2C_CONTROLLER
-
 # uncomment the line below to include USB Ozy support
 # USBOZY_INCLUDE=USBOZY
 
@@ -120,41 +124,35 @@ ifeq ($(PTT_INCLUDE),PTT)
 PTT_OPTIONS=-D PTT
 endif
 
-ifeq ($(I2C_CONTROLLER_INCLUDE),I2C_CONTROLLER)
-  I2C_CONTROLLER_OPTIONS=-D I2C_CONTROLLER
-  I2C_CONTROLLER_LIBS=-lgpiod -li2c
-  I2C_CONTROLLER_SOURCES= \
-  i2c_controller.c \
-  i2c_controller_menu.c
-  I2C_CONTROLLER_HEADERS= \
-  i2c_controller.h \
-  i2c_controller_menu.h
-  I2C_CONTROLLER_OBJS= \
-  i2c_controller.o \
-  i2c_controller_menu.o
-endif
-
 ifeq ($(GPIO_INCLUDE),GPIO)
-  GPIO_OPTIONS=-D GPIO
-  GPIO_LIBS=-lgpiod -li2c
-  GPIO_SOURCES= \
+GPIO_OPTIONS=-D GPIO
+GPIO_LIBS=-lgpiod -li2c
+GPIO_SOURCES= \
   configure.c \
   i2c.c \
   gpio.c \
   encoder_menu.c \
-  switch_menu.c
-  GPIO_HEADERS= \
+  switch_menu.c \
+  i2c_controller.c \
+  i2c_controller_menu.c
+
+GPIO_HEADERS= \
   configure.h \
   i2c.h \
   gpio.h \
   encoder_menu.h \
-  switch_menu.h
-  GPIO_OBJS= \
+  switch_menu.h \
+  i2c_controller.h \
+  i2c_controller_menu.h
+
+GPIO_OBJS= \
   configure.o \
   i2c.o \
   gpio.o \
   encoder_menu.o \
-  switch_menu.o
+  switch_menu.o \
+  i2c_controller.o \
+  i2c_controller_menu.o
 endif
 
 #
@@ -198,14 +196,14 @@ AUDIO_LIBS=-lasound
 #AUDIO_LIBS=-lsoundio
 
 CFLAGS=        -g -Wno-deprecated-declarations -O3
-OPTIONS=$(SMALL_SCREEN_OPTIONS) $(I2C_ENCODERS_OPTIONS) $(MIDI_OPTIONS) $(PURESIGNAL_OPTIONS) $(REMOTE_OPTIONS) $(USBOZY_OPTIONS) \
-       $(I2C_CONTROLLER_OPTIONS) $(GPIO_OPTIONS) $(SOAPYSDR_OPTIONS) $(LOCALCW_OPTIONS) \
+OPTIONS=$(SMALL_SCREEN_OPTIONS) $(MIDI_OPTIONS) $(PURESIGNAL_OPTIONS) $(REMOTE_OPTIONS) $(USBOZY_OPTIONS) \
+       $(GPIO_OPTIONS) $(SOAPYSDR_OPTIONS) $(LOCALCW_OPTIONS) \
        $(STEMLAB_OPTIONS) \
         $(PTT_OPTIONS) \
        $(SERVER_OPTIONS) \
        -D GIT_DATE='"$(GIT_DATE)"' -D GIT_VERSION='"$(GIT_VERSION)"' $(DEBUG_OPTION) $(OSFLAG)
 
-LIBS=-lrt -lm -lwdsp -lpthread $(AUDIO_LIBS) $(USBOZY_LIBS) $(GTKLIBS) $(I2C_CONTROLLER_LIBS) $(GPIO_LIBS) $(SOAPYSDRLIBS) $(STEMLAB_LIBS) $(MIDI_LIBS)
+LIBS=-lrt -lm -lwdsp -lpthread $(AUDIO_LIBS) $(USBOZY_LIBS) $(GTKLIBS) $(GPIO_LIBS) $(SOAPYSDRLIBS) $(STEMLAB_LIBS) $(MIDI_LIBS)
 INCLUDES=$(GTKINCLUDES)
 
 COMPILE=$(CC) $(CFLAGS) $(OPTIONS) $(INCLUDES)
@@ -426,18 +424,18 @@ css.o \
 actions.o
 
 $(PROGRAM):  $(OBJS) $(REMOTE_OBJS) $(USBOZY_OBJS) $(SOAPYSDR_OBJS) \
-               $(LOCALCW_OBJS) $(I2C_CONTROLLER_OBJS) $(GPIO_OBJS) $(PURESIGNAL_OBJS) \
+               $(LOCALCW_OBJS) $(GPIO_OBJS) $(PURESIGNAL_OBJS) \
                $(MIDI_OBJS) $(STEMLAB_OBJS) $(SERVER_OBJS)
-       $(LINK) -o $(PROGRAM) $(OBJS) $(REMOTE_OBJS) $(USBOZY_OBJS) $(I2C_CONTROLLER_OBJS) $(GPIO_OBJS) \
+       $(LINK) -o $(PROGRAM) $(OBJS) $(REMOTE_OBJS) $(USBOZY_OBJS) $(GPIO_OBJS) \
                $(SOAPYSDR_OBJS) $(LOCALCW_OBJS) $(PURESIGNAL_OBJS) \
                $(MIDI_OBJS) $(STEMLAB_OBJS) $(SERVER_OBJS) $(LIBS)
 
 .PHONY:        all
 all:   prebuild  $(PROGRAM) $(HEADERS) $(USBOZY_HEADERS) $(SOAPYSDR_HEADERS) \
-       $(LOCALCW_HEADERS) $(I2C_CONTROLLER_HEADERS) $(GPIO_HEADERS) \
+       $(LOCALCW_HEADERS) $(GPIO_HEADERS) \
        $(PURESIGNAL_HEADERS) $(MIDI_HEADERS) $(STEMLAB_HEADERS) $(SERVER_HEADERS)\
        $(SOURCES) \
-       $(USBOZY_SOURCES) $(SOAPYSDR_SOURCES) $(LOCALCW_SOURCE) $(I2C_CONTROLLER_SOURCES) $(GPIO_SOURCES) \
+       $(USBOZY_SOURCES) $(SOAPYSDR_SOURCES) $(LOCALCW_SOURCE) $(GPIO_SOURCES) \
        $(PURESIGNAL_SOURCES) $(MIDI_SOURCES) $(STEMLAB_SOURCES) $(SERVER_SOURCES)
 
 .PHONY:        prebuild
@@ -456,7 +454,7 @@ CPPINCLUDES:=$(shell echo $(INCLUDES) | sed -e "s/-pthread / /" )
 .PHONY:        cppcheck
 cppcheck:
        cppcheck $(CPPOPTIONS) $(OPTIONS) $(CPPINCLUDES) $(SOURCES) $(REMOTE_SOURCES) \
-       $(USBOZY_SOURCES) $(SOAPYSDR_SOURCES) $(I2C_CONTROLLER_SOURCES) $(GPIO_SOURCES) \
+       $(USBOZY_SOURCES) $(SOAPYSDR_SOURCES) $(GPIO_SOURCES) \
        $(PURESIGNAL_SOURCES) $(MIDI_SOURCES) $(STEMLAB_SOURCES) $(LOCALCW_SOURCES) \
        $(SERVER_SOURCES)
 
index 6110e3c33c9549a453663fa4a3f261c2646428ff..832b0bde2cb7e5ae7a0fef009e97e38dd8c04921 100644 (file)
@@ -568,6 +568,7 @@ fprintf(stderr,"%p Protocol=%d name=%s\n",d,d->protocol,d->name);
     gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(gpio),NULL,"Controller1");
     gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(gpio),NULL,"Controller2 V1");
     gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(gpio),NULL,"Controller2 V2");
+    gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(gpio),NULL,"Controller I2C");
     gtk_grid_attach(GTK_GRID(grid),gpio,0,row,1,1);
 
     gtk_combo_box_set_active(GTK_COMBO_BOX(gpio),controller);
diff --git a/gpio.c b/gpio.c
index 73f21fc7e721348e0872fe5f72946b749f05db7e..af29ca0c93d061885b96b21ebe236e654751d695 100644 (file)
--- a/gpio.c
+++ b/gpio.c
@@ -85,8 +85,6 @@ static struct gpiod_chip *chip=NULL;
 static GMutex encoder_mutex;
 static GThread *monitor_thread_id;
 
-int controller=NO_CONTROLLER;
-
 int I2C_INTERRUPT=15;
 
 #define MAX_LINES 32
diff --git a/gpio.h b/gpio.h
index 855984e9cf2a68de2a22dfca94b3174813e35ee5..822acec4b44c5e2e2ac20761dcb5ab80b92c792e 100644 (file)
--- a/gpio.h
+++ b/gpio.h
 #define MAX_SWITCHES 16
 #define MAX_FUNCTIONS 6
 
-enum {
-  NO_CONTROLLER=0,
-  CONTROLLER1,
-  CONTROLLER2_V1,
-  CONTROLLER2_V2,
-};
-
-extern int controller;
-  
 typedef struct _encoder {
   gboolean bottom_encoder_enabled;
   gboolean bottom_encoder_pullup;
index a589e658f446452f510c7fa263b35e13ff6a47a5..8b56fee4f638f598adc2ba40fd723f40c3c35702 100644 (file)
@@ -29,6 +29,7 @@
 #include <i2c/smbus.h>
 #include <sys/ioctl.h>
 #include <fcntl.h>
+#include "actions.h"
 #include "i2c_controller.h"
 #include "vfo.h"
 #include "radio.h"
@@ -37,6 +38,7 @@
 #include "new_menu.h"
 
 
+/*
 char *encoder_string[ENCODER_ACTIONS] = {
   "NO ACTION",
   "AF GAIN",
@@ -130,8 +132,9 @@ char *sw_string[SWITCH_ACTIONS] = {
   "ZOOM -",
   "ZOOM +",
 };
+*/
 
-ENCODER encoder[MAX_ENCODERS]=
+I2C_ENCODER encoder[MAX_I2C_ENCODERS]=
 {
   {TRUE,0x11,0,ENCODER_AF_GAIN,TRUE,MODE_MENU,FALSE,NO_ACTION,FALSE,NO_ACTION,FALSE,NO_ACTION},
   {TRUE,0x12,0,ENCODER_AGC_GAIN,TRUE,FILTER_MENU,FALSE,NO_ACTION,FALSE,NO_ACTION,FALSE,NO_ACTION},
@@ -142,7 +145,7 @@ ENCODER encoder[MAX_ENCODERS]=
   {TRUE,0x10,0,ENCODER_VFO,TRUE,MENU_BAND,FALSE,NO_ACTION,FALSE,NO_ACTION,FALSE,NO_ACTION},
 };
 
-char *gpio_device="/dev/gpiochip0";
+char *i2c_controller_gpio_device="/dev/gpiochip0";
 int new_i2c_interrupt=4;
 
 static struct gpiod_chip *chip=NULL;
@@ -151,7 +154,7 @@ static struct gpiod_line *line=NULL;
 static GMutex encoder_mutex;
 static GThread *monitor_thread_id;
 
-char *i2c_device="/dev/i2c-1";
+char *i2c_controller_i2c_device="/dev/i2c-1";
 
 static int fd=-1;
 
@@ -159,7 +162,7 @@ static GThread *rotary_encoder_thread_id;
 
 static int vfo_encoder_changed(void *data) {
   if(!locked) {
-    gint pos=(gint)data;
+    gint pos=GPOINTER_TO_INT(data);
     vfo_step(pos);
   }
   return 0;
@@ -168,7 +171,7 @@ static int vfo_encoder_changed(void *data) {
 static gpointer rotary_encoder_thread(gpointer data) {
   while(1) {
     g_mutex_lock(&encoder_mutex);
-    for(int i=0;i<MAX_ENCODERS;i++) {
+    for(int i=0;i<MAX_I2C_ENCODERS;i++) {
       if(encoder[i].enabled) {
         if(encoder[i].pos!=0) {
           switch(encoder[i].encoder_function) {
@@ -176,7 +179,7 @@ static gpointer rotary_encoder_thread(gpointer data) {
               if(active_menu==BAND_MENU) {
                 // move to next/previous band
               } else {
-                g_idle_add(vfo_encoder_changed,(gpointer)encoder[i].pos);
+                g_idle_add(vfo_encoder_changed,GINT_TO_POINTER(encoder[i].pos));
               }
               break;
             case ENCODER_AF_GAIN:
@@ -187,7 +190,7 @@ static gpointer rotary_encoder_thread(gpointer data) {
               if(af_gain>1.0) af_gain=1.0;
               double *dp=g_new(double,1);
               *dp=af_gain;
-              g_idle_add(ext_set_af_gain,(gpointer)dp);
+              g_idle_add(ext_set_af_gain,dp);
               }
               break;
             case ENCODER_AGC_GAIN:
@@ -198,7 +201,7 @@ static gpointer rotary_encoder_thread(gpointer data) {
               if(agc_gain>120.0) agc_gain=120.0;
               double *dp=g_new(double,1);
               *dp=agc_gain;
-              g_idle_add(ext_set_agc_gain,(gpointer)dp);
+              g_idle_add(ext_set_agc_gain,dp);
               }
               break;
             case ENCODER_DRIVE:
@@ -209,7 +212,7 @@ static gpointer rotary_encoder_thread(gpointer data) {
               if(drive>drive_max) drive=drive_max;
               double *dp=g_new(double,1);
               *dp=drive;
-              g_idle_add(ext_set_drive,(gpointer)dp);
+              g_idle_add(ext_set_drive,dp);
               }
               break;
           }
@@ -222,20 +225,20 @@ static gpointer rotary_encoder_thread(gpointer data) {
   }
 }
 
-int i2c_init() {
+static int i2c_init() {
   int ret=0;
 
   g_mutex_init(&encoder_mutex);
 
-  g_print("%s: open i2c device %s\n",__FUNCTION__,i2c_device);
-  fd=open(i2c_device, O_RDWR);
+  g_print("%s: open i2c device %s\n",__FUNCTION__,i2c_controller_i2c_device);
+  fd=open(i2c_controller_i2c_device, O_RDWR);
   if(fd<0) {
-    g_print("%s: open i2c device %s failed: %s\n",__FUNCTION__,i2c_device,g_strerror(errno));
+    g_print("%s: open i2c device %s failed: %s\n",__FUNCTION__,i2c_controller_i2c_device,g_strerror(errno));
     goto end;
   }
-  g_print("%s: open i2c device %s fd=%d\n",__FUNCTION__,i2c_device,fd);
+  g_print("%s: open i2c device %s fd=%d\n",__FUNCTION__,i2c_controller_i2c_device,fd);
 
-  for(int i=0;i<MAX_ENCODERS;i++) {
+  for(int i=0;i<MAX_I2C_ENCODERS;i++) {
     if(encoder[i].enabled) {
  
       if (ioctl(fd, I2C_SLAVE, encoder[i].address) < 0) {
@@ -368,13 +371,13 @@ static void encoder_switch_pushed(int i) {
   }
 }
 
-void i2c_interrupt(int line) {
+static void i2c_interrupt(int line) {
   int length;
 
   g_print("%s: line=%d fd=%d\n",__FUNCTION__,line,fd);
   if(fd!=-1) {
     g_mutex_lock(&encoder_mutex);
-    for(int i=0;i<MAX_ENCODERS;i++) {
+    for(int i=0;i<MAX_I2C_ENCODERS;i++) {
       if(encoder[i].enabled) {
         if (ioctl(fd, I2C_SLAVE, encoder[i].address) < 0) {
           g_print("%s: ioctl i2c slave %d failed: %s\n",__FUNCTION__,encoder[i].address,g_strerror(errno));
@@ -461,7 +464,7 @@ static gpointer monitor_thread(gpointer arg) {
   t.tv_sec=60;
   t.tv_nsec=0;
 
-  int ret=gpiod_ctxless_event_monitor(gpio_device,GPIOD_CTXLESS_EVENT_FALLING_EDGE,new_i2c_interrupt,FALSE,"encoder",&t,NULL,interrupt_cb,NULL);
+  int ret=gpiod_ctxless_event_monitor(i2c_controller_gpio_device,GPIOD_CTXLESS_EVENT_FALLING_EDGE,new_i2c_interrupt,FALSE,"encoder",&t,NULL,interrupt_cb,NULL);
   if (ret<0) {
     g_print("%s: ctxless event monitor failed: %s\n",__FUNCTION__,g_strerror(errno));
   }
@@ -470,7 +473,7 @@ static gpointer monitor_thread(gpointer arg) {
   return NULL;
 }
 
-int gpio_init() {
+static int gpio_init() {
   int ret=0;
 
 
@@ -528,7 +531,7 @@ end:
   return ret;
 }
 
-void gpio_close() {
+static void gpio_close() {
   if(line!=NULL) gpiod_line_release(line);
   if(chip!=NULL) gpiod_chip_close(chip);
 }
index e104e1c77ab66eb227ecb89764573cfd2180b643..31ee49733f4ef5387064760d84ccf05e8be71639 100644 (file)
 #define GAMMA_2_6 6
 #define GAMMA_2_8 7
 
+/*
 enum {
   ENCODER_NO_ACTION=0,
   ENCODER_AF_GAIN,
@@ -240,8 +241,9 @@ enum {
 };
 
 extern char *sw_string[SWITCH_ACTIONS];
+*/
 
-typedef struct _encoder {
+typedef struct i2c_encoder {
   gboolean enabled;
   gint address;
   gint pos;
@@ -254,11 +256,11 @@ typedef struct _encoder {
   gint gp2_function;
   gboolean gp3_enabled; 
   gint gp3_function;
-} ENCODER;
+} I2C_ENCODER;
 
-#define MAX_ENCODERS 7
+#define MAX_I2C_ENCODERS 7
 
-extern ENCODER encoder[MAX_ENCODERS];
+extern I2C_ENCODER encoder[MAX_I2C_ENCODERS];
 
 extern int i2c_controller_init();
 #endif
index 963162cd9873f27360ebd3ce2a9902703a724b74..fd90aebcf37db46c5f40343f0cab51974aa1a6bd 100644 (file)
@@ -2,6 +2,7 @@
 #include <glib.h>
 #include <glib/gprintf.h>
 
+#include "actions.h"
 #include "i2c_controller.h"
 #include "main.h"
 #include "new_menu.h"
@@ -108,7 +109,7 @@ void i2c_controller_menu(GtkWidget *parent_window) {
   gtk_grid_set_column_spacing (GTK_GRID(grid),2);
   gtk_grid_set_row_spacing (GTK_GRID(grid),2);
 
-  for(int i=0;i<MAX_ENCODERS;i++) {
+  for(int i=0;i<MAX_I2C_ENCODERS;i++) {
     row=i%3;
     col=(i/3)*4;
 
@@ -139,7 +140,7 @@ void i2c_controller_menu(GtkWidget *parent_window) {
   gtk_grid_set_column_spacing (GTK_GRID(grid),2);
   gtk_grid_set_row_spacing (GTK_GRID(grid),2);
 
-  for(int i=0;i<MAX_ENCODERS;i++) {
+  for(int i=0;i<MAX_I2C_ENCODERS;i++) {
     row=i%3;
     col=(i/3)*4;
 
diff --git a/main.h b/main.h
index 44b7eff3cf53718feb4177ddde2253f1dc86fa7c..5c9fb6d33efda364a6b5f8ae2b0f5aaf95897529 100644 (file)
--- a/main.h
+++ b/main.h
 #include <sys/utsname.h>
 extern struct utsname unameData;
 
+enum {
+  NO_CONTROLLER,
+  CONTROLLER1,
+  CONTROLLER2_V1,
+  CONTROLLER2_V2,
+  CONTROLLER_I2C
+};
+
+extern gint controller;
+
 extern gint display_width;
 extern gint display_height;
 extern gint full_screen;
index b827564a17b804bad3672ce18cae6f0576254c05..0374e8b8e3f68b424cad0e1306ca117560b0855c 100644 (file)
 #include "actions.h"
 #ifdef GPIO
 #include "gpio.h"
+#include "i2c_controller_menu.h"
 #endif
 #include "old_protocol.h"
 #include "new_protocol.h"
 #ifdef CLIENT_SERVER
 #include "server_menu.h"
 #endif
-#ifdef I2C_CONTROLLER
-#include "i2c_controller_menu.h"
-#endif
 
 
 static GtkWidget *menu_b=NULL;
@@ -190,6 +188,7 @@ static gboolean rigctl_cb (GtkWidget *widget, GdkEventButton *event, gpointer da
   return TRUE;
 }
 
+#ifdef GPIO
 static gboolean encoder_cb (GtkWidget *widget, GdkEventButton *event, gpointer data) {
   cleanup();
   encoder_menu(top_window);
@@ -202,6 +201,17 @@ static gboolean switch_cb (GtkWidget *widget, GdkEventButton *event, gpointer da
   return TRUE;
 }
 
+void start_i2c_controller() {
+  cleanup();
+  i2c_controller_menu(top_window);
+}
+
+static gboolean i2c_controller_cb (GtkWidget *widget, GdkEventButton *event, gpointer data) {
+  start_i2c_controller();
+  return TRUE;
+}
+#endif
+
 static gboolean cw_cb (GtkWidget *widget, GdkEventButton *event, gpointer data) {
   cleanup();
   cw_menu(top_window);
@@ -411,47 +421,6 @@ static gboolean ps_cb (GtkWidget *widget, GdkEventButton *event, gpointer data)
 }
 #endif
 
-#ifdef GPIO
-/*
-void start_encoder(int encoder) {
-  int old_menu=active_menu;
-  cleanup();
-  switch(encoder) {
-    case 2:
-      if(old_menu!=E2_MENU) {
-        encoder_menu(top_window,encoder);
-        active_menu=E2_MENU;
-      }
-      break;
-    case 3:
-      if(old_menu!=E3_MENU) {
-        encoder_menu(top_window,encoder);
-        active_menu=E3_MENU;
-      }
-      break;
-    case 4:
-      if(old_menu!=E4_MENU) {
-        encoder_menu(top_window,encoder);
-        active_menu=E4_MENU;
-      }
-      break;
-    case 5:
-      if(old_menu!=E5_MENU) {
-        encoder_menu(top_window,encoder);
-        active_menu=E5_MENU;
-      }
-      break;
-  }
-}
-
-static gboolean encoder_cb (GtkWidget *widget, GdkEventButton *event, gpointer data) {
-  int encoder=(int)data;
-  start_encoder(encoder);
-  return TRUE;
-}
-*/
-#endif
-
 void start_test() {
   cleanup();
   test_menu(top_window);
@@ -474,18 +443,6 @@ static gboolean server_cb (GtkWidget *widget, GdkEventButton *event, gpointer da
 }
 #endif
 
-#ifdef I2C_CONTROLLER
-void start_i2c_controller() {
-  cleanup();
-  i2c_controller_menu(top_window);
-}
-
-static gboolean i2c_controller_cb (GtkWidget *widget, GdkEventButton *event, gpointer data) {
-  start_i2c_controller();
-  return TRUE;
-}
-#endif
-
 void new_menu()
 {
   int i;
@@ -634,26 +591,35 @@ void new_menu()
     i++;
 
 #ifdef GPIO
-    if(controller!=NO_CONTROLLER) {
-      GtkWidget *encoders_b=gtk_button_new_with_label("Encoders");
-      g_signal_connect (encoders_b, "button-press-event", G_CALLBACK(encoder_cb), NULL);
-      gtk_grid_attach(GTK_GRID(grid),encoders_b,(i%5),i/5,1,1);
-      i++;
+    switch(controller) {
+      case NO_CONTROLLER:
+        break;
+      case CONTROLLER1:
+      case CONTROLLER2_V1:
+      case CONTROLLER2_V2:
+        {
+        GtkWidget *encoders_b=gtk_button_new_with_label("Encoders");
+        g_signal_connect (encoders_b, "button-press-event", G_CALLBACK(encoder_cb), NULL);
+        gtk_grid_attach(GTK_GRID(grid),encoders_b,(i%5),i/5,1,1);
+        i++;
 
-      GtkWidget *switches_b=gtk_button_new_with_label("Switches");
-      g_signal_connect (switches_b, "button-press-event", G_CALLBACK(switch_cb), NULL);
-      gtk_grid_attach(GTK_GRID(grid),switches_b,(i%5),i/5,1,1);
-      i++;
+        GtkWidget *switches_b=gtk_button_new_with_label("Switches");
+        g_signal_connect (switches_b, "button-press-event", G_CALLBACK(switch_cb), NULL);
+        gtk_grid_attach(GTK_GRID(grid),switches_b,(i%5),i/5,1,1);
+        i++;
+        }
+        break;
+      case CONTROLLER_I2C:
+        {
+        GtkWidget *i2c_controller_b=gtk_button_new_with_label("I2C Controller");
+        g_signal_connect (i2c_controller_b, "button-press-event", G_CALLBACK(i2c_controller_cb), NULL);
+        gtk_grid_attach(GTK_GRID(grid),i2c_controller_b,(i%5),i/5,1,1);
+        i++;
+        }
+        break;
     }
 #endif
 
-#ifdef I2C_CONTROLLER
-    GtkWidget *i2c_controller_b=gtk_button_new_with_label("I2C Controller");
-    g_signal_connect (i2c_controller_b, "button-press-event", G_CALLBACK(i2c_controller_cb), NULL);
-    gtk_grid_attach(GTK_GRID(grid),i2c_controller_b,(i%5),i/5,1,1);
-    i++;
-#endif
-
 //
 //  We need at least two receivers and two ADCs to do DIVERSITY
 //
index df51beb8c46e60cb3c06beab24d8181f1c686547..5da076ff448af52b291af376ed00ba861fd19f3e 100644 (file)
--- a/oc_menu.c
+++ b/oc_menu.c
@@ -224,7 +224,7 @@ g_print("oc_menu: parent=%p\n",parent);
     BAND *band=band_get_band(i);
     if(strlen(band->title)>0) {
       GtkWidget *band_label=gtk_label_new(NULL);
-      char band_text[16];
+      char band_text[32];
       sprintf(band_text,"<b>%s</b>",band->title);
       gtk_label_set_markup(GTK_LABEL(band_label), band_text);
       //gtk_widget_override_font(band_label, pango_font_description_from_string("Arial 18"));
diff --git a/radio.c b/radio.c
index b445769234b4a3a41daaf92392511cc1a63d3cac..290481c8a09bed148f1dbb81e35854ec9c378fa7 100644 (file)
--- a/radio.c
+++ b/radio.c
 #include "soapy_protocol.h"
 #endif
 #include "actions.h"
-#ifdef GPIO
 #include "gpio.h"
-#endif
-#ifdef I2C_CONTROLLER
 #include "i2c_controller.h"
-#endif
 #include "vfo.h"
 #include "vox.h"
 #include "meter.h"
@@ -100,6 +96,8 @@ void MIDIstartup();
 #define TOOLBAR_HEIGHT (30)
 #define WATERFALL_HEIGHT (105)
 
+gint controller=NO_CONTROLLER;
+
 GtkWidget *fixed;
 static GtkWidget *vfo_panel;
 static GtkWidget *meter;
@@ -603,9 +601,11 @@ if(!radio_is_remote) {
 #endif
   }
 
-#ifdef I2C_CONTROLLER
-  if(i2c_controller_init()<0) {
-    g_print("%s: I2C_CONTROLLER failed to initialize i2c\n", __FUNCTION__);
+#ifdef GPIO
+  if(controller==CONTROLLER_I2C) {
+    if(i2c_controller_init()<0) {
+      g_print("%s: I2C_CONTROLLER failed to initialize i2c\n", __FUNCTION__);
+    }
   }
 #endif
 
index 75a3cdbb4c26d7091e70320af0bb8d1e6654b5df..2602bcb92399c8edbf8425957846358b9a99f605 100644 (file)
@@ -182,9 +182,11 @@ static void vfo_divisor_value_changed_cb(GtkWidget *widget, gpointer data) {
   vfo_encoder_divisor=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget));
 }
 
+#ifdef GPIO
 static void gpio_settle_value_changed_cb(GtkWidget *widget, gpointer data) {
   settle_time=gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget));
 }
+#endif
 
 /*
 static void toolbar_dialog_buttons_cb(GtkWidget *widget, gpointer data) {
index 1ed7d6fd93a08e0f744111c459157ffe011dcaad..d313fb776b42ec44ccb380d7919404ad45f6e191 100644 (file)
--- a/toolbar.c
+++ b/toolbar.c
 #include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
-#ifdef GPIO
 #include "actions.h"
 #include "gpio.h"
-#endif
 #include "toolbar.h"
 #include "mode.h"
 #include "filter.h"