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;
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;
"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] = {
"",
static void s6Alert() {
int t=millis();
- g_print("s6Alert\n");
if(millis()<s6_debounce) {
return;
}
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;
}
}
default:
break;
}
-g_print("controller=%d e2_encoder_action: %d\n",ctrlr,e2_encoder_action);
}
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;
value=getProperty(name);
if(value) sw_action[i]=atoi(value);
}
-g_print("e2_encoder_action: %d\n",e2_encoder_action);
}
void gpio_restore_state() {
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);
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);
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);
}
}
+
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) {
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);
}
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;
}
}
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);
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);