From: John Melton G0ORX <john.d.melton@googlemail.com> Date: Fri, 12 Mar 2021 13:18:03 +0000 (+0000) Subject: Add VFOSTEP_PLUS and VFOSTEP_MINUS to switch functions X-Git-Url: https://git.rkrishnan.org/pf/simplejson/bar.txt?a=commitdiff_plain;h=98419181d3881fcaa1986ff14175d74cb9e1bccf;p=pihpsdr.git Add VFOSTEP_PLUS and VFOSTEP_MINUS to switch functions --- diff --git a/actions.c b/actions.c index 2c819dd..9bf4ee3 100644 --- a/actions.c +++ b/actions.c @@ -126,6 +126,8 @@ char *sw_string[SWITCH_ACTIONS] = { "TUNE FULL", "TUNE MEM", "TWO TONE", + "VFOSTEP +", + "VFOSTEP -", "XIT", "XIT CL", "XIT -", @@ -183,6 +185,8 @@ char *sw_cap_string[SWITCH_ACTIONS] = { "TUN-F", "TUN-M", "2TONE", + "STEP+", + "STEP-", "XIT", "XIT CL", "XIT -", @@ -499,6 +503,7 @@ int encoder_action(void *data) { } int switch_action(void *data) { + int i; SWITCH_ACTION *a=(SWITCH_ACTION *)data; if(a->state==PRESSED) { switch(a->action) { @@ -572,6 +577,26 @@ int switch_action(void *data) { tx_set_twotone(transmitter,state); } break; + case VFOSTEP_PLUS: + for(i=0;i<STEPS;i++) { + if(steps[i]==step) break; + } + if(i>=STEPS) i=0; + i++; + if(i>=STEPS) i=0; + step=steps[i]; + g_idle_add(ext_vfo_update, NULL); + break; + case VFOSTEP_MINUS: + for(i=0;i<STEPS;i++) { + if(steps[i]==step) break; + } + if(i>=STEPS) i=0; + i--; + if(i<0) i=STEPS-1; + step=steps[i]; + g_idle_add(ext_vfo_update, NULL); + break; case NR: if(active_receiver->nr==0 && active_receiver->nr2==0) { active_receiver->nr=1; diff --git a/actions.h b/actions.h index c0c011a..b48c5b3 100644 --- a/actions.h +++ b/actions.h @@ -96,6 +96,8 @@ enum { TUNE_FULL, TUNE_MEMORY, TWO_TONE, + VFOSTEP_PLUS, + VFOSTEP_MINUS, XIT, XIT_CLEAR, XIT_MINUS, diff --git a/ext.c b/ext.c index 6ee09b2..d94efa2 100644 --- a/ext.c +++ b/ext.c @@ -264,10 +264,11 @@ int ext_tx_set_ps(void *data) { int ext_update_vfo_step(void *data) { int direction=GPOINTER_TO_INT(data); - int i=0; - while(steps[i]!=step && steps[i]!=0) { - i++; + int i; + for(i=0;i<STEPS;i++) { + if(steps[i]==step) break; } + if(step>=STEPS) i=0; if(steps[i]!=0) { if(direction>0) { diff --git a/gpio.c b/gpio.c index 1509d1f..0e86587 100644 --- a/gpio.c +++ b/gpio.c @@ -683,21 +683,21 @@ void gpio_restore_state() { if(value) encoders[i].switch_address=atoi(value); } - if(controller==CONTROLLER1) { - for(int f=0;f<MAX_FUNCTIONS;f++) { - for(int i=0;i<MAX_SWITCHES;i++) { - sprintf(name,"switches[%d,%d].switch_enabled",f,i); - value=getProperty(name); - if(value) switches_controller1[f][i].switch_enabled=atoi(value); - sprintf(name,"switches[%d,%d].switch_pullup",f,i); - value=getProperty(name); - if(value) switches_controller1[f][i].switch_pullup=atoi(value); - sprintf(name,"switches[%d,%d].switch_address",f,i); - value=getProperty(name); - if(value) switches_controller1[f][i].switch_address=atoi(value); - } + for(int f=0;f<MAX_FUNCTIONS;f++) { + for(int i=0;i<MAX_SWITCHES;i++) { + sprintf(name,"switches[%d,%d].switch_enabled",f,i); + value=getProperty(name); + if(value) switches_controller1[f][i].switch_enabled=atoi(value); + sprintf(name,"switches[%d,%d].switch_pullup",f,i); + value=getProperty(name); + if(value) switches_controller1[f][i].switch_pullup=atoi(value); + sprintf(name,"switches[%d,%d].switch_address",f,i); + value=getProperty(name); + if(value) switches_controller1[f][i].switch_address=atoi(value); } - } else { + } + + if(controller!=CONTROLLER1) { for(int i=0;i<MAX_SWITCHES;i++) { sprintf(name,"switches[%d].switch_enabled",i); value=getProperty(name); @@ -763,22 +763,21 @@ void gpio_save_state() { setProperty(name,value); } - if(controller==CONTROLLER1) { - for(int f=0;f<MAX_FUNCTIONS;f++) { - for(int i=0;i<MAX_SWITCHES;i++) { - sprintf(name,"switches[%d,%d].switch_enabled",f,i); - sprintf(value,"%d",switches_controller1[f][i].switch_enabled); - setProperty(name,value); - sprintf(name,"switches[%d,%d].switch_pullup",f,i); - sprintf(value,"%d",switches_controller1[f][i].switch_pullup); - setProperty(name,value); - sprintf(name,"switches[%d,%d].switch_address",f,i); - sprintf(value,"%d",switches_controller1[f][i].switch_address); - setProperty(name,value); - } + for(int f=0;f<MAX_FUNCTIONS;f++) { + for(int i=0;i<MAX_SWITCHES;i++) { + sprintf(name,"switches[%d,%d].switch_enabled",f,i); + sprintf(value,"%d",switches_controller1[f][i].switch_enabled); + setProperty(name,value); + sprintf(name,"switches[%d,%d].switch_pullup",f,i); + sprintf(value,"%d",switches_controller1[f][i].switch_pullup); + setProperty(name,value); + sprintf(name,"switches[%d,%d].switch_address",f,i); + sprintf(value,"%d",switches_controller1[f][i].switch_address); + setProperty(name,value); } -/* - } else { + } + + if(controller!=CONTROLLER1) { for(int i=0;i<MAX_SWITCHES;i++) { sprintf(name,"switches[%d].switch_enabled",i); sprintf(value,"%d",switches[i].switch_enabled); @@ -790,7 +789,6 @@ void gpio_save_state() { sprintf(value,"%d",switches[i].switch_address); setProperty(name,value); } -*/ } saveProperties("gpio.props"); @@ -811,15 +809,14 @@ void gpio_restore_actions() { if(value) encoders[i].switch_function=atoi(value); } - if(controller==CONTROLLER1) { - for(int f=0;f<MAX_FUNCTIONS;f++) { - for(int i=0;i<MAX_SWITCHES;i++) { - sprintf(name,"switches[%d,%d].switch_function",f,i); - value=getProperty(name); - if(value) switches_controller1[f][i].switch_function=atoi(value); - } + for(int f=0;f<MAX_FUNCTIONS;f++) { + for(int i=0;i<MAX_SWITCHES;i++) { + sprintf(name,"switches[%d,%d].switch_function",f,i); + value=getProperty(name); + if(value) switches_controller1[f][i].switch_function=atoi(value); } - } else { + } + if(controller!=CONTROLLER1) { for(int i=0;i<MAX_SWITCHES;i++) { sprintf(name,"switches[%d].switch_function",i); value=getProperty(name); @@ -843,15 +840,14 @@ void gpio_save_actions() { setProperty(name,value); } - if(controller==CONTROLLER1) { - for(int f=0;f<MAX_FUNCTIONS;f++) { - for(int i=0;i<MAX_SWITCHES;i++) { - sprintf(name,"switches[%d,%d].switch_function",f,i); - sprintf(value,"%d",switches_controller1[f][i].switch_function); - setProperty(name,value); - } + for(int f=0;f<MAX_FUNCTIONS;f++) { + for(int i=0;i<MAX_SWITCHES;i++) { + sprintf(name,"switches[%d,%d].switch_function",f,i); + sprintf(value,"%d",switches_controller1[f][i].switch_function); + setProperty(name,value); } - } else { + } + if(controller!=CONTROLLER1) { for(int i=0;i<MAX_SWITCHES;i++) { sprintf(name,"switches[%d].switch_function",i); sprintf(value,"%d",switches[i].switch_function); diff --git a/radio.c b/radio.c index f0e09b8..430ec31 100644 --- a/radio.c +++ b/radio.c @@ -2090,9 +2090,10 @@ g_print("radioRestoreState: %s\n",property_path); memRestoreState(); vfo_restore_state(); modesettings_restore_state(); -#ifdef GPIO +//#ifdef GPIO +// gpio_restore_actions(); +//#endif gpio_restore_actions(); -#endif value=getProperty("rigctl_enable"); if(value) rigctl_enable=atoi(value); value=getProperty("rigctl_port_base"); @@ -2163,11 +2164,12 @@ g_print("radioSaveState: %s\n",property_path); g_mutex_lock(&property_mutex); clearProperties(); -#ifdef GPIO - if(controller!=NO_CONTROLLER) { - gpio_save_actions(); - } -#endif +//#ifdef GPIO +// if(controller!=NO_CONTROLLER) { +// gpio_save_actions(); +// } +//#endif + gpio_save_actions(); sprintf(value,"%d",receivers); setProperty("receivers",value); for(i=0;i<receivers;i++) { diff --git a/vfo.c b/vfo.c index 6da5c02..549e7f1 100644 --- a/vfo.c +++ b/vfo.c @@ -64,8 +64,8 @@ static int my_height; static GtkWidget *vfo_panel; static cairo_surface_t *vfo_surface = NULL; -int steps[]={1,10,25,50,100,250,500,1000,5000,9000,10000,100000,250000,500000,1000000,0}; -char *step_labels[]={"1Hz","10Hz","25Hz","50Hz","100Hz","250Hz","500Hz","1kHz","5kHz","9kHz","10kHz","100kHz","250KHz","500KHz","1MHz",0}; +int steps[]={1,10,25,50,100,250,500,1000,5000,9000,10000,100000,250000,500000,1000000}; +char *step_labels[]={"1Hz","10Hz","25Hz","50Hz","100Hz","250Hz","500Hz","1kHz","5kHz","9kHz","10kHz","100kHz","250KHz","500KHz","1MHz"}; static GtkWidget* menu=NULL; static GtkWidget* band_menu=NULL; @@ -570,7 +570,6 @@ void vfo_step(int steps) { #ifdef CLIENT_SERVER if(radio_is_remote) { - //send_vfo_step(client_socket,id,steps); update_vfo_step(id,steps); return; } @@ -1133,10 +1132,12 @@ void vfo_update() { } cairo_show_text(cr, "DIV"); - int s=0; - while(steps[s]!=step && steps[s]!=0) { - s++; + int s; + for(s=0;s<STEPS;s++) { + if(steps[s]==step) break; } + if(s>=STEPS) s=0; + sprintf(temp_text,"Step %s",step_labels[s]); cairo_move_to(cr, 400, 15); cairo_set_source_rgb(cr, 1.0, 1.0, 0.0); @@ -1214,16 +1215,6 @@ fprintf(stderr,"vfo_update: no surface!\n"); } } -/* -static gboolean -vfo_step_select_cb (GtkWidget *widget, - gpointer data) -{ - step=steps[(int)data]; - g_idle_add(ext_vfo_update,NULL); -} -*/ - static gboolean vfo_press_event_cb (GtkWidget *widget, GdkEventButton *event, diff --git a/vfo.h b/vfo.h index f46d32f..41240c1 100644 --- a/vfo.h +++ b/vfo.h @@ -71,6 +71,7 @@ typedef struct _set_frequency { long long frequency; } SET_FREQUENCY; +#define STEPS 15 extern int steps[]; extern char *step_labels[];