]> git.rkrishnan.org Git - pihpsdr.git/commitdiff
fixes
authorc vw <dl1ycf@darc.de>
Wed, 4 Dec 2019 16:03:18 +0000 (17:03 +0100)
committerc vw <dl1ycf@darc.de>
Wed, 4 Dec 2019 16:03:18 +0000 (17:03 +0100)
new_protocol.c
old_protocol.c
radio.c
rx_menu.c
transmitter.c
tx_menu.c
vfo.c

index 607e6f097c0c113db658556ef6da856d60c1c370..4fe00bbf6a5876e595c3bdc76a41f453137af9e4 100644 (file)
@@ -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;i<MIC_SAMPLES;i++) {
     sample=(short)(mic_line_buffer[b++]<<8);
     sample |= (short) (mic_line_buffer[b++]&0xFF);
+    fsample = (float) sample * 0.00003051;
 #ifdef FREEDV
     if(active_receiver->freedv) {
-      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
index 4b407fddb64bcbbbca543a361a7d2a73dce124d7..035b30bc713922f8b301aaa4cd4ba90e88fcc495 100644 (file)
@@ -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 3bfbd56e1ee8b7f4fd1ca0b80b9b807f8f23abe7..0c2bb0fb769f0ecfa9b87651e8eefec0652a2f79 100644 (file)
--- 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)) {
index 42b9d64c0ddc0bc9670c94585d177e4a07316616..c9fd9380016f4faf7d987da0011b6c7b61af51a1 100644 (file)
--- 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);
 
index 6f01908f6a9480744808df140ef84db5247b688b..4f5f9a38d392fde0dd9deac872dbe0d30b1bf626 100644 (file)
@@ -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;
       }
     }
 
index 3848c043674cd488fc5e9d736bb74f976dc89bfd..8248c30657b0c49d0d0d197ffae86e510ca53737 100644 (file)
--- 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 6aacdc5349041359f060de0763a422a8113a4d55..a1e783ecbcddd193da4b2e403e4a2c4efbb24f75 100644 (file)
--- 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;
     }