From b522d0df6f3e333cd60d02c45ab3514cc06c6d74 Mon Sep 17 00:00:00 2001
From: John Melton G0ORX <john.d.melton@googlemail.com>
Date: Tue, 3 Mar 2020 10:52:16 +0000
Subject: [PATCH] For controller2v2 set ENABLE_CW_BUTTONS to 0 because of clash
 of Wpi14

---
 gpio.c | 41 +++++++++++++++++++++--------------------
 1 file changed, 21 insertions(+), 20 deletions(-)

diff --git a/gpio.c b/gpio.c
index 703774b..be0389f 100644
--- a/gpio.c
+++ b/gpio.c
@@ -761,10 +761,8 @@ static void e4EncoderInt() {
   int levelB=digitalRead(E4_ENCODER_B);
 
   if(levelA!=e4CurrentA) {
-    //if(levelA==levelB) ++e4EncoderPos;
-    //if(levelA!=levelB) --e4EncoderPos;
-    if(levelA==levelB) --e4EncoderPos;
-    if(levelA!=levelB) ++e4EncoderPos;
+    if(levelA==levelB) ++e4EncoderPos;
+    if(levelA!=levelB) --e4EncoderPos;
     e4CurrentA=levelA;
   }
 }
@@ -1191,18 +1189,18 @@ void gpio_restore_state() {
   if(value) E5_FUNCTION=atoi(value);
 
 #ifdef LOCALCW		
- value=getProperty("ENABLE_CW_BUTTONS");		
- if(value) ENABLE_CW_BUTTONS=atoi(value);		
- value=getProperty("CW_ACTIVE_LOW");		
- if(value) CW_ACTIVE_LOW=atoi(value);		
- value=getProperty("CWL_BUTTON");		
- if(value) CWL_BUTTON=atoi(value);		
- value=getProperty("CWR_BUTTON");		
- if(value) CWR_BUTTON=atoi(value);		
- value=getProperty("SIDETONE_GPIO");		
- if(value) SIDETONE_GPIO=atoi(value);		
- value=getProperty("ENABLE_GPIO_SIDETONE");		
- if(value) ENABLE_GPIO_SIDETONE=atoi(value);		
+  value=getProperty("ENABLE_CW_BUTTONS");		
+  if(value) ENABLE_CW_BUTTONS=atoi(value);		
+  value=getProperty("CW_ACTIVE_LOW");		
+  if(value) CW_ACTIVE_LOW=atoi(value);		
+  value=getProperty("CWL_BUTTON");		
+  if(value) CWL_BUTTON=atoi(value);		
+  value=getProperty("CWR_BUTTON");		
+  if(value) CWR_BUTTON=atoi(value);		
+  value=getProperty("SIDETONE_GPIO");		
+  if(value) SIDETONE_GPIO=atoi(value);		
+  value=getProperty("ENABLE_GPIO_SIDETONE");		
+  if(value) ENABLE_GPIO_SIDETONE=atoi(value);		
 #endif
 
   if(controller!=CONTROLLER1) {
@@ -1219,6 +1217,11 @@ void gpio_restore_state() {
  
   }
 
+  if(controller==CONTROLLER2_V2) {
+    // turn off as clash of use of pin 14 (WPi)
+    ENABLE_CW_BUTTONS=0;
+  }
+
 
 }
 
@@ -1535,10 +1538,8 @@ int gpio_init() {
   if(ENABLE_E4_ENCODER) {
     setup_pin(E4_FUNCTION, PUD_UP, &e4FunctionAlert);
 	  
-    //setup_encoder_pin(E4_ENCODER_A,ENABLE_E4_PULLUP?PUD_UP:PUD_OFF,&e4EncoderInt);
-    //setup_encoder_pin(E4_ENCODER_B,ENABLE_E4_PULLUP?PUD_UP:PUD_OFF,NULL);
-    setup_encoder_pin(E4_ENCODER_A,ENABLE_E4_PULLUP?PUD_UP:PUD_OFF,NULL);
-    setup_encoder_pin(E4_ENCODER_B,ENABLE_E4_PULLUP?PUD_UP:PUD_OFF,&e4EncoderInt);
+    setup_encoder_pin(E4_ENCODER_A,ENABLE_E4_PULLUP?PUD_UP:PUD_OFF,&e4EncoderInt);
+    setup_encoder_pin(E4_ENCODER_B,ENABLE_E4_PULLUP?PUD_UP:PUD_OFF,NULL);
     e4EncoderPos=0;
 	  
     if(controller==CONTROLLER2_V2) {
-- 
2.45.2