From cbb6fca11caeb8d133311c62533fd6eaea511642 Mon Sep 17 00:00:00 2001 From: John Melton G0ORX Date: Mon, 2 Mar 2020 20:49:38 +0000 Subject: [PATCH] changed encoders to have diversity phase and gain Coarse and Fine --- diversity_menu.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ diversity_menu.h | 4 ++++ gpio.c | 43 +++++++++++++++++++++---------------- gpio.h | 6 ++++-- sliders.c | 4 ++-- 5 files changed, 90 insertions(+), 23 deletions(-) diff --git a/diversity_menu.c b/diversity_menu.c index 1b66296..eba5b02 100644 --- a/diversity_menu.c +++ b/diversity_menu.c @@ -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; diff --git a/diversity_menu.h b/diversity_menu.h index b71588f..59d63b8 100644 --- a/diversity_menu.h +++ b/diversity_menu.h @@ -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 83c8b59..703774b 100644 --- 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()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 f90f188..536d9e0 100644 --- 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 }; diff --git a/sliders.c b/sliders.c index f6ecfe6..b3639e3 100644 --- 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); -- 2.45.2