From 36eccef83811c2f55986f181b5a72e1f985a42e9 Mon Sep 17 00:00:00 2001
From: John Melton - G0ORX/N6LYT <john.d.melton@googlemail.com>
Date: Wed, 22 Feb 2017 16:58:52 +0000
Subject: [PATCH] Fixed VFO bug not changing to RED when VOX active. Fixed bug
 when RIT+ and RIT- pressed together.

---
 new_protocol.h |  1 -
 radio.c        |  2 +-
 toolbar.c      | 27 +++++++++++++++++++++------
 3 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/new_protocol.h b/new_protocol.h
index daf8228..ee0d0cc 100644
--- a/new_protocol.h
+++ b/new_protocol.h
@@ -87,7 +87,6 @@ void setMox(int state);
 int getMox();
 void setTune(int state);
 int getTune();
-int isTransmitting();
 
 extern void new_protocol_process_local_mic(unsigned char *buffer,int le);
 extern void new_protocol_audio_samples(RECEIVER *rx,short left_audio_sample,short right_audio_sample);
diff --git a/radio.c b/radio.c
index 3dc6289..d0ec898 100644
--- a/radio.c
+++ b/radio.c
@@ -632,11 +632,11 @@ int getMox() {
 }
 
 void setVox(int state) {
-fprintf(stderr,"setVox: vox=%d state=%d\n",vox,state);
   if(vox!=state && !tune) {
     vox=state;
     rxtx(state);
   }
+  g_idle_add(vfo_update,(gpointer)NULL);
 }
 
 int vox_changed(void *data) {
diff --git a/toolbar.c b/toolbar.c
index be245ba..1826027 100644
--- a/toolbar.c
+++ b/toolbar.c
@@ -76,7 +76,8 @@ static GtkWidget *last_filter;
 static GdkRGBA white;
 static GdkRGBA gray;
 
-static gint rit_timer;
+static gint rit_plus_timer=-1;
+static gint rit_minus_timer=-1;
 
 static gboolean rit_timer_cb(gpointer data) {
   int i=(int)data;
@@ -227,7 +228,11 @@ static void rit_cb(GtkWidget *widget, gpointer data) {
   if(vfo[active_receiver->id].rit>1000) vfo[active_receiver->id].rit=1000;
   if(vfo[active_receiver->id].rit<-1000) vfo[active_receiver->id].rit=-1000;
   vfo_update(NULL);
-  rit_timer=g_timeout_add(200,rit_timer_cb,(void *)i);
+  if(i<0) {
+    rit_minus_timer=g_timeout_add(200,rit_timer_cb,(void *)i);
+  } else {
+    rit_plus_timer=g_timeout_add(200,rit_timer_cb,(void *)i);
+  }
 }
 
 static void rit_clear_cb(GtkWidget *widget, gpointer data) {
@@ -729,7 +734,9 @@ void sim_s4_pressed_cb(GtkWidget *widget, gpointer data) {
       btoa_cb(widget,data);
       break;
     case 2:
-      rit_cb(widget,(void *)1);
+      if(rit_minus_timer==-1 && rit_plus_timer==-1) {
+        rit_cb(widget,(void *)1);
+      }
       break;
     case 3:
       break;
@@ -743,7 +750,10 @@ void sim_s4_released_cb(GtkWidget *widget, gpointer data) {
     case 1:
       break;
     case 2:
-      g_source_remove(rit_timer);
+      if(rit_plus_timer!=-1) {
+        g_source_remove(rit_plus_timer);
+        rit_plus_timer=-1;
+      }
       break;
     case 3:
       break;
@@ -760,7 +770,9 @@ void sim_s5_pressed_cb(GtkWidget *widget, gpointer data) {
       aswapb_cb(widget,data);
       break;
     case 2:
-      rit_cb(widget,(void *)-1);
+      if(rit_minus_timer==-1 && rit_plus_timer==-1) {
+        rit_cb(widget,(void *)-1);
+      }
       break;
     case 3:
       break;
@@ -774,7 +786,10 @@ void sim_s5_released_cb(GtkWidget *widget, gpointer data) {
     case 1:
       break;
     case 2:
-      g_source_remove(rit_timer);
+      if(rit_minus_timer!=-1) {
+        g_source_remove(rit_minus_timer);
+        rit_minus_timer=-1;
+      }
       break;
     case 3:
       break;
-- 
2.45.2