From: John Melton - G0ORX/N6LYT Date: Sun, 4 Dec 2016 14:47:12 +0000 (+0000) Subject: fixed TX ANT 1 bug. Fixed filter change in CTUN. Fixed step over center in CTUN.... X-Git-Url: https://git.rkrishnan.org/uri//%22%22?a=commitdiff_plain;h=06d4976765041bf3cc2ce88cfc78aa4840c779e6;p=pihpsdr.git fixed TX ANT 1 bug. Fixed filter change in CTUN. Fixed step over center in CTUN. Added Hide button. --- diff --git a/Makefile b/Makefile index 5e03aea..57fa9d6 100644 --- a/Makefile +++ b/Makefile @@ -143,6 +143,7 @@ filter_menu.c \ noise_menu.c \ agc_menu.c \ fm_menu.c \ +test_menu.c \ rit.c \ meter.c \ mode.c \ @@ -198,6 +199,7 @@ filter_menu.h \ noise_menu.h \ agc_menu.h \ fm_menu.h \ +test_menu.h \ rit.h \ meter.h \ mode.h \ @@ -250,6 +252,7 @@ filter_menu.o \ noise_menu.o \ agc_menu.o \ fm_menu.o \ +test_menu.o \ rit.o \ meter.o \ mode.o \ diff --git a/ant_menu.c b/ant_menu.c index 9e2af14..de36b4c 100644 --- a/ant_menu.c +++ b/ant_menu.c @@ -203,6 +203,7 @@ void ant_menu(GtkWidget *parent) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tx1_b), band->alexTxAntenna==0); gtk_widget_show(tx1_b); gtk_grid_attach(GTK_GRID(grid),tx1_b,8,i+2,1,1); + g_signal_connect(tx1_b,"pressed",G_CALLBACK(tx_ant_cb),(gpointer)((i<<4)+0)); GtkWidget *tx2_b=gtk_radio_button_new_from_widget(GTK_RADIO_BUTTON(tx1_b)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tx2_b), band->alexTxAntenna==1); diff --git a/main.c b/main.c index 443ad5f..084b20a 100644 --- a/main.c +++ b/main.c @@ -65,14 +65,13 @@ #include "psk_waterfall.h" #endif -#define VFO_HEIGHT ((display_height/32)*4) +//#define VFO_HEIGHT ((display_height/32)*4) +#define VFO_HEIGHT ((display_height/32)*6) #define VFO_WIDTH ((display_width/32)*16) #define MENU_HEIGHT VFO_HEIGHT -//#define MENU_WIDTH ((display_width/32)*3) #define MENU_WIDTH ((display_width/32)*8) #define RIT_WIDTH ((MENU_WIDTH/3)*2) #define METER_HEIGHT VFO_HEIGHT -//#define METER_WIDTH ((display_width/32)*13) #define METER_WIDTH ((display_width/32)*8) #define PANADAPTER_HEIGHT ((display_height/32)*8) #define SLIDERS_HEIGHT ((display_height/32)*6) @@ -536,6 +535,11 @@ fprintf(stderr,"%p protocol=%d name=%s\n",d,d->protocol,d->name); } } +static gboolean minimize_cb (GtkWidget *widget, GdkEventButton *event, gpointer data) { + gtk_window_iconify(GTK_WINDOW(window)); + return TRUE; +} + static void start_radio() { int y; fprintf(stderr,"start: selected radio=%p device=%d\n",radio,radio->device); @@ -612,7 +616,6 @@ fprintf(stderr,"start: selected radio=%p device=%d\n",radio,radio->device); gtk_container_add(GTK_CONTAINER(window), fixed); y=0; -fprintf(stderr,"vfo_height=%d\n",VFO_HEIGHT); vfo = vfo_init(VFO_WIDTH,VFO_HEIGHT,window); gtk_fixed_put(GTK_FIXED(fixed),vfo,0,0); @@ -621,12 +624,17 @@ fprintf(stderr,"vfo_height=%d\n",VFO_HEIGHT); rit_control = rit_init(RIT_WIDTH,MENU_HEIGHT,window); gtk_fixed_put(GTK_FIXED(fixed),rit_control,VFO_WIDTH,y); -fprintf(stderr,"menu_height=%d\n",MENU_HEIGHT); + GtkWidget *minimize_b=gtk_button_new_with_label("Hide"); + gtk_widget_override_font(minimize_b, pango_font_description_from_string("FreeMono Bold 10")); + gtk_widget_set_size_request (minimize_b, MENU_WIDTH-RIT_WIDTH, MENU_HEIGHT/2); + g_signal_connect (minimize_b, "button-press-event", G_CALLBACK(minimize_cb), NULL); + gtk_widget_show(minimize_b); + gtk_fixed_put(GTK_FIXED(fixed),minimize_b,VFO_WIDTH+((MENU_WIDTH/3)*2),y); + //menu = menu_init(MENU_WIDTH,MENU_HEIGHT,window); - menu = new_menu_init(MENU_WIDTH-RIT_WIDTH,MENU_HEIGHT,window); - gtk_fixed_put(GTK_FIXED(fixed),menu,VFO_WIDTH+((MENU_WIDTH/3)*2),y); + menu = new_menu_init(MENU_WIDTH-RIT_WIDTH,MENU_HEIGHT/2,window); + gtk_fixed_put(GTK_FIXED(fixed),menu,VFO_WIDTH+((MENU_WIDTH/3)*2),y+(MENU_HEIGHT/2)); -fprintf(stderr,"meter_height=%d\n",METER_HEIGHT); meter = meter_init(METER_WIDTH,METER_HEIGHT,window); gtk_fixed_put(GTK_FIXED(fixed),meter,VFO_WIDTH+MENU_WIDTH,y); y+=VFO_HEIGHT; @@ -646,7 +654,6 @@ fprintf(stderr,"meter_height=%d\n",METER_HEIGHT); height+=SLIDERS_HEIGHT/2; } } -fprintf(stderr,"panadapter_height=%d\n",height); panadapter = panadapter_init(display_width,height); gtk_fixed_put(GTK_FIXED(fixed),panadapter,0,VFO_HEIGHT); y+=height; @@ -667,7 +674,6 @@ fprintf(stderr,"panadapter_height=%d\n",height); if(!display_toolbar) { height+=TOOLBAR_HEIGHT; } -fprintf(stderr,"waterfall_height=%d\n",height); waterfall = waterfall_init(display_width,height); gtk_fixed_put(GTK_FIXED(fixed),waterfall,0,y); y+=height; @@ -689,14 +695,12 @@ fprintf(stderr,"waterfall_height=%d\n",height); #endif if(display_sliders) { -fprintf(stderr,"sliders_height=%d\n",SLIDERS_HEIGHT); sliders = sliders_init(display_width,SLIDERS_HEIGHT,window); gtk_fixed_put(GTK_FIXED(fixed),sliders,0,y); y+=SLIDERS_HEIGHT; } if(display_toolbar) { -fprintf(stderr,"toolbar_height=%d\n",TOOLBAR_HEIGHT); toolbar = toolbar_init(display_width,TOOLBAR_HEIGHT,window); gtk_fixed_put(GTK_FIXED(fixed),toolbar,0,y); y+=TOOLBAR_HEIGHT; diff --git a/meter.c b/meter.c index 23222d4..f95b790 100644 --- a/meter.c +++ b/meter.c @@ -317,7 +317,7 @@ void meter_update(int meter_type,double value,double reverse,double exciter,doub cairo_set_font_size(cr, 12); sprintf(sf,"%d dBm",(int)level); - cairo_move_to(cr, text_location, 45); + cairo_move_to(cr, text_location, meter_height-30); cairo_show_text(cr, sf); #ifdef FREEDV diff --git a/new_menu.c b/new_menu.c index 8af62e5..d09ad8d 100644 --- a/new_menu.c +++ b/new_menu.c @@ -47,6 +47,7 @@ #include "noise_menu.h" #include "agc_menu.h" #include "fm_menu.h" +#include "test_menu.h" static GtkWidget *parent_window=NULL; @@ -238,6 +239,16 @@ static gboolean fm_cb (GtkWidget *widget, GdkEventButton *event, gpointer data) return TRUE; } +void start_test() { + cleanup(); + test_menu(parent_window); +} + +static gboolean test_cb (GtkWidget *widget, GdkEventButton *event, gpointer data) { + start_test(); + return TRUE; +} + static gboolean new_menu_pressed_event_cb (GtkWidget *widget, GdkEventButton *event, gpointer data) @@ -361,6 +372,11 @@ static gboolean new_menu_pressed_event_cb (GtkWidget *widget, g_signal_connect (agc_b, "button-press-event", G_CALLBACK(agc_cb), NULL); gtk_grid_attach(GTK_GRID(grid),agc_b,5,4,1,1); +/* + GtkWidget *test_b=gtk_button_new_with_label("Test"); + g_signal_connect (test_b, "button-press-event", G_CALLBACK(test_cb), NULL); + gtk_grid_attach(GTK_GRID(grid),test_b,0,5,1,1); +*/ gtk_container_add(GTK_CONTAINER(content),grid); diff --git a/radio.c b/radio.c index e957405..3fc3647 100644 --- a/radio.c +++ b/radio.c @@ -340,25 +340,10 @@ void setFrequency(long long f) { BAND *band=band_get_current_band(); BANDSTACK_ENTRY* entry=bandstack_entry_get_current(); - if(entry->frequencyA!=f) { - switch(protocol) { - case NEW_PROTOCOL: - case ORIGINAL_PROTOCOL: - if(ctun) { - long long minf=entry->frequencyA-(long long)(sample_rate/2); - long long maxf=entry->frequencyA+(long long)(sample_rate/2); - if(fmaxf) f=maxf; - ddsOffset=f-entry->frequencyA; - wdsp_set_offset(ddsOffset); - return; - } else { - entry->frequencyA=f; - } - break; -#ifdef LIMESDR - case LIMESDR_PROTOCOL: - { + switch(protocol) { + case NEW_PROTOCOL: + case ORIGINAL_PROTOCOL: + if(ctun) { long long minf=entry->frequencyA-(long long)(sample_rate/2); long long maxf=entry->frequencyA+(long long)(sample_rate/2); if(ffrequencyA; wdsp_set_offset(ddsOffset); return; - } - break; + } else { + entry->frequencyA=f; + } + break; +#ifdef LIMESDR + case LIMESDR_PROTOCOL: + { + long long minf=entry->frequencyA-(long long)(sample_rate/2); + long long maxf=entry->frequencyA+(long long)(sample_rate/2); + if(fmaxf) f=maxf; + ddsOffset=f-entry->frequencyA; + wdsp_set_offset(ddsOffset); + return; + } + break; #endif - } } displayFrequency=f; diff --git a/rigctl.c b/rigctl.c index 23be960..c6eb5de 100644 --- a/rigctl.c +++ b/rigctl.c @@ -1,4 +1,5 @@ -/* TS-2000 emulation via TCP + +/* S-2000 emulation via TCP * Copyright (C) 2016 Steve Wilson * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -36,13 +37,14 @@ #include "wdsp_init.h" #include "bandstack.h" #include "vfo.h" +#include "sliders.h" #include // IP stuff below #include #include //inet_addr -#define RIGCTL_DEBUG +#undef RIGCTL_DEBUG // the port client will be connecting to #define PORT 19090 // This is the HAMLIB port @@ -194,10 +196,6 @@ static void * rigctl (void * arg) { // Response - AG<0/1>123; Where 123 is 0-260 if(len>4) { // Set Audio Gain volume = (double) atoi(&cmd_input[3])/260; -/* KA6S - This crashes the system - BUG - set_af_gain(volume); -*/ g_idle_add(update_af_gain,NULL); } else { // Read Audio Gain sprintf(msg,"AG0%03d;",2.6 * volume); @@ -327,9 +325,6 @@ static void * rigctl (void * arg) { if(len == 13) { //We are receiving freq info long long new_freqA = atoll(&cmd_input[2]); setFrequency(new_freqA); - // KA6S - this kills the system pretty quickly - it freezes - // vfo_update(NULL); - // BUG g_idle_add(vfo_update,NULL); } else { if(len==2) { @@ -342,6 +337,7 @@ static void * rigctl (void * arg) { if(len==13) { //We are receiving freq info long long new_freqA = atoll(&cmd_input[2]); setFrequency(new_freqA); + g_idle_add(vfo_update,NULL); } else if(len == 2) { sprintf(msg,"FB%011d;",getFrequency()); send_resp(msg); @@ -511,12 +507,20 @@ static void * rigctl (void * arg) { entry= (BANDSTACK_ENTRY *) bandstack_entry_get_current(); entry->mode=new_mode; + // BUG - kills the system when there is some + // GPIO activity and Mode sets occur. Used twittling the + // frequency along with setting mode between USB/LSB with + // flrig. Tried doing the g_idle_add trick - but don't know the + // the magic to get that to compile without warnings setMode(entry->mode); + // Moved the vfo_update down after filter updated. (John G0ORX) + //g_idle_add(vfo_update,NULL); FILTER* band_filters=filters[entry->mode]; FILTER* band_filter=&band_filters[entry->filter]; setFilter(band_filter->low,band_filter->high); /* Need a way to update VFO info here..*/ + g_idle_add(vfo_update,NULL); } else { // Read Mode int curr_mode; switch (mode) { @@ -559,8 +563,11 @@ static void * rigctl (void * arg) { send_resp(msg); } else { int tval = atoi(&cmd_input[2]); - new_vol = (double) tval/100; - set_mic_gain(new_vol); + new_vol = (double) tval/2; + //set_mic_gain(new_vol); + double *p_mic_gain=malloc(sizeof(double)); + *p_mic_gain=new_vol; + g_idle_add(update_mic_gain,(void *)p_mic_gain); } } else if(strcmp(cmd_str,"ML")==0) { // Set/read the monitor function level @@ -669,9 +676,12 @@ static void * rigctl (void * arg) { //Scales to 0.00-1.00 double drive_val = - (double)(atoi(&cmd_input[2]))/10; + (double)(atoi(&cmd_input[2])); // setDrive(drive_val); - set_drive(drive_val); + double *p_drive=malloc(sizeof(double)); + *p_drive=drive_val; + g_idle_add(update_drive,(gpointer)p_drive); + //set_drive(drive_val); } } else if(strcmp(cmd_str,"PI")==0) { // STore the programmable memory channel @@ -736,8 +746,11 @@ static void * rigctl (void * arg) { // Scale from -20 - 120 if(len>4) { // Set Audio Gain int base_value = atoi(&cmd_input[2]); - float new_gain = ((((float) base_value)/255) * 140) - 20; - set_agc_gain(new_gain); + double new_gain = ((((double) base_value)/255) * 140) - 20; + //set_agc_gain(new_gain); + double *p_gain=malloc(sizeof(double)); + *p_gain=new_gain; + g_idle_add(update_agc_gain,(gpointer)p_gain); } else { // Read Audio Gain sprintf(msg,"RG%03d;",(255/140)*(agc_gain+20)); send_resp(msg); @@ -1014,7 +1027,7 @@ int init_server () { socket_desc = socket(AF_INET , SOCK_STREAM , 0); if (socket_desc == -1) { - fprintf(stderr,"RIGCTL: Could not create socket\n"); + fprintf(stderr,"RIGCTL: Could not create socket"); } fprintf(stderr, "RIGCTL: Socket created\n"); diff --git a/sliders.c b/sliders.c index 95f46ae..9361387 100644 --- a/sliders.c +++ b/sliders.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include "sliders.h" @@ -156,6 +157,12 @@ void set_agc_gain(double value) { } } +int update_agc_gain(void *data) { + set_agc_gain(*(double*)data); + free(data); + return 0; +} + static void afgain_value_changed_cb(GtkWidget *widget, gpointer data) { volume=gtk_range_get_value(GTK_RANGE(af_gain_scale))/100.0; SetRXAPanelGain1 (CHANNEL_RX0, volume); @@ -240,6 +247,12 @@ void set_mic_gain(double value) { } } +int update_mic_gain(void *data) { + set_mic_gain(*(double*)data); + free(data); + return 0; +} + void set_drive(double value) { setDrive(value); if(display_sliders) { @@ -276,6 +289,12 @@ static void drive_value_changed_cb(GtkWidget *widget, gpointer data) { setDrive(gtk_range_get_value(GTK_RANGE(drive_scale))); } +int update_drive(void *data) { + set_drive(*(double *)data); + free(data); + return 0; +} + void set_tune(double value) { setTuneDrive(value); if(display_sliders) { diff --git a/sliders.h b/sliders.h index 2326c7f..8225e13 100644 --- a/sliders.h +++ b/sliders.h @@ -20,7 +20,10 @@ #ifndef _SLIDERS_H #define _SLIDERS_H -int update_af_gain(void *data); +extern int update_agc_gain(void *); +extern int update_af_gain(void *); +extern int update_mic_gain(void *); +extern int update_drive(void *); void set_agc_gain(double value); void set_af_gain(double value); diff --git a/test_menu.c b/test_menu.c new file mode 100644 index 0000000..2b0191a --- /dev/null +++ b/test_menu.c @@ -0,0 +1,82 @@ +/* Copyright (C) +* 2016 - John Melton, G0ORX/N6LYT +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +* +*/ + +#include +#include +#include + +#include "new_menu.h" + +static GtkWidget *parent_window=NULL; + +static GtkWidget *dialog=NULL; + +static gboolean close_cb (GtkWidget *widget, GdkEventButton *event, gpointer data) { + if(dialog!=NULL) { + gtk_widget_destroy(dialog); + dialog=NULL; + sub_menu=NULL; + } + return TRUE; +} + +static gboolean test_cb (GtkWidget *widget, GdkEventButton *event, gpointer data) { + gtk_window_iconify(GTK_WINDOW(parent_window)); + return TRUE; +} + +void test_menu(GtkWidget *parent) { + + parent_window=parent; + + dialog=gtk_dialog_new(); + gtk_window_set_transient_for(GTK_WINDOW(dialog),GTK_WINDOW(parent_window)); + gtk_window_set_decorated(GTK_WINDOW(dialog),FALSE); + + GdkRGBA color; + color.red = 1.0; + color.green = 1.0; + color.blue = 1.0; + color.alpha = 1.0; + gtk_widget_override_background_color(dialog,GTK_STATE_FLAG_NORMAL,&color); + + GtkWidget *content=gtk_dialog_get_content_area(GTK_DIALOG(dialog)); + + GtkWidget *grid=gtk_grid_new(); + + gtk_grid_set_column_homogeneous(GTK_GRID(grid),TRUE); + gtk_grid_set_row_homogeneous(GTK_GRID(grid),TRUE); + gtk_grid_set_column_spacing (GTK_GRID(grid),5); + gtk_grid_set_row_spacing (GTK_GRID(grid),5); + + GtkWidget *close_b=gtk_button_new_with_label("Close Test"); + g_signal_connect (close_b, "pressed", G_CALLBACK(close_cb), NULL); + gtk_grid_attach(GTK_GRID(grid),close_b,0,0,1,1); + + GtkWidget *test_b=gtk_button_new_with_label("Test"); + g_signal_connect (test_b, "pressed", G_CALLBACK(test_cb), NULL); + gtk_grid_attach(GTK_GRID(grid),test_b,0,1,1,1); + + gtk_container_add(GTK_CONTAINER(content),grid); + + sub_menu=dialog; + + gtk_widget_show_all(dialog); + +} diff --git a/test_menu.h b/test_menu.h new file mode 100644 index 0000000..1a24455 --- /dev/null +++ b/test_menu.h @@ -0,0 +1,20 @@ +/* Copyright (C) +* 2016 - John Melton, G0ORX/N6LYT +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +* +*/ + +void test_menu(GtkWidget *parent); diff --git a/wdsp_init.c b/wdsp_init.c index 18d8fd2..6760a44 100644 --- a/wdsp_init.c +++ b/wdsp_init.c @@ -139,6 +139,7 @@ int getMode() { } void setFilter(int low,int high) { + if(mode==modeCWL) { filterLow=-cw_keyer_sidetone_frequency-low; filterHigh=-cw_keyer_sidetone_frequency+high; @@ -150,15 +151,12 @@ void setFilter(int low,int high) { filterHigh=high; } + RXASetPassband(receiver,(double)filterLow,(double)filterHigh); + double fl=filterLow+ddsOffset; double fh=filterHigh+ddsOffset; - - //RXANBPSetFreqs(receiver,(double)filterLow,(double)filterHigh); - //SetRXABandpassFreqs(receiver, fl,fh); - //SetRXASNBAOutputBandwidth(receiver, (double)filterLow, (double)filterHigh); - RXASetPassband(receiver,fl,fh); - SetTXABandpassFreqs(CHANNEL_TX, fl,fh); + } int getFilterLow() { @@ -215,16 +213,6 @@ void wdsp_set_offset(long long offset) { RXANBPSetShiftFrequency(receiver, (double)offset); SetRXAShiftRun(receiver, 1); } - -/* - BAND *band=band_get_current_band(); - BANDSTACK_ENTRY* entry=bandstack_entry_get_current(); - setFrequency(entry->frequencyA); - setMode(entry->mode); - FILTER* band_filters=filters[entry->mode]; - FILTER* band_filter=&band_filters[entry->filter]; - setFilter(band_filter->low,band_filter->high); -*/ } void wdsp_set_input_rate(double rate) {