From: John Melton G0ORX <john.d.melton@googlemail.com>
Date: Sun, 27 Oct 2019 16:20:30 +0000 (+0000)
Subject: Added midi actions VFOSTEPUP and VFOSTEPDOWN to allow buttons to be used to change... 
X-Git-Url: https://git.rkrishnan.org/%5B/frontends/flags/%22doc.html/%22file://%22%3C?a=commitdiff_plain;h=9be68da492f7d060026648b2866c1504a744381c;p=pihpsdr.git

Added midi actions VFOSTEPUP and VFOSTEPDOWN to allow buttons to be used to change the vfo step rate up and down
---

diff --git a/ext.c b/ext.c
index 972e8da..ca80aeb 100644
--- a/ext.c
+++ b/ext.c
@@ -194,6 +194,31 @@ int ext_tx_set_ps(void *data) {
 }
 #endif
 
+int ext_update_vfo_step(void *data) {
+  int direction=GPOINTER_TO_INT(data);
+  int i=0;
+  while(steps[i]!=step && steps[i]!=0) {
+    i++;
+  }
+
+  if(steps[i]!=0) {
+    if(direction>0) {
+      i++;
+      if(steps[i]!=0) {
+        step=steps[i];
+        vfo_update();
+      }
+    } else {
+      i--;
+      if(i>=0) {
+        step=steps[i];
+        vfo_update();
+      }
+    }
+  }
+  return 0;
+}
+
 int ext_vfo_step(void *data) {
   int step=GPOINTER_TO_INT(data);
   vfo_step(step);
diff --git a/ext.h b/ext.h
index ac99555..a4a259d 100644
--- a/ext.h
+++ b/ext.h
@@ -85,6 +85,7 @@ extern int ext_function_update(void *data);
 extern int ext_tx_set_ps(void *data);
 #endif
 
+int ext_update_vfo_step(void *data);
 int ext_vfo_step(void *data);
 int ext_vfo_mode_changed(void *data);
 int ext_set_af_gain(void *data);
diff --git a/midi.h b/midi.h
index e21cab2..1f68f0c 100644
--- a/midi.h
+++ b/midi.h
@@ -78,7 +78,9 @@ enum MIDIaction {
   VFO,			// change VFO frequency
   VFO_A2B,		// VFO A -> B
   VFO_B2A,		// VFO B -> A
-  VOX 			// VOX on/off
+  VOX, 			// VOX on/off
+  VFO_STEP_UP,		// cycle through vfo steps upwards;
+  VFO_STEP_DOWN,	// cycle through vfo steps downwards;
 };
 
 //
diff --git a/midi2.c b/midi2.c
index c8f81f9..9b950e2 100644
--- a/midi2.c
+++ b/midi2.c
@@ -122,6 +122,8 @@ static struct {
 	{ VFO_A2B,	"VFOA2B"},
 	{ VFO_B2A,	"VFOB2A"},
 	{ VOX,   	"VOX"},
+	{ VFO_STEP_UP,  "VFOSTEPUP"},
+	{ VFO_STEP_DOWN,  "VFOSTEPDOWN"},
         { ACTION_NONE,  "NONE"},
         { ACTION_NONE,  NULL}
 };
diff --git a/midi3.c b/midi3.c
index 7bb8f0c..efa5361 100644
--- a/midi3.c
+++ b/midi3.c
@@ -334,6 +334,12 @@ void DoTheMidi(enum MIDIaction action, enum MIDItype type, int val) {
 	    active_receiver->agc=new;
 	    g_idle_add(ext_vfo_update, NULL);
 	    break;
+        case VFO_STEP_UP:
+	    g_idle_add(ext_update_vfo_step, GINT_TO_POINTER(1));
+            break;
+        case VFO_STEP_DOWN:
+	    g_idle_add(ext_update_vfo_step, GINT_TO_POINTER(-1));
+            break;
 	case ACTION_NONE:
 	    // No error message, this is the "official" action for un-used controller buttons.
 	    break;