]> git.rkrishnan.org Git - pihpsdr.git/commitdiff
Added VFOA/VFOB support to MIDI
authorc vw <dl1ycf@darc.de>
Wed, 23 Oct 2019 15:07:37 +0000 (17:07 +0200)
committerc vw <dl1ycf@darc.de>
Wed, 23 Oct 2019 15:07:37 +0000 (17:07 +0200)
ext.c
ext.h
midi.h
midi2.c
midi3.c
vfo.c
vfo.h

diff --git a/ext.c b/ext.c
index 0d68f255f8625a99e03c15cd1f62b6c125f92363..1cb1802d9827db6bc20a57fc8ea989e6fe2fef2c 100644 (file)
--- a/ext.c
+++ b/ext.c
@@ -200,6 +200,15 @@ int ext_vfo_step(void *data) {
   return 0;
 }
 
+int ext_vfo_id_step(void *data) {
+  int *ip=(int *) data;
+  int id=ip[0];
+  int step=ip[1];
+  vfo_id_step(id,step);
+  free(data);
+  return 0;
+}
+
 int ext_set_mic_gain(void * data) {
   double d=*(double *)data;
   set_mic_gain(d);
@@ -500,5 +509,6 @@ int ext_function_update(void *data) {
   }
   update_toolbar_labels();
   vfo_update();
+  return 0;
 }
 
diff --git a/ext.h b/ext.h
index ac995554b6d83fd2f24b1b82cf5dae61c7419fe5..bc93cf2af6aeb31e11e4e0a4c1a054ed8a384a2b 100644 (file)
--- a/ext.h
+++ b/ext.h
@@ -86,6 +86,7 @@ extern int ext_tx_set_ps(void *data);
 #endif
 
 int ext_vfo_step(void *data);
+int ext_vfo_id_step(void *data);
 int ext_vfo_mode_changed(void *data);
 int ext_set_af_gain(void *data);
 int ext_set_mic_gain(void *data);
diff --git a/midi.h b/midi.h
index e21cab2f609a64d28a3779e97f351e0a9af0076a..3c9e8b0d8befce989ea87f3a0338703be7a30607 100644 (file)
--- a/midi.h
+++ b/midi.h
@@ -76,6 +76,8 @@ enum MIDIaction {
   MIDI_TUNE,                   // toggle "tune" state
   TX_DRIVE,            // RF output power
   VFO,                 // change VFO frequency
+  VFOA,                        // change VFO-A frequency
+  VFOB,                        // change VFO-B frequency
   VFO_A2B,             // VFO A -> B
   VFO_B2A,             // VFO B -> A
   VOX                  // VOX on/off
diff --git a/midi2.c b/midi2.c
index c8f81f97a341141472c7cc60675bf738bff19d3b..3ac2eceb14fd779b4c330faa879c80dd95078a7b 100644 (file)
--- a/midi2.c
+++ b/midi2.c
@@ -119,6 +119,8 @@ static struct {
         { MIDI_TUNE,    "TUNE"},
         { TX_DRIVE,     "RFPOWER"},
         { VFO,          "VFO"},
+        { VFOA,         "VFOA"},
+        { VFOB,         "VFOB"},
        { VFO_A2B,      "VFOA2B"},
        { VFO_B2A,      "VFOB2A"},
        { VOX,          "VOX"},
diff --git a/midi3.c b/midi3.c
index 7bb8f0ccf272a192cdc90cc6667f94215269e6a9..87f42133682035f5db432ccbf402572fa7d179c4 100644 (file)
--- a/midi3.c
+++ b/midi3.c
@@ -28,6 +28,7 @@ void DoTheMidi(enum MIDIaction action, enum MIDItype type, int val) {
     int new;
     double dnew;
     double *dp;
+    int    *ip;
 
     switch (action) {
        case SWAP_VFO:  // only key supported
@@ -40,6 +41,15 @@ void DoTheMidi(enum MIDIaction action, enum MIDItype type, int val) {
                g_idle_add(ext_vfo_step, GINT_TO_POINTER(val));
            }
            break;
+       case VFOA: // only wheel supported
+       case VFOB: // only wheel supported
+           if (type == MIDI_WHEEL) {
+               ip=malloc(2*sizeof(int));
+               *ip = (action == VFOA) ? 0 : 1;   // could use (action - VFOA) to support even more VFOs
+               *(ip+1)=val;
+               g_idle_add(ext_vfo_id_step, ip);
+           }
+           break;
        case MIDI_TUNE: // only key supported
            if (type == MIDI_KEY) {
                new = !tune;
diff --git a/vfo.c b/vfo.c
index 006c4e4d23e65796571d918ba51c0cf556b5676f..3693531bbdb18427d46ae95a1585d8e1a8b3b49f 100644 (file)
--- a/vfo.c
+++ b/vfo.c
@@ -558,6 +558,26 @@ void vfo_step(int steps) {
     g_idle_add(ext_vfo_update,NULL);
   }
 }
+//
+// DL1YCF: essentially a duplicate of vfo_step but
+//         changing a specific VFO freq instead of
+//         changing the VFO of the active receiver
+//
+void vfo_id_step(int id, int steps) {
+  if(!locked) {
+    if(vfo[id].ctun) {
+      vfo[id].ctun_frequency=vfo[id].ctun_frequency+(steps*step);
+    } else {
+      vfo[id].frequency=vfo[id].frequency+(steps*step);
+    }
+    receiver_frequency_changed(active_receiver);
+#ifdef INCLUDED
+    BANDSTACK_ENTRY* entry=bandstack_entry_get_current();
+    setFrequency(active_receiver->frequency+(steps*step));
+#endif
+    g_idle_add(ext_vfo_update,NULL);
+  }
+}
 
 void vfo_move(long long hz) {
   int id=active_receiver->id;
diff --git a/vfo.h b/vfo.h
index c2218851e23eca3e2617e8ef6f77c1d5d97d638a..dc9a5cd694a6dfb4251773fd9c94b9b49d1a263a 100644 (file)
--- a/vfo.h
+++ b/vfo.h
@@ -65,6 +65,7 @@ extern char *step_labels[];
 
 extern GtkWidget* vfo_init(int width,int height,GtkWidget *parent);
 extern void vfo_step(int steps);
+extern void vfo_id_step(int id, int steps);
 extern void vfo_move(long long hz);
 extern void vfo_move_to(long long hz);
 extern void vfo_update();