From: Ramakrishnan Muthukrishnan <ram@leastauthority.com>
Date: Mon, 21 Feb 2022 12:18:08 +0000 (+0530)
Subject: fixes to get CW working
X-Git-Url: https://git.rkrishnan.org/pf/vdrive/(%5B%5E?a=commitdiff_plain;h=1d3920188ad4461863b9834473cec5bd11724f77;p=pihpsdr.git

fixes to get CW working
---

diff --git a/gpio.c b/gpio.c
index e5afe7e..6bb2132 100644
--- a/gpio.c
+++ b/gpio.c
@@ -518,7 +518,7 @@ static void process_edge(int offset,int value) {
       keyer_event(1, CW_ACTIVE_LOW ? (value==PRESSED) : value);
       found=TRUE;
     } else if(offset==CWR_BUTTON) {
-      keyer_event(1, CW_ACTIVE_LOW ? (value==PRESSED) : value);
+      keyer_event(0, CW_ACTIVE_LOW ? (value==PRESSED) : value);
       found=TRUE;
     }
   }
@@ -977,6 +977,20 @@ int gpio_init() {
     goto err;
   }
 
+
+#ifdef LOCALCW
+	if(controller == NO_CONTROLLER) {
+		// radioberry plugged into the RPI
+		// GPIO is on only for LOCALCW.
+		// Users do have to choose for no controller;
+		// for local CW the following pins are set.
+		CWL_BUTTON=17;
+		CWR_BUTTON=21;
+		g_print("LOCALCW is on ; NO controller selected; CW Buttons reconfigured\n");
+	}
+	// Radioberry device driver uses GPIO ports.
+	if(controller != NO_CONTROLLER) {
+#endif
   // setup encoders
   g_print("%s: setup encoders\n",__FUNCTION__);
   for(int i=0;i<MAX_ENCODERS;i++) {
@@ -1014,6 +1028,9 @@ int gpio_init() {
       }
     }
   }
+#ifdef LOCALCW
+}
+#endif
 
   if(controller==CONTROLLER2_V1 || controller==CONTROLLER2_V2) {
     i2c_init();