From baa20fb6e81527751cd7e97f910c6c56880d6898 Mon Sep 17 00:00:00 2001 From: John Melton G0ORX Date: Fri, 8 Nov 2019 16:00:50 +0000 Subject: [PATCH] Fixed touch screen scroll revered when not in CTUN mode. Fixed touch screen scrool bug when large step size set. --- radio.c | 2 +- receiver.c | 8 ++++---- transmitter.c | 8 ++++++-- tx_panadapter.c | 30 ++++++++++++++++++++++-------- vfo.c | 40 +++++++++++++++++++++++++++++----------- vfo.h | 2 +- 6 files changed, 63 insertions(+), 27 deletions(-) diff --git a/radio.c b/radio.c index fb63857..7cb1ec6 100644 --- a/radio.c +++ b/radio.c @@ -828,7 +828,7 @@ void start_radio() { //fprintf(stderr,"Create transmitter\n"); if(can_transmit) { - transmitter=create_transmitter(CHANNEL_TX, buffer_size, fft_size, updates_per_second, display_width/2, tx_height/2); + transmitter=create_transmitter(CHANNEL_TX, buffer_size, fft_size, updates_per_second, display_width/3, PANADAPTER_HEIGHT); transmitter->x=0; transmitter->y=VFO_HEIGHT; diff --git a/receiver.c b/receiver.c index 48a3380..defeb36 100644 --- a/receiver.c +++ b/receiver.c @@ -113,7 +113,7 @@ gboolean receiver_button_release_event(GtkWidget *widget, GdkEventButton *event, if (event->button == 1) { if(has_moved) { // drag - vfo_move((long long)((float)(x-last_x)*rx->hz_per_pixel)); + vfo_move((long long)((float)(x-last_x)*rx->hz_per_pixel),TRUE); } else { // move to this frequency vfo_move_to((long long)((float)x*rx->hz_per_pixel)); @@ -142,7 +142,7 @@ gboolean receiver_motion_notify_event(GtkWidget *widget, GdkEventMotion *event, //if(state & GDK_BUTTON1_MASK) { //int moved=last_x-x; int moved=x-last_x; - vfo_move((long long)((float)moved*rx->hz_per_pixel)); + vfo_move((long long)((float)moved*rx->hz_per_pixel),FALSE); last_x=x; has_moved=TRUE; //} @@ -153,9 +153,9 @@ gboolean receiver_motion_notify_event(GtkWidget *widget, GdkEventMotion *event, gboolean receiver_scroll_event(GtkWidget *widget, GdkEventScroll *event, gpointer data) { if(event->direction==GDK_SCROLL_UP) { - vfo_move(step); + vfo_move(step,TRUE); } else { - vfo_move(-step); + vfo_move(-step,TRUE); } return TRUE; } diff --git a/transmitter.c b/transmitter.c index 7a44d4f..ec4be79 100644 --- a/transmitter.c +++ b/transmitter.c @@ -139,6 +139,7 @@ void transmitter_set_compressor(TRANSMITTER *tx,int state) { } void reconfigure_transmitter(TRANSMITTER *tx,int height) { +g_print("reconfigure_transmitter: width=%d height=%d\n",tx->width,height); gtk_widget_set_size_request(tx->panadapter, tx->width, height); } @@ -485,7 +486,9 @@ static gboolean update_display(gpointer data) { } } - meter_update(active_receiver,POWER,transmitter->fwd,transmitter->rev,transmitter->exciter,transmitter->alc); + if(!duplex) { + meter_update(active_receiver,POWER,transmitter->fwd,transmitter->rev,transmitter->exciter,transmitter->alc); + } return TRUE; // keep going } @@ -546,7 +549,7 @@ static void init_analyzer(TRANSMITTER *tx) { static void create_visual(TRANSMITTER *tx) { - fprintf(stderr,"transmitter: create_visual: id=%d\n",tx->id); + fprintf(stderr,"transmitter: create_visual: id=%d width=%d height=%d\n",tx->id, tx->width,tx->height); tx->panel=gtk_fixed_new(); gtk_widget_set_size_request (tx->panel, tx->width, tx->height); @@ -768,6 +771,7 @@ fprintf(stderr,"transmitter: allocate buffers: mic_input_buffer=%p iq_output_buf void tx_set_mode(TRANSMITTER* tx,int mode) { if(tx!=NULL) { tx->mode=mode; +g_print("tx_set_mode: %s\n",mode_string[tx->mode]); SetTXAMode(tx->id, tx->mode); tx_set_filter(tx,tx_filter_low,tx_filter_high); } diff --git a/tx_panadapter.c b/tx_panadapter.c index e78ea10..04b86bd 100644 --- a/tx_panadapter.c +++ b/tx_panadapter.c @@ -123,7 +123,7 @@ tx_panadapter_button_release_event_cb (GtkWidget *widget, if (event->button == 1) { if(has_moved) { // drag - vfo_move((long long)((float)(x-last_x)*hz_per_pixel)); + vfo_move((long long)((float)(x-last_x)*hz_per_pixel),TRUE); } else { // move to this frequency vfo_move_to((long long)((float)(x-(display_width/2))*hz_per_pixel)); @@ -154,7 +154,7 @@ tx_panadapter_motion_notify_event_cb (GtkWidget *widget, &state); if(state & GDK_BUTTON1_MASK) { int moved=last_x-x; - vfo_move((long long)((float)moved*hz_per_pixel)); + vfo_move((long long)((float)moved*hz_per_pixel),FALSE); last_x=x; has_moved=TRUE; } @@ -169,9 +169,9 @@ tx_panadapter_scroll_event_cb (GtkWidget *widget, gpointer data) { if(event->direction==GDK_SCROLL_UP) { - vfo_move(step); + vfo_move(step,TRUE); } else { - vfo_move(-step); + vfo_move(-step,TRUE); } return FALSE; } @@ -417,6 +417,23 @@ void tx_panadapter_update(TRANSMITTER *tx) { } #endif + if(duplex) { + char text[64]; + cairo_set_source_rgb(cr,1.0,0.0,0.0); + + sprintf(text,"FWD: %f",transmitter->fwd); + cairo_move_to(cr,10,display_height-40); + cairo_show_text(cr, text); + + sprintf(text,"REV: %f",transmitter->rev); + cairo_move_to(cr,10,display_height-30); + cairo_show_text(cr, text); + + sprintf(text,"ALC: %f",transmitter->alc); + cairo_move_to(cr,10,display_height-20); + cairo_show_text(cr, text); + } + cairo_destroy (cr); gtk_widget_queue_draw (tx->panadapter); @@ -425,10 +442,7 @@ void tx_panadapter_update(TRANSMITTER *tx) { void tx_panadapter_init(TRANSMITTER *tx, int width,int height) { - int display_width=width; - int display_height=height; - -fprintf(stderr,"tx_panadapter_init: %d x %d\n",display_width,display_height); +fprintf(stderr,"tx_panadapter_init: %d x %d\n",width,height); tx->panadapter_surface=NULL; tx->panadapter=gtk_drawing_area_new (); diff --git a/vfo.c b/vfo.c index 97b4c51..7b4180c 100644 --- a/vfo.c +++ b/vfo.c @@ -584,14 +584,20 @@ void vfo_step(int steps) { } } -void vfo_move(long long hz) { +void vfo_move(long long hz,int round) { int id=active_receiver->id; g_print("vfo_move: id=%d hz=%lld\n",id,hz); if(!locked) { if(vfo[id].ctun) { - vfo[id].ctun_frequency=((vfo[id].ctun_frequency+hz)/step)*step; + vfo[id].ctun_frequency=vfo[id].ctun_frequency+hz; + if(round) { + vfo[id].ctun_frequency=(vfo[id].ctun_frequency/step)*step; + } } else { - vfo[id].frequency=((vfo[id].frequency+hz)/step)*step; + vfo[id].frequency=vfo[id].frequency-hz; + if(round) { + vfo[id].frequency=(vfo[id].frequency/step)*step; + } } int sid=id==0?1:0; switch(sat_mode) { @@ -600,17 +606,29 @@ g_print("vfo_move: id=%d hz=%lld\n",id,hz); case SAT_MODE: // A and B increment and decrement together if(vfo[sid].ctun) { - vfo[sid].ctun_frequency=((vfo[sid].ctun_frequency+hz)/step)*step; + vfo[sid].ctun_frequency=vfo[sid].ctun_frequency+hz; + if(round) { + vfo[sid].ctun_frequency=(vfo[sid].ctun_frequency/step)*step; + } } else { - vfo[sid].frequency=((vfo[sid].frequency+hz)/step)*step; + vfo[sid].frequency=vfo[sid].frequency-hz; + if(round) { + vfo[sid].frequency=(vfo[sid].frequency/step)*step; + } } break; case RSAT_MODE: // A increments and B decrements or A decrments and B increments if(vfo[sid].ctun) { vfo[sid].ctun_frequency=((vfo[sid].ctun_frequency-hz)/step)*step; + if(round) { + vfo[sid].ctun_frequency=(vfo[sid].ctun_frequency/step)*step; + } } else { - vfo[sid].frequency=((vfo[sid].frequency-hz)/step)*step; + vfo[sid].frequency=((vfo[sid].frequency+hz)/step)*step; + if(round) { + vfo[sid].ctun_frequency=(vfo[sid].ctun_frequency/step)*step; + } } break; } @@ -715,9 +733,9 @@ vfo_scroll_event_cb (GtkWidget *widget, { int i; if(event->direction==GDK_SCROLL_UP) { - vfo_move(step); + vfo_move(step,TRUE); } else { - vfo_move(-step); + vfo_move(-step,TRUE); } return FALSE; } @@ -1061,7 +1079,7 @@ void vfo_update() { cairo_show_text(cr, "Locked"); //cairo_move_to(cr, 55, 50); - cairo_move_to(cr, 260, 15); + cairo_move_to(cr, 260, 18); if(split) { cairo_set_source_rgb(cr, 1.0, 0.0, 0.0); } else { @@ -1070,7 +1088,7 @@ void vfo_update() { cairo_show_text(cr, "Split"); //cairo_move_to(cr, 95, 50); - cairo_move_to(cr, 260, 25); + cairo_move_to(cr, 260, 28); if(sat_mode!=SAT_NONE) { cairo_set_source_rgb(cr, 1.0, 0.0, 0.0); } else { @@ -1090,7 +1108,7 @@ void vfo_update() { } sprintf(temp_text,"DUP"); //cairo_move_to(cr, 130, 50); - cairo_move_to(cr, 260, 35); + cairo_move_to(cr, 260, 38); cairo_set_font_size(cr, 12); cairo_show_text(cr, temp_text); diff --git a/vfo.h b/vfo.h index 310e35c..9ad802b 100644 --- a/vfo.h +++ b/vfo.h @@ -66,7 +66,7 @@ extern char *step_labels[]; extern GtkWidget* vfo_init(int width,int height,GtkWidget *parent); extern void vfo_step(int steps); -extern void vfo_move(long long hz); +extern void vfo_move(long long hz,int round); extern void vfo_move_to(long long hz); extern void vfo_update(); extern void set_frequency(); -- 2.45.2