From 1eaf33f9533481e4aa5980bb63b462fbb8319466 Mon Sep 17 00:00:00 2001 From: c vw Date: Wed, 4 Dec 2019 17:03:18 +0100 Subject: [PATCH] fixes --- new_protocol.c | 9 ++-- old_protocol.c | 9 ++-- radio.c | 2 + rx_menu.c | 7 +++ transmitter.c | 6 ++- tx_menu.c | 7 +++ vfo.c | 125 ++++++++++++++++++------------------------------- 7 files changed, 78 insertions(+), 87 deletions(-) diff --git a/new_protocol.c b/new_protocol.c index 607e6f0..4fe00bb 100644 --- a/new_protocol.c +++ b/new_protocol.c @@ -764,7 +764,8 @@ static void new_protocol_high_priority() { int power=0; if(isTransmitting()) { if(tune && !transmitter->tune_use_drive) { - power=(int)((double)transmitter->drive_level/100.0*(double)transmitter->tune_percent); + double fac=sqrt((double)transmitter->tune_percent * 0.01); + power=(int)((double)transmitter->drive_level*fac); } else { power=transmitter->drive_level; } @@ -1821,6 +1822,7 @@ static void process_mic_data(int bytes) { int b; int i; short sample; + float fsample; sequence=((mic_line_buffer[0]&0xFF)<<24)+((mic_line_buffer[1]&0xFF)<<16)+((mic_line_buffer[2]&0xFF)<<8)+(mic_line_buffer[3]&0xFF); if (sequence != micsamples_sequence) { @@ -1832,12 +1834,13 @@ static void process_mic_data(int bytes) { for(i=0;ifreedv) { - add_freedv_mic_sample(transmitter,sample); + add_freedv_mic_sample(transmitter,fsample); } else { #endif - add_mic_sample(transmitter,sample); + add_mic_sample(transmitter,fsample); #ifdef FREEDV } #endif diff --git a/old_protocol.c b/old_protocol.c index 4b407fd..035b30b 100644 --- a/old_protocol.c +++ b/old_protocol.c @@ -823,6 +823,7 @@ static void process_ozy_input_buffer(unsigned char *buffer) { int left_sample; int right_sample; short mic_sample; + float fsample; double left_sample_double; double right_sample_double; double mic_sample_double; @@ -982,12 +983,13 @@ static void process_ozy_input_buffer(unsigned char *buffer) { if(!transmitter->local_microphone) { mic_samples++; if(mic_samples>=mic_sample_divisor) { // reduce to 48000 + fsample = (float) mic_sample * 0.00003051; #ifdef FREEDV if(active_receiver->freedv) { - add_freedv_mic_sample(transmitter,mic_sample); + add_freedv_mic_sample(transmitter,fsample); } else { #endif - add_mic_sample(transmitter,mic_sample); + add_mic_sample(transmitter,fsample); #ifdef FREEDV } #endif @@ -1348,7 +1350,8 @@ void ozy_send_buffer() { } if(isTransmitting() || (mode == modeCWU) || (mode == modeCWL)) { if(tune && !transmitter->tune_use_drive) { - power=(int)((double)transmitter->drive_level/100.0*(double)transmitter->tune_percent); + double fac=sqrt((double)transmitter->tune_percent * 0.01); + power=(int)((double)transmitter->drive_level*fac); } else { power=transmitter->drive_level; } diff --git a/radio.c b/radio.c index 3bfbd56..0c2bb0f 100644 --- a/radio.c +++ b/radio.c @@ -825,6 +825,8 @@ void start_radio() { g_object_ref((gpointer)receiver[i]->panel); set_displaying(receiver[i],1); y+=rx_height; + // Upon startup, if RIT or CTUN is active, tell WDSP. + set_offset(receiver[i],vfo[i].offset); } if((protocol==ORIGINAL_PROTOCOL) && (RECEIVERS==2) && (receiver[0]->sample_rate!=receiver[1]->sample_rate)) { diff --git a/rx_menu.c b/rx_menu.c index 42b9d64..c9fd938 100644 --- a/rx_menu.c +++ b/rx_menu.c @@ -360,6 +360,13 @@ void rx_menu(GtkWidget *parent) { } } } + + // If the combo box shows no device, take the first one + i=gtk_combo_box_get_active(GTK_COMBO_BOX(output)); + if (i < 0) { + gtk_combo_box_set_active(GTK_COMBO_BOX(output),0); + } + gtk_grid_attach(GTK_GRID(grid),output,x,++row,1,1); g_signal_connect(output,"changed",G_CALLBACK(local_output_changed_cb),NULL); diff --git a/transmitter.c b/transmitter.c index 6f01908..4f5f9a3 100644 --- a/transmitter.c +++ b/transmitter.c @@ -962,11 +962,13 @@ static void full_tx_buffer(TRANSMITTER *tx) { // scaling the TX IQ samples. In the other cases, DriveLevel // as sent in the C&C frames becomes effective and the IQ // samples are sent with full amplitude. + // DL1YCF: include factor 0.00392 since DriveLevel == 255 means full amplitude // if(tune && !transmitter->tune_use_drive) { - gain=gain*((double)transmitter->drive_level*100.0/(double)transmitter->tune_percent); + double fac=sqrt((double)transmitter->tune_percent * 0.01); + gain=gain*(double)transmitter->drive_level*fac*0.00392; } else { - gain=gain*(double)transmitter->drive_level; + gain=gain*(double)transmitter->drive_level*0.00392; } } diff --git a/tx_menu.c b/tx_menu.c index 3848c04..8248c30 100644 --- a/tx_menu.c +++ b/tx_menu.c @@ -361,6 +361,13 @@ void tx_menu(GtkWidget *parent) { } } + // If the combo box shows no device, take the first one + i=gtk_combo_box_get_active(GTK_COMBO_BOX(input)); + if (i < 0) { + gtk_combo_box_set_active(GTK_COMBO_BOX(input),0); + } + + gtk_grid_attach(GTK_GRID(grid),input,col,row++,1,1); g_signal_connect(input,"changed",G_CALLBACK(local_input_changed_cb),NULL); diff --git a/vfo.c b/vfo.c index 6aacdc5..a1e783e 100644 --- a/vfo.c +++ b/vfo.c @@ -550,37 +550,38 @@ void vfo_a_swap_b() { void vfo_step(int steps) { int id=active_receiver->id; - long long saved_freq; + long long delta; if(!locked) { + if(vfo[id].ctun) { - saved_freq=vfo[id].ctun_frequency; + delta=vfo[id].ctun_frequency; vfo[id].ctun_frequency=(vfo[id].ctun_frequency/step + steps)*step; + delta=vfo[id].ctun_frequency - delta; } else { - saved_freq=vfo[id].frequency; + delta=vfo[id].frequency; vfo[id].frequency=(vfo[id].frequency/step + steps)*step; + delta = vfo[id].frequency - delta; } -//g_print("vfo_step: id=%d steps=%d step=%lld ctun=%d freq=%lld to %lld\n",id,steps,step,vfo[id].ctun,saved_freq,vfo[id].ctun?vfo[id].ctun_frequency:vfo[id].frequency); - int sid=id==0?1:0; switch(sat_mode) { case SAT_NONE: break; case SAT_MODE: // A and B increment and decrement together - if(vfo[sid].ctun) { - vfo[sid].ctun_frequency=(vfo[sid].ctun_frequency/step + steps)*step; + if (vfo[sid].ctun) { + vfo[sid].ctun_frequency += delta; } else { - vfo[sid].frequency=(vfo[sid].frequency/step + steps)*step; + vfo[sid].frequency += delta; } 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/step + steps)*step; + if (vfo[sid].ctun) { + vfo[sid].ctun_frequency -= delta; } else { - vfo[sid].frequency=(vfo[sid].frequency/step -steps)*step; + vfo[sid].frequency -= delta; } break; } @@ -594,16 +595,17 @@ void vfo_step(int steps) { // changing the VFO of the active receiver // void vfo_id_step(int id, int steps) { - long long saved_freq; + long long delta; if(!locked) { if(vfo[id].ctun) { - saved_freq=vfo[id].ctun_frequency; + delta=vfo[id].ctun_frequency; vfo[id].ctun_frequency=(vfo[id].ctun_frequency/step+steps)*step; + delta=vfo[id].ctun_frequency - delta; } else { - saved_freq=vfo[id].frequency; + delta=vfo[id].frequency; vfo[id].frequency=(vfo[id].frequency/step+steps)*step; + delta = vfo[id].frequency - delta; } -//g_print("vfo_id_step: id=%d steps=%d step=%lld ctun=%d freq=%lld to %lld\n",id,steps,step,vfo[id].ctun,saved_freq,vfo[id].ctun?vfo[id].ctun_frequency:vfo[id].frequency); int sid=id==0?1:0; switch(sat_mode) { @@ -611,48 +613,45 @@ void vfo_id_step(int id, int steps) { break; case SAT_MODE: // A and B increment and decrement together - if(vfo[sid].ctun) { - vfo[sid].ctun_frequency=vfo[sid].ctun_frequency+(steps*step); + if (vfo[sid].ctun) { + vfo[sid].ctun_frequency += delta; } else { - vfo[sid].frequency=vfo[sid].frequency+(steps*step); + vfo[sid].frequency += delta; } 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-(steps*step); + if (vfo[sid].ctun) { + vfo[sid].ctun_frequency -= delta; } else { - vfo[sid].frequency=vfo[sid].frequency-(steps*step); + vfo[sid].frequency -= delta; } break; } receiver_frequency_changed(active_receiver); -#ifdef INCLUDED - BANDSTACK_ENTRY* entry=bandstack_entry_get_current(); - setFrequency(active_receiver->frequency+(steps*step)); -#endif g_idle_add(ext_vfo_update,NULL); } } void vfo_move(long long hz,int round) { int id=active_receiver->id; - long long saved_freq; + long long delta; if(!locked) { if(vfo[id].ctun) { - saved_freq=vfo[id].ctun_frequency; + delta=vfo[id].ctun_frequency; vfo[id].ctun_frequency=vfo[id].ctun_frequency+hz; if(round && (vfo[id].mode!=modeCWL && vfo[id].mode!=modeCWU)) { vfo[id].ctun_frequency=(vfo[id].ctun_frequency/step)*step; } + delta=vfo[id].ctun_frequency - delta; } else { - saved_freq=vfo[id].frequency; + delta=vfo[id].frequency; vfo[id].frequency=vfo[id].frequency-hz; if(round && (vfo[id].mode!=modeCWL && vfo[id].mode!=modeCWU)) { vfo[id].frequency=(vfo[id].frequency/step)*step; } -//g_print("vfo_move: id=%d ctun=%d hz=%lld round=%d sat_mode=%d freq=%lld to %lld\n",id,vfo[id].ctun,hz,round,sat_mode,saved_freq,vfo[id].ctun?vfo[id].ctun_frequency:vfo[id].frequency); + delta = vfo[id].frequency - delta; } int sid=id==0?1:0; @@ -660,37 +659,19 @@ void vfo_move(long long hz,int round) { case SAT_NONE: break; case SAT_MODE: - if(!vfo[id].ctun) { - hz=-hz; - } // A and B increment and decrement together - if(vfo[sid].ctun) { - vfo[sid].ctun_frequency=vfo[sid].ctun_frequency+hz; - if(round && (vfo[sid].mode!=modeCWL && vfo[sid].mode!=modeCWU)) { - vfo[sid].ctun_frequency=(vfo[sid].ctun_frequency/step)*step; - } + if (vfo[sid].ctun) { + vfo[sid].ctun_frequency += delta; } else { - vfo[sid].frequency=vfo[sid].frequency+hz; - if(round && (vfo[sid].mode!=modeCWL && vfo[sid].mode!=modeCWU)) { - vfo[sid].frequency=(vfo[sid].frequency/step)*step; - } + vfo[sid].frequency += delta; } break; case RSAT_MODE: // A increments and B decrements or A decrments and B increments - if(!vfo[id].ctun) { - hz=-hz; - } - if(vfo[sid].ctun) { - vfo[sid].ctun_frequency=vfo[sid].ctun_frequency-hz; - if(round && (vfo[sid].mode!=modeCWL && vfo[sid].mode!=modeCWU)) { - vfo[sid].ctun_frequency=(vfo[sid].ctun_frequency/step)*step; - } + if (vfo[sid].ctun) { + vfo[sid].ctun_frequency -= delta; } else { - vfo[sid].frequency=vfo[sid].frequency-hz; - if(round && (vfo[sid].mode!=modeCWL && vfo[sid].mode!=modeCWU)) { - vfo[sid].frequency=(vfo[sid].frequency/step)*step; - } + vfo[sid].frequency -= delta; } break; } @@ -704,10 +685,10 @@ void vfo_move_to(long long hz) { int id=active_receiver->id; long long offset=hz; long long half=(long long)(active_receiver->sample_rate/2); - long long diff; long long f; - long long saved_freq; + long long delta; + fprintf(stderr,"VFO MOVE TO: %lld\n", hz); if(vfo[id].mode!=modeCWL && vfo[id].mode!=modeCWU) { offset=(hz/step)*step; } @@ -715,57 +696,43 @@ void vfo_move_to(long long hz) { if(!locked) { if(vfo[id].ctun) { - saved_freq=vfo[id].ctun_frequency; - diff=f-vfo[id].ctun_frequency; + delta=vfo[id].ctun_frequency; vfo[id].ctun_frequency=f; if(vfo[id].mode==modeCWL) { vfo[id].ctun_frequency+=cw_keyer_sidetone_frequency; - diff+=cw_keyer_sidetone_frequency; } else if(vfo[id].mode==modeCWU) { vfo[id].ctun_frequency-=cw_keyer_sidetone_frequency; - diff-=cw_keyer_sidetone_frequency; } + delta=vfo[id].ctun_frequency - delta; } else { - saved_freq=vfo[id].frequency; - diff=f-vfo[id].frequency; + delta=vfo[id].frequency; vfo[id].frequency=f; if(vfo[id].mode==modeCWL) { vfo[id].frequency+=cw_keyer_sidetone_frequency; - diff+=cw_keyer_sidetone_frequency; } else if(vfo[id].mode==modeCWU) { vfo[id].frequency-=cw_keyer_sidetone_frequency; - diff-=cw_keyer_sidetone_frequency; } + delta = vfo[id].frequency - delta; } -//g_print("vfo_move_to: id=%d ctun=%d hz=%lld sat_mode=%d freq=%lld to %lld\n",id,vfo[id].ctun,hz,sat_mode,saved_freq,vfo[id].ctun?vfo[id].ctun_frequency:vfo[id].frequency); - int sid=id==0?1:0; switch(sat_mode) { case SAT_NONE: break; case SAT_MODE: - f=vfo[sid].frequency-half+offset; // A and B increment and decrement together - if(vfo[sid].ctun) { - vfo[sid].ctun_frequency+=diff; + if (vfo[sid].ctun) { + vfo[sid].ctun_frequency += delta; } else { - vfo[sid].frequency+=diff; - } - if(vfo[id].mode!=modeCWL && vfo[id].mode!=modeCWU) { - vfo[sid].frequency=vfo[sid].frequency/step*step; + vfo[sid].frequency += delta; } break; case RSAT_MODE: - f=vfo[sid].frequency+half-offset; // A increments and B decrements or A decrements and B increments - if(vfo[sid].ctun) { - vfo[sid].ctun_frequency-=diff; + if (vfo[sid].ctun) { + vfo[sid].ctun_frequency -= delta; } else { - vfo[sid].frequency-=diff; - } - if(vfo[id].mode!=modeCWL && vfo[id].mode!=modeCWU) { - vfo[sid].frequency=vfo[sid].frequency/step*step; + vfo[sid].frequency -= delta; } break; } -- 2.45.2