From: c vw <dl1ycf@darc.de>
Date: Wed, 19 May 2021 13:46:27 +0000 (+0200)
Subject: Small changes to prepeare the "big merge"
X-Git-Url: https://git.rkrishnan.org/vdrive/%22file:/reliability?a=commitdiff_plain;h=8877071dceb49cd78ce42548f9f2f311a99fcf73;p=pihpsdr.git

Small changes to prepeare the "big merge"
---

diff --git a/agc_menu.c b/agc_menu.c
index 5670218..36e2caa 100644
--- a/agc_menu.c
+++ b/agc_menu.c
@@ -43,6 +43,7 @@ static void cleanup() {
     gtk_widget_destroy(dialog);
     dialog=NULL;
     sub_menu=NULL;
+    active_menu=NO_MENU;
   }
 }
 
diff --git a/band_menu.c b/band_menu.c
index 908dafc..7bbb472 100644
--- a/band_menu.c
+++ b/band_menu.c
@@ -32,7 +32,9 @@
 #include "receiver.h"
 #include "vfo.h"
 #include "button_text.h"
+#ifdef CLIENT_SERVER
 #include "client_server.h"
+#endif
 
 static GtkWidget *parent_window=NULL;
 
@@ -45,6 +47,7 @@ static void cleanup() {
     gtk_widget_destroy(dialog);
     dialog=NULL;
     sub_menu=NULL;
+    active_menu=NO_MENU;
   }
 }
 
@@ -112,7 +115,7 @@ void band_menu(GtkWidget *parent) {
   long long frequency_min=radio->frequency_min;
   long long frequency_max=radio->frequency_max;
 
-//g_print("band_menu: min=%lld max=%lld\n",frequency_min,frequency_max);
+  //g_print("band_menu: min=%lld max=%lld\n",frequency_min,frequency_max);
   j=0;
   for(i=0;i<BANDS+XVTRS;i++) {
     band=(BAND*)band_get_band(i);
diff --git a/bandstack_menu.c b/bandstack_menu.c
index 579360b..19152df 100644
--- a/bandstack_menu.c
+++ b/bandstack_menu.c
@@ -44,6 +44,7 @@ static void cleanup() {
     gtk_widget_destroy(dialog);
     dialog=NULL;
     sub_menu=NULL;
+    active_menu=NO_MENU;
   }
 }
 
diff --git a/display_menu.c b/display_menu.c
index 7dbf1e3..38aab90 100644
--- a/display_menu.c
+++ b/display_menu.c
@@ -24,6 +24,7 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "main.h"
 #include "new_menu.h"
 #include "display_menu.h"
 #include "channel.h"
diff --git a/filter_menu.c b/filter_menu.c
index 600b924..4654b03 100644
--- a/filter_menu.c
+++ b/filter_menu.c
@@ -44,6 +44,7 @@ static void cleanup() {
     gtk_widget_destroy(dialog);
     dialog=NULL;
     sub_menu=NULL;
+    active_menu=NO_MENU;
   }
 }
 
diff --git a/hpsdrsim.c b/hpsdrsim.c
index 58f1ea6..083bc22 100644
--- a/hpsdrsim.c
+++ b/hpsdrsim.c
@@ -532,7 +532,7 @@ int main(int argc, char *argv[])
                                   bp=buffer+16;  // skip 8 header and 8 SYNC/C&C bytes
 				  sum=0.0;
                                   for (j=0; j<126; j++) {
-					bp +=4;  / skip audio samples
+					bp +=4;  // skip audio samples
 					sample  = (int)((signed char) *bp++)<<8;
 					sample |= (int) ((signed char) *bp++ & 0xFF);
 					disample=(double) sample * 0.000030517578125;  // division by 32768
diff --git a/iambic.c b/iambic.c
index dadc20a..5f43c3c 100644
--- a/iambic.c
+++ b/iambic.c
@@ -177,6 +177,8 @@
  **************************************************************************************************************
  */
 
+#include <gtk/gtk.h>
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -240,30 +242,6 @@ extern int clock_nanosleep(clockid_t __clock_id, int __flags,
       struct timespec *__rem);
 #endif
 
-#ifndef GPIO
-//
-// Dummy functions if compiled without GPIO
-//
-int gpio_cw_sidetone_enabled() { return 0; }
-void gpio_cw_sidetone_set(int level) {}
-#endif
-
-static void keyer_straight_key(int state) {
-  //
-  // Interface for simple key-down action e.g. from a MIDI message
-  //
-  if (state != 0) {
-    cw_key_down=960000;  // max. 20 sec to protect hardware
-    cw_key_up=0;
-    cw_key_hit=1;
-    gpio_cw_sidetone_set(1);
-  } else {
-    cw_key_down=0;
-    cw_key_up=0;
-    gpio_cw_sidetone_set(0);
-  }
-}
-
 void keyer_update() {
     //
     // This function will take notice of changes in the following variables
@@ -368,10 +346,12 @@ static void* keyer_thread(void *arg) {
 	// If using GPIO side tone information, mute CW side tone
 	// as long as the keyer thread is active
 	//
+#ifdef GPIO
 	if (gpio_cw_sidetone_enabled()) {
 	  old_volume=cw_keyer_sidetone_volume;
 	  cw_keyer_sidetone_volume=0;
 	}
+#endif
 
 	//
 	// Normally the keyer will be used in "break-in" mode, that is, we switch to TX
@@ -457,7 +437,12 @@ static void* keyer_thread(void *arg) {
                     // If both paddles are pressed (should not happen), then
                     // the dash paddle wins.
                     if (*kdash) {                  // send manual dashes
-                      keyer_straight_key(1);       // do key down
+                      cw_key_down=960000;  // max. 20 sec to protect hardware
+                      cw_key_up=0;
+                      cw_key_hit=1;
+#ifdef GPIO
+                      gpio_cw_sidetone_set(1);
+#endif
                       key_state=STRAIGHT;
                     }
                 } else {
@@ -475,7 +460,11 @@ static void* keyer_thread(void *arg) {
 		// Wait for dash paddle being released in "straight key" mode.
                 //
                 if (! *kdash) {
-                  keyer_straight_key(0);   // key-up
+                  cw_key_down=0;
+                  cw_key_up=0;
+#ifdef GPIO
+                  gpio_cw_sidetone_set(0);
+#endif
                   key_state=CHECK;
                 }
                 break;
@@ -488,7 +477,9 @@ static void* keyer_thread(void *arg) {
                 dash_held = *kdash;
                 cw_key_down=dot_samples;
                 cw_key_up=dot_samples;
+#ifdef GPIO
                 gpio_cw_sidetone_set(1);
+#endif
                 key_state=SENDDOT;
                 break;
 
@@ -497,7 +488,9 @@ static void* keyer_thread(void *arg) {
                 // wait for dot being complete
                 //
                 if (cw_key_down == 0) {
+#ifdef GPIO
                   gpio_cw_sidetone_set(0);
+#endif
                   key_state=DOTDELAY;
                 }
                 break;
@@ -543,7 +536,9 @@ static void* keyer_thread(void *arg) {
 		dot_held = *kdot;  // remember if dot is still held at beginning of the dash
                 cw_key_down=dash_samples;
                 cw_key_up=dot_samples;
+#ifdef GPIO
                 gpio_cw_sidetone_set(1);
+#endif
                 key_state=SENDDASH;
                 break;
 
@@ -552,7 +547,9 @@ static void* keyer_thread(void *arg) {
                 // wait for dot being complete
                 //
                 if (cw_key_down == 0) {
+#ifdef GPIO
                   gpio_cw_sidetone_set(0);
+#endif
                   key_state=DASHDELAY;
                 }
                 break;
@@ -612,9 +609,11 @@ static void* keyer_thread(void *arg) {
 	//
 	// If we have reduced the side tone volume, restore it!
 	//
+#ifdef GPIO
 	if (gpio_cw_sidetone_enabled()) {
 	  cw_keyer_sidetone_volume = old_volume;
 	}
+#endif
 
     }
     fprintf(stderr,"keyer_thread: EXIT\n");
diff --git a/mode_menu.c b/mode_menu.c
index 7f5e910..b992d82 100644
--- a/mode_menu.c
+++ b/mode_menu.c
@@ -45,6 +45,7 @@ static void cleanup() {
     gtk_widget_destroy(dialog);
     dialog=NULL;
     sub_menu=NULL;
+    active_menu=NO_MENU;
   }
 }
 
diff --git a/newhpsdrsim.c b/newhpsdrsim.c
index ed6244c..f20823a 100644
--- a/newhpsdrsim.c
+++ b/newhpsdrsim.c
@@ -1177,14 +1177,7 @@ void *audio_thread(void *data) {
      if (seqnum != 0 &&seqnum != seqold+1 ) {
        fprintf(stderr,"Audio thread: SEQ ERROR, old=%lu new=%lu\n", seqold, seqnum);
      }
-     p=buffer+4;
-     for (i=0; i<64; i++) {
-       lsample  = ((signed char) *p++) << 8;	
-       lsample |= (*p++ & 0xff); 
-       rsample  = ((signed char) *p++) << 8;	
-       rsample |= (*p++ & 0xff); 
-       audio_write(lsample,rsample);
-    }
+     // just skip the audio samples
   }
   close (sock);
   return NULL;
diff --git a/vfo.h b/vfo.h
index a479d17..f380cce 100644
--- a/vfo.h
+++ b/vfo.h
@@ -45,7 +45,8 @@ struct _vfo {
   long long offset;
 
   gboolean entering_frequency;
-  long long entered_frequency;
+  gint64 entered_frequency;
+
 };
 
 extern struct _vfo vfo[MAX_VFOS];