From: c vw <dl1ycf@darc.de>
Date: Mon, 18 Nov 2019 15:28:39 +0000 (+0100)
Subject: Added MIDI action "VOXLEVEL"
X-Git-Url: https://git.rkrishnan.org/components/frontends/FOOURL?a=commitdiff_plain;h=c2651a830dd3aefece88530620840d60a5086b2b;p=pihpsdr.git

Added MIDI action "VOXLEVEL"
---

diff --git a/midi.h b/midi.h
index f84fde8..8d10ab9 100644
--- a/midi.h
+++ b/midi.h
@@ -91,6 +91,7 @@ enum MIDIaction {
   VFO_STEP_UP,		// VFOSTEPUP:		cycle through vfo steps upwards;
   VFO_STEP_DOWN,	// VFOSTEPDOWN:		cycle through vfo steps downwards;
   VOX, 			// VOX:			toggle VOX on/off
+  VOXLEVEL, 		// VOXLEVEL:		adjust VOX threshold
   MIDI_XIT_CLEAR,	// XITCLEAR:		clear XIT value
   XIT_VAL,		// XITVAL:		change XIT value
 };
diff --git a/midi2.c b/midi2.c
index c29024a..e1ba495 100644
--- a/midi2.c
+++ b/midi2.c
@@ -144,6 +144,7 @@ static struct {
 	{ VFO_STEP_UP,  	"VFOSTEPUP"},
 	{ VFO_STEP_DOWN,	"VFOSTEPDOWN"},
 	{ VOX,   		"VOX"},
+	{ VOXLEVEL,   		"VOXLEVEL"},
 	{ MIDI_XIT_CLEAR,  	"XITCLEAR"},
 	{ XIT_VAL,  		"XITVAL"},
         { ACTION_NONE,  	"NONE"},
diff --git a/midi3.c b/midi3.c
index f2c9409..80dc87e 100644
--- a/midi3.c
+++ b/midi3.c
@@ -630,6 +630,26 @@ void DoTheMidi(enum MIDIaction action, enum MIDItype type, int val) {
 	      g_idle_add(ext_vfo_update, NULL);
 	    }
 	    break;
+	/////////////////////////////////////////////////////////// "VOXLEVEL"
+	case VOXLEVEL: // knob or wheel supported
+            switch (type) {
+              case MIDI_WHEEL:
+                // This changes the value incrementally,
+                // but stay within limits (0.0 through 1.0)
+                vox_threshold += (double) val * 0.01;
+		if (vox_threshold > 1.0) vox_threshold=1.0;
+		if (vox_threshold < 0.0) vox_threshold=0.0;
+                break;
+              case MIDI_KNOB:
+                vox_threshold = 0.01 * (double) val;
+                break;
+              default:
+                // do nothing
+                // we should not come here anyway
+                break;
+            }
+	    // VOX level not shown on screen, hence no VFO update
+	    break;
 	/////////////////////////////////////////////////////////// "XITCLEAR"
         case MIDI_XIT_CLEAR:  // only key supported
             if (type == MIDI_KEY) {