]> git.rkrishnan.org Git - pihpsdr.git/commitdiff
fix for inputt-ing diversity parameters
authorc vw <dl1ycf@darc.de>
Thu, 16 Jan 2020 10:30:53 +0000 (11:30 +0100)
committerc vw <dl1ycf@darc.de>
Thu, 16 Jan 2020 10:30:53 +0000 (11:30 +0100)
diversity_menu.c
sliders.c

index 0b447cfb29ab05e2f0fc45bb8b859ac2c902265c..6df029686d2e19123a999d2ce6da24818e3711d7 100644 (file)
@@ -129,13 +129,17 @@ static void phase_fine_changed_cb(GtkWidget *widget, gpointer data) {
 
 void update_diversity_gain(double increment) {
   double g=div_gain+(increment/10);
-  if(g<-25.0) g=-25.0;
-  if(g>25.0) g=25.0;
+  if(g<-27.0) g=-27.0;
+  if(g>27.0) g=27.0;
   div_gain=g;
   //
-  // calculate coarse and fine value
+  // calculate coarse and fine value.
+  // if gain is 27, we can only use coarse=25 and fine=2,
+  // but normally we want to keep "fine" small
   //
   gain_coarse=round(div_gain);
+  if (gain_coarse >  25.0) gain_coarse= 25.0;
+  if (gain_coarse < -25.0) gain_coarse=-25.0;
   gain_fine=div_gain - gain_coarse;
   if(gain_coarse_scale!=NULL && gain_fine_scale != NULL) {
     gtk_range_set_value(GTK_RANGE(gain_coarse_scale),gain_coarse);
@@ -148,8 +152,8 @@ void update_diversity_gain(double increment) {
 
 void update_diversity_phase(double increment) {
   double p=div_phase+increment;
-  if(p<0.0) p=360.0;
-  if(p>360.0) p=0.0;
+  while (p >  180.0) p -= 360.0;
+  while (p < -180.0) p += 360.0;
   div_phase=p;
   //
   // calculate coarse and fine
@@ -176,9 +180,15 @@ void diversity_menu(GtkWidget *parent) {
   g_signal_connect (dialog, "delete_event", G_CALLBACK (delete_event), NULL);
 
   //
-  // set coarse/fine values from actual values
+  // set coarse/fine values from "sanitized" actual values
   //
+  if (div_gain >  27.0)  div_gain= 27.0;
+  if (div_gain < -27.0)  div_gain=-27.0;
+  while (div_phase >  180.0) div_phase -=360.0;
+  while (div_phase < -180.0) div_phase +=360.0;
   gain_coarse=round(div_gain);
+  if (gain_coarse >  25.0) gain_coarse= 25.0;
+  if (gain_coarse < -25.0) gain_coarse=-25.0;
   gain_fine=div_gain-gain_coarse;
   phase_coarse=2.0*round(div_phase*0.5);
   phase_fine=div_phase-phase_coarse;
@@ -237,7 +247,7 @@ void diversity_menu(GtkWidget *parent) {
   gtk_widget_show(phase_coarse_label);
   gtk_grid_attach(GTK_GRID(grid),phase_coarse_label,0,3,1,1);
 
-  phase_coarse_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,0.0,360.0,2.0);
+  phase_coarse_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,-180.0,180.0,2.0);
   gtk_widget_set_size_request (phase_coarse_scale, 300, 25);
   gtk_range_set_value(GTK_RANGE(phase_coarse_scale),phase_coarse);
   gtk_widget_show(phase_coarse_scale);
index 5a716c2286e475799179c394dd21956e0aaf3f7d..f53984c87df098220ee461559058d48b6e2c8816 100644 (file)
--- a/sliders.c
+++ b/sliders.c
@@ -695,7 +695,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,-25.0, 25.0, 0.1);
+      diversity_gain_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,-27.0, 27.0, 0.1);
       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);
@@ -722,7 +722,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,0.0, 360.0, 1.0);
+      diversity_phase_scale=gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL,-180.0, 180.0, 1.0);
       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);