From: c vw <dl1ycf@darc.de>
Date: Fri, 20 Dec 2019 15:42:21 +0000 (+0100)
Subject: a) renamed "midi.inp" to "midi.props"
X-Git-Url: https://git.rkrishnan.org/components/frontends/?a=commitdiff_plain;h=af5b3366143cc4c5a2801017c9eaeceb16b81ff6;p=pihpsdr.git

a) renamed "midi.inp" to "midi.props"
b) corrected "duplex" switching from toolbar and MIDI
---

diff --git a/Makefile.mac b/Makefile.mac
index 8b27c9c..63f3893 100644
--- a/Makefile.mac
+++ b/Makefile.mac
@@ -539,7 +539,7 @@ hpsdrsim:       hpsdrsim.o newhpsdrsim.o
 #	$HOME -> Application Support -> piHPSDR
 #
 #       That is the directory where the WDSP wisdom file (created upon first
-#       start of piHPSDR) but also the radio settings and the midi.inp file
+#       start of piHPSDR) but also the radio settings and the midi.props file
 #       are stored.
 #
 #############################################################################
diff --git a/discovery.c b/discovery.c
index 353c65e..d082983 100644
--- a/discovery.c
+++ b/discovery.c
@@ -103,7 +103,7 @@ static gboolean start_cb (GtkWidget *widget, GdkEventButton *event, gpointer dat
 #ifdef MIDI
 //
 // This is a file open dialog. If we choose a readable file here, it is just copied
-// to file "midi.inp" in the local directory
+// to file "midi.props" in the local directory
 //
 static gboolean midi_cb(GtkWidget *widget, GdkEventButton *event, gpointer data) {
     GtkWidget *opfile,*message;
@@ -135,7 +135,7 @@ static gboolean midi_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
         len=statbuf.st_size;
         //
         // Now first read the whole contents of the file, and then write it out.
-        // This is for new-bees trying to import the midi.inp in the working dir
+        // This is for new-bees trying to import the midi.props in the working dir
         //
         contents=g_new(char, len);
         bytes_read = bytes_written = 0;
@@ -148,8 +148,8 @@ static gboolean midi_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
       if (contents && bytes_read == len) {
 	// should this file exist as a link or symlink, or should it
 	// be read-only, remove it first
-	unlink("midi.inp");
-        fdout=open("midi.inp", O_WRONLY | O_CREAT, 0644);
+	unlink("midi.props");
+        fdout=open("midi.props", O_WRONLY | O_CREAT, 0644);
         if (fdout >= 0) {
           bytes_written=write(fdout, contents, len);
           close(fdout);
diff --git a/ext.c b/ext.c
index 0436735..57a3e25 100644
--- a/ext.c
+++ b/ext.c
@@ -30,6 +30,7 @@
 #include "diversity_menu.h"
 #include "vfo.h"
 #include "radio.h"
+#include "radio_menu.h"
 #include "new_menu.h"
 #include "new_protocol.h"
 #ifdef PURESIGNAL
@@ -617,3 +618,8 @@ int ext_update_noise(void *data) {
   update_noise();
   return 0;
 }
+
+int ext_set_duplex(void *data) {
+  setDuplex();
+  return 0;
+}
diff --git a/ext.h b/ext.h
index 6fe1858..f70c958 100644
--- a/ext.h
+++ b/ext.h
@@ -106,5 +106,6 @@ int ext_start_tx(void *data);
 int ext_diversity_update(void *data);
 int ext_sat_update(void *data);
 int ext_set_rf_gain(void *data);
+int ext_set_duplex(void *data);
 
 int ext_update_noise(void *data);
diff --git a/midi2.c b/midi2.c
index b698336..29788e2 100644
--- a/midi2.c
+++ b/midi2.c
@@ -90,7 +90,7 @@ void NewMidiEvent(enum MIDIevent event, int channel, int note, int val) {
 }
 
 /*
- * This data structre connects names as used in the midi.inp file with
+ * This data structre connects names as used in the midi.props file with
  * our MIDIaction enum values.
  * Take care that no key word is contained in another one!
  * Example: use "CURRVFO" not "VFO" otherwise there is possibly
@@ -152,7 +152,7 @@ static struct {
 };
 
 /*
- * Translation from keyword in midi.inp file to MIDIaction
+ * Translation from keyword in midi.props file to MIDIaction
  */
 
 static enum MIDIaction keyword2action(char *s) {
@@ -188,7 +188,7 @@ void MIDIstartup() {
     for (i=0; i<128; i++) MidiCommandsTable.desc[i]=NULL;
     MidiCommandsTable.pitch=NULL;
 
-    fpin=fopen("midi.inp", "r");
+    fpin=fopen("midi.props", "r");
     if (!fpin) return;
 
     for (;;) {
diff --git a/midi3.c b/midi3.c
index 505ea0d..b44947b 100644
--- a/midi3.c
+++ b/midi3.c
@@ -34,7 +34,7 @@ void DoTheMidi(enum MIDIaction action, enum MIDItype type, int val) {
     int    *ip;
 
     //
-    // Handle cases in alphabetical order of the key words in midi.inp
+    // Handle cases in alphabetical order of the key words in midi.props
     //
     switch (action) {
 	/////////////////////////////////////////////////////////// "A2B"
@@ -234,12 +234,10 @@ void DoTheMidi(enum MIDIaction action, enum MIDItype type, int val) {
 	    break;
 	/////////////////////////////////////////////////////////// "DUP"
         case MIDI_DUP:
-            if(duplex) {
-              duplex=0;
-            } else {
-              duplex=1;
-            }
-            g_idle_add(ext_vfo_update, NULL);
+	    if (can_transmit) {
+	      duplex=duplex==1?0:1;
+              g_idle_add(ext_set_duplex, NULL);
+	    }
             break;
 	/////////////////////////////////////////////////////////// "FILTERDOWN"
 	/////////////////////////////////////////////////////////// "FILTERUP"
@@ -331,7 +329,7 @@ void DoTheMidi(enum MIDIaction action, enum MIDItype type, int val) {
 	    break;
 	/////////////////////////////////////////////////////////// "MOX"
 	case MIDI_MOX: // only key supported
-	    if (type == MIDI_KEY) {
+	    if (type == MIDI_KEY && can_transmit) {
 	        new = !mox;
 		g_idle_add(ext_mox_update, GINT_TO_POINTER(new));
 	    }
@@ -613,7 +611,7 @@ void DoTheMidi(enum MIDIaction action, enum MIDItype type, int val) {
 	    break;    
 	/////////////////////////////////////////////////////////// "TUNE"
 	case MIDI_TUNE: // only key supported
-	    if (type == MIDI_KEY) {
+	    if (type == MIDI_KEY && can_transmit) {
 	        new = !tune;
 		g_idle_add(ext_tune_update, GINT_TO_POINTER(new));
 	    }
diff --git a/radio_menu.c b/radio_menu.c
index 71fc7cc..e982f1e 100644
--- a/radio_menu.c
+++ b/radio_menu.c
@@ -196,8 +196,10 @@ static void split_cb(GtkWidget *widget, gpointer data) {
   vfo_update();
 }
 
-static void duplex_cb(GtkWidget *widget, gpointer data) {
-  duplex=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
+//
+// call-able from outside, e.g. toolbar or MIDI
+//
+void setDuplex() {
   if(duplex) {
     gtk_container_remove(GTK_CONTAINER(fixed),transmitter->panel);
     reconfigure_transmitter(transmitter,display_width/4,display_height/2);
@@ -211,6 +213,11 @@ static void duplex_cb(GtkWidget *widget, gpointer data) {
   vfo_update();
 }
 
+static void duplex_cb(GtkWidget *widget, gpointer data) {
+  duplex=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
+  setDuplex();
+}
+
 static void sat_cb(GtkWidget *widget, gpointer data) {
   sat_mode=gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
   vfo_update();
diff --git a/radio_menu.h b/radio_menu.h
index bd43812..7af7eab 100644
--- a/radio_menu.h
+++ b/radio_menu.h
@@ -18,3 +18,4 @@
 */
 
 extern void radio_menu(GtkWidget *parent);
+extern void setDuplex(void);
diff --git a/toolbar.c b/toolbar.c
index 591fadd..e05648b 100644
--- a/toolbar.c
+++ b/toolbar.c
@@ -289,8 +289,8 @@ static void split_cb (GtkWidget *widget, gpointer data) {
 
 static void duplex_cb (GtkWidget *widget, gpointer data) {
   if(can_transmit) {
-    duplex=duplex==1?0:1;
-    g_idle_add(ext_vfo_update,NULL);
+    duplex=(duplex==1)?0:1;
+    g_idle_add(ext_set_duplex,NULL);
   }
 }