]> git.rkrishnan.org Git - pihpsdr.git/commitdiff
added Out of band warning whentrying to transmit out of band
authorJohn Melton - G0ORX/N6LYT <john.d.melton@googlemail.com>
Sun, 19 Feb 2017 11:12:20 +0000 (11:12 +0000)
committerJohn Melton - G0ORX/N6LYT <john.d.melton@googlemail.com>
Sun, 19 Feb 2017 11:12:20 +0000 (11:12 +0000)
radio.c
toolbar.c
transmitter.c
transmitter.h
vfo.c

diff --git a/radio.c b/radio.c
index 8bd18552c64e82bf0978c28379121feeec5bc953..3dc6289a96f961cb9c8830a6456381af4de514a9 100644 (file)
--- a/radio.c
+++ b/radio.c
@@ -616,6 +616,7 @@ fprintf(stderr,"rxtx: state=%d\n",state);
 }
 
 void setMox(int state) {
+fprintf(stderr,"setMox: %d\n",state);
   if(mox!=state) {
     mox=state;
     if(vox_enabled && vox) {
index 43ec78f3e944488f59b26ab04459acab1933a6e2..be245ba1019e779dfae951b8db5deb14d1ba0322 100644 (file)
--- a/toolbar.c
+++ b/toolbar.c
@@ -39,6 +39,7 @@
 #include "wdsp.h"
 #include "radio.h"
 #include "receiver.h"
+#include "transmitter.h"
 #include "property.h"
 #include "new_menu.h"
 #include "button_text.h"
@@ -550,6 +551,8 @@ void lock_cb(GtkWidget *widget, gpointer data) {
 }
 
 void mox_cb(GtkWidget *widget, gpointer data) {
+
+fprintf(stderr,"mox_cb: mox=%d\n",mox);
   if(getTune()==1) {
     setTune(0);
   }
@@ -560,15 +563,27 @@ void mox_cb(GtkWidget *widget, gpointer data) {
     }
   } else if(canTransmit() || tx_out_of_band) {
     setMox(1);
+  } else {
+    transmitter_set_out_of_band(transmitter);
   }
   g_idle_add(vfo_update,NULL);
 }
 
 int mox_update(void *data) {
+  int state=(int)data;
   if(getTune()==1) {
     setTune(0);
   }
-  setMox((int)data);
+  if(state) {
+    if(canTransmit() || tx_out_of_band) {
+      setMox(state);
+    } else {
+      transmitter_set_out_of_band(transmitter);
+    }
+  } else {
+    setMox(state);
+  }
+  g_idle_add(vfo_update,NULL);
   return 0;
 }
 
@@ -582,6 +597,7 @@ int ptt_update(void *data) {
   if(protocol==NEW_PROTOCOL || (mode!=modeCWU && mode!=modeCWL)) {
     mox_cb(NULL,NULL);
   }
+  g_idle_add(vfo_update,NULL);
   return 0;
 }
 
@@ -593,6 +609,8 @@ void tune_cb(GtkWidget *widget, gpointer data) {
     setTune(0);
   } else if(canTransmit() || tx_out_of_band) {
     setTune(1);
+  } else {
+    transmitter_set_out_of_band(transmitter);
   }
   vfo_update(NULL);
 }
index 0a161d34c60e1e20a740daaab60089824c7a4eaf..51c8264bce79d3b2159f75760952e71916b3c6b7 100644 (file)
 static int filterLow;
 static int filterHigh;
 
+static gint update_out_of_band(gpointer data) {
+  TRANSMITTER *tx=(TRANSMITTER *)data;
+  tx->out_of_band=0;
+  vfo_update(NULL);
+  return FALSE;
+}
+
+void transmitter_set_out_of_band(TRANSMITTER *tx) {
+  tx->out_of_band=1;
+  tx->out_of_band_timer_id=gdk_threads_add_timeout_full(G_PRIORITY_HIGH_IDLE,1000,update_out_of_band, tx, NULL);
+}
+
 void reconfigure_transmitter(TRANSMITTER *tx,int height) {
   gtk_widget_set_size_request(tx->panadapter, tx->width, height);
 }
@@ -361,6 +373,8 @@ fprintf(stderr,"create_transmitter: id=%d buffer_size=%d mic_sample_rate=%d mic_
   tx->filter_low=tx_filter_low;
   tx->filter_high=tx_filter_high;
 
+  tx->out_of_band=0;
+
   transmitter_restore_state(tx);
 
   if(split) {
index fec966d364210c96bf97d57b3121d7c482ee1c26..c4eeda2cfb7644f4ace9b76b20304a74f504764d 100644 (file)
@@ -70,6 +70,9 @@ typedef struct _transmitter {
   int local_microphone;
   int input_device;
 
+  int out_of_band;
+  gint out_of_band_timer_id;
+
 } TRANSMITTER;
 
 extern TRANSMITTER *create_transmitter(int id, int buffer_size, int fft_size, int fps, int width, int height);
@@ -83,4 +86,5 @@ extern void tx_set_pre_emphasize(TRANSMITTER *tx,int state);
 extern void add_mic_sample(TRANSMITTER *tx,short mic_sample);
 
 extern void transmitter_save_state(TRANSMITTER *tx);
+extern void transmitter_set_out_of_band(TRANSMITTER *tx);
 #endif
diff --git a/vfo.c b/vfo.c
index e45e1526cb2a2b1ae9662dff2ae866865acf252e..b73484a1d622f8258cc58a74134650d9e75af09f 100644 (file)
--- a/vfo.c
+++ b/vfo.c
@@ -618,33 +618,42 @@ int vfo_update(void *data) {
         cairo_move_to(cr, 5, 15);  
         cairo_show_text(cr, text);
 
-        //long long af=active_receiver->frequency+active_receiver->dds_offset;
         long long af=vfo[0].frequency+vfo[0].offset;
-        sprintf(temp_text,"VFO A: %0lld.%06lld",af/(long long)1000000,af%(long long)1000000);
-        if(isTransmitting() && !split) {
-            cairo_set_source_rgb(cr, 1, 0, 0);
+        if(transmitter->out_of_band && !split) {
+          cairo_set_source_rgb(cr, 1, 0, 0);
+          sprintf(temp_text,"VFO A: Out of band");
         } else {
-            if(active_receiver->id==0) {
-              cairo_set_source_rgb(cr, 0, 1, 0);
-            } else {
-              cairo_set_source_rgb(cr, 0, 0.65, 0);
-            }
+          sprintf(temp_text,"VFO A: %0lld.%06lld",af/(long long)1000000,af%(long long)1000000);
+          if(isTransmitting() && !split) {
+              cairo_set_source_rgb(cr, 1, 0, 0);
+          } else {
+              if(active_receiver->id==0) {
+                cairo_set_source_rgb(cr, 0, 1, 0);
+              } else {
+                cairo_set_source_rgb(cr, 0, 0.65, 0);
+              }
+          }
         }
         cairo_move_to(cr, 5, 38);  
         cairo_set_font_size(cr, 22); 
         cairo_show_text(cr, temp_text);
 
-        //long long bf=frequencyB;
+
         long long bf=vfo[1].frequency+vfo[1].offset;
-        sprintf(temp_text,"VFO B: %0lld.%06lld",bf/(long long)1000000,bf%(long long)1000000);
-        if(isTransmitting() && split) {
-            cairo_set_source_rgb(cr, 1, 0, 0);
+        if(transmitter->out_of_band && split) {
+          cairo_set_source_rgb(cr, 1, 0, 0);
+          sprintf(temp_text,"VFO B: Out of band");
         } else {
-            if(active_receiver->id==1) {
-              cairo_set_source_rgb(cr, 0, 1, 0);
-            } else {
-              cairo_set_source_rgb(cr, 0, 0.65, 0);
-            }
+          sprintf(temp_text,"VFO B: %0lld.%06lld",bf/(long long)1000000,bf%(long long)1000000);
+          if(isTransmitting() && split) {
+              cairo_set_source_rgb(cr, 1, 0, 0);
+          } else {
+              if(active_receiver->id==1) {
+                cairo_set_source_rgb(cr, 0, 1, 0);
+              } else {
+                cairo_set_source_rgb(cr, 0, 0.65, 0);
+              }
+          }
         }
         cairo_move_to(cr, 260, 38);  
         cairo_show_text(cr, temp_text);