]> git.rkrishnan.org Git - pihpsdr.git/commitdiff
changed encoders to have diversity phase and gain Coarse and Fine
authorJohn Melton G0ORX <john.d.melton@googlemail.com>
Mon, 2 Mar 2020 20:49:38 +0000 (20:49 +0000)
committerJohn Melton G0ORX <john.d.melton@googlemail.com>
Mon, 2 Mar 2020 20:49:38 +0000 (20:49 +0000)
diversity_menu.c
diversity_menu.h
gpio.c
gpio.h
sliders.c

index 1b66296ab3b8688ff93199e1a12253bf255d0e9f..eba5b02e8fed6fbefc01aa822853bf846fcd3475 100644 (file)
@@ -150,6 +150,34 @@ void update_diversity_gain(double increment) {
   set_gain_phase();
 }
 
+void update_diversity_gain_coarse(double increment) {
+  double g=gain_coarse+increment;
+  if(g<-25.0) g=-25.0;
+  if(g>25.0) g=25.0;
+  gain_coarse=g;
+  div_gain=gain_coarse+gain_fine;
+  if(gain_coarse_scale!=NULL) {
+    gtk_range_set_value(GTK_RANGE(gain_coarse_scale),gain_coarse);
+  } else {
+    show_diversity_gain();
+  }
+  set_gain_phase();
+}
+
+void update_diversity_gain_fine(double increment) {
+  double g=gain_fine+(increment/100);
+  if(g<-2.0) g=-2.0;
+  if(g>2.0) g=2.0;
+  gain_fine=g;
+  div_gain=gain_coarse+gain_fine;
+  if(gain_fine_scale!=NULL) {
+    gtk_range_set_value(GTK_RANGE(gain_fine_scale),gain_fine);
+  } else {
+    show_diversity_gain();
+  }
+  set_gain_phase();
+}
 void update_diversity_phase(double increment) {
   double p=div_phase+increment;
   while (p >  180.0) p -= 360.0;
@@ -169,6 +197,34 @@ void update_diversity_phase(double increment) {
   set_gain_phase();
 }
 
+void update_diversity_phase_coarse(double increment) {
+  double p=phase_coarse+increment;
+  if (p >  180.0) p = 180.0;
+  if (p < -180.0) p = -180.0;
+  phase_coarse=p;
+  if(phase_coarse_scale!=NULL) {
+    gtk_range_set_value(GTK_RANGE(phase_coarse_scale),phase_coarse);
+  } else {
+    show_diversity_phase();
+  }
+  div_phase=phase_coarse+phase_fine;
+  set_gain_phase();
+}
+
+void update_diversity_phase_fine(double increment) {
+  double p=phase_fine+(increment/10.0);
+  while (p >  5.0) p = 5.0;
+  while (p < -5.0) p = -5.0;
+  phase_fine=p;
+  if(phase_fine_scale!=NULL) {
+    gtk_range_set_value(GTK_RANGE(phase_fine_scale),phase_fine);
+  } else {
+    show_diversity_phase();
+  }
+  div_phase=phase_coarse+phase_fine;
+  set_gain_phase();
+}
+
 void diversity_menu(GtkWidget *parent) {
 
   parent_window=parent;
index b71588f9f0609304b9a4e1f186c727873323269a..59d63b825514eb61729501635d0ee573b8fcf921 100644 (file)
@@ -19,4 +19,8 @@
 
 extern void diversity_menu(GtkWidget *parent);
 extern void update_diversity_gain(double increment);
+extern void update_diversity_gain_coarse(double increment);
+extern void update_diversity_gain_fine(double increment);
 extern void update_diversity_phase(double increment);
+extern void update_diversity_phase_coarse(double increment);
+extern void update_diversity_phase_fine(double increment);
diff --git a/gpio.c b/gpio.c
index 83c8b59fa1297700e367cd839dab9f306d1760f6..703774bfbfec0e3d5fe01920e4d6444ecc35a894 100644 (file)
--- a/gpio.c
+++ b/gpio.c
@@ -223,8 +223,10 @@ char *encoder_string[ENCODER_ACTIONS] = {
   "SQUELCH RX1",
   "SQUELCH RX2",
   "COMP",
-  "DIVERSITY GAIN",
-  "DIVERSITY PHASE"};
+  "DIVERSITY GAIN COARSE",
+  "DIVERSITY GAIN FINE",
+  "DIVERSITY PHASE COARSE",
+  "DIVERSITY PHASE FINE"};
 
 char *sw_string[SWITCH_ACTIONS] = {
   "",
@@ -641,7 +643,6 @@ static unsigned long s6_debounce=0;
 
 static void s6Alert() {
     int t=millis();
-    g_print("s6Alert\n");
     if(millis()<s6_debounce) {
       return;
     }
@@ -760,8 +761,10 @@ static void e4EncoderInt() {
   int levelB=digitalRead(E4_ENCODER_B);
 
   if(levelA!=e4CurrentA) {
-    if(levelA==levelB) ++e4EncoderPos;
-    if(levelA!=levelB) --e4EncoderPos;
+    //if(levelA==levelB) ++e4EncoderPos;
+    //if(levelA!=levelB) --e4EncoderPos;
+    if(levelA==levelB) --e4EncoderPos;
+    if(levelA!=levelB) ++e4EncoderPos;
     e4CurrentA=levelA;
   }
 }
@@ -1034,7 +1037,6 @@ g_print("gpio_set_defaults: %d\n",ctrlr);
     default:
       break;
   }
-g_print("controller=%d e2_encoder_action: %d\n",ctrlr,e2_encoder_action);
 }
 
 void gpio_restore_actions() {
@@ -1042,7 +1044,6 @@ void gpio_restore_actions() {
   char name[80];
   int i;
 
-g_print("gpio_restore_actions: controller=%d\n",controller);
   if(sw_action!=NULL) {
     g_free(sw_action);
     sw_action=NULL;
@@ -1098,7 +1099,6 @@ g_print("gpio_restore_actions: controller=%d\n",controller);
     value=getProperty(name);           
     if(value) sw_action[i]=atoi(value);                
   }
-g_print("e2_encoder_action: %d\n",e2_encoder_action);
 }
 
 void gpio_restore_state() {
@@ -1227,7 +1227,6 @@ void gpio_save_actions() {
   char name[80];
   char value[80];
 
-g_print("gpio_save_actions: controller=%d\n",controller);
   sprintf(value,"%d",settle_time);
   setProperty("settle_time",value);
   sprintf(value,"%d",e2_sw_action);
@@ -1400,7 +1399,6 @@ void gpio_save_state() {
 
 static void setup_pin(int pin, int up_down, void(*pAlert)(void)) {
   int rc;
-g_print("setup_pin: pin=%d ip_down=%d pAlert=%p\n",pin,up_down,pAlert);
   pinMode(pin,GPIO);
   pinMode(pin,INPUT);
   pullUpDnControl(pin,up_down);
@@ -1414,6 +1412,7 @@ g_print("setup_pin: pin=%d ip_down=%d pAlert=%p\n",pin,up_down,pAlert);
 
 static void setup_encoder_pin(int pin, int up_down, void(*pAlert)(void)) {
   int rc;
+  pinMode(pin,GPIO);
   pinMode(pin,INPUT);
   pullUpDnControl(pin,up_down);
   usleep(10000);
@@ -1532,11 +1531,14 @@ int gpio_init() {
     }
   }
 
+
   if(ENABLE_E4_ENCODER) {
     setup_pin(E4_FUNCTION, PUD_UP, &e4FunctionAlert);
          
-    setup_encoder_pin(E4_ENCODER_A,ENABLE_E4_PULLUP?PUD_UP:PUD_OFF,&e4EncoderInt);
-    setup_encoder_pin(E4_ENCODER_B,ENABLE_E4_PULLUP?PUD_UP:PUD_OFF,NULL);
+    //setup_encoder_pin(E4_ENCODER_A,ENABLE_E4_PULLUP?PUD_UP:PUD_OFF,&e4EncoderInt);
+    //setup_encoder_pin(E4_ENCODER_B,ENABLE_E4_PULLUP?PUD_UP:PUD_OFF,NULL);
+    setup_encoder_pin(E4_ENCODER_A,ENABLE_E4_PULLUP?PUD_UP:PUD_OFF,NULL);
+    setup_encoder_pin(E4_ENCODER_B,ENABLE_E4_PULLUP?PUD_UP:PUD_OFF,&e4EncoderInt);
     e4EncoderPos=0;
          
     if(controller==CONTROLLER2_V2) {
@@ -1583,17 +1585,14 @@ int gpio_init() {
       setup_pin(S3_BUTTON, PUD_UP, &s3Alert);
     }
   
-    g_print("ENABLE_S4_BUTTON: %d\n",ENABLE_S4_BUTTON);
     if(ENABLE_S4_BUTTON) {
       setup_pin(S4_BUTTON, PUD_UP, &s4Alert);
     }
   
-    g_print("ENABLE_S5_BUTTON: %d\n",ENABLE_S5_BUTTON);
     if(ENABLE_S5_BUTTON) {
       setup_pin(S5_BUTTON, PUD_UP, &s5Alert);
     }
   
-    g_print("ENABLE_S6_BUTTON: %d\n",ENABLE_S6_BUTTON);
     if(ENABLE_S6_BUTTON) {
       setup_pin(S6_BUTTON, PUD_UP, &s6Alert);
     }
@@ -2054,11 +2053,17 @@ static void encoder_changed(int action,int pos) {
       transmitter->compressor_level=(int)value;
       set_compression(transmitter);
       break;
-    case ENCODER_DIVERSITY_GAIN:
-      update_diversity_gain((double)pos);
+    case ENCODER_DIVERSITY_GAIN_COARSE:
+      update_diversity_gain_coarse((double)pos);
+      break;
+    case ENCODER_DIVERSITY_GAIN_FINE:
+      update_diversity_gain_fine((double)pos);
+      break;
+    case ENCODER_DIVERSITY_PHASE_COARSE:
+      update_diversity_phase_coarse((double)pos);
       break;
-    case ENCODER_DIVERSITY_PHASE:
-      update_diversity_phase((double)pos);
+    case ENCODER_DIVERSITY_PHASE_FINE:
+      update_diversity_phase_fine((double)pos);
       break;
   }
 }
diff --git a/gpio.h b/gpio.h
index f90f1887be25499397df35e93630fe327b452e93..536d9e09b9386cba38cc366f6265cdf366d126d6 100644 (file)
--- a/gpio.h
+++ b/gpio.h
@@ -66,8 +66,10 @@ enum {
   ENCODER_SQUELCH_RX1,
   ENCODER_SQUELCH_RX2,
   ENCODER_COMP,
-  ENCODER_DIVERSITY_GAIN,
-  ENCODER_DIVERSITY_PHASE,
+  ENCODER_DIVERSITY_GAIN_COARSE,
+  ENCODER_DIVERSITY_GAIN_FINE,
+  ENCODER_DIVERSITY_PHASE_COARSE,
+  ENCODER_DIVERSITY_PHASE_FINE,
   ENCODER_ACTIONS
 };
 
index f6ecfe6089c67482359703de0b991bc03b1196e2..b3639e385f3a316a92fbc93c3283ec07cecda051 100644 (file)
--- a/sliders.c
+++ b/sliders.c
@@ -740,7 +740,7 @@ void show_diversity_gain() {
       scale_status=DIVERSITY_GAIN;
       scale_dialog=gtk_dialog_new_with_buttons("Diversity Gain",GTK_WINDOW(top_window),GTK_DIALOG_DESTROY_WITH_PARENT,NULL,NULL);
       GtkWidget *content=gtk_dialog_get_content_area(GTK_DIALOG(scale_dialog));
-      diversity_gain_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,-27.0, 27.0, 0.1);
+      diversity_gain_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,-27.0, 27.0, 0.01);
       gtk_widget_set_size_request (diversity_gain_scale, 400, 30);
       gtk_range_set_value (GTK_RANGE(diversity_gain_scale),div_gain);
       gtk_widget_show(diversity_gain_scale);
@@ -767,7 +767,7 @@ void show_diversity_phase() {
       scale_status=DIVERSITY_PHASE;
       scale_dialog=gtk_dialog_new_with_buttons("Diversity Phase",GTK_WINDOW(top_window),GTK_DIALOG_DESTROY_WITH_PARENT,NULL,NULL);
       GtkWidget *content=gtk_dialog_get_content_area(GTK_DIALOG(scale_dialog));
-      diversity_phase_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, -180.0, 180.0, 1.0);
+      diversity_phase_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, -180.0, 180.0, 0.1);
       gtk_widget_set_size_request (diversity_phase_scale, 400, 30);
       gtk_range_set_value (GTK_RANGE(diversity_phase_scale),div_phase);
       gtk_widget_show(diversity_phase_scale);