Charles Young's development fork. Going forward I only want to push mature code to main repository.

Dependencies:   mbed

Fork of GEO_COUNTER_L432KC by Geo Electronics "Geo Counter"

Revision:
38:1642320d83a0
Parent:
36:7fc5487bcc22
Child:
42:204c99cf3fde
--- a/RotarySwitch.cpp	Thu Sep 06 05:45:01 2018 -0700
+++ b/RotarySwitch.cpp	Thu Sep 06 10:03:01 2018 -0700
@@ -13,6 +13,7 @@
 RotarySwitch::RotarySwitch()
 {
    LED_status_index = 0;
+   LED_status_reported = LED_status_index;
    WheelCurrent = 0;
    WheelPrevious = 0;
    QEPBpressed = false;
@@ -24,7 +25,7 @@
 
 int RotarySwitch::GetPosition(void)
 {
-   return LED_status_index;
+   return LED_status_reported;
 }
 
 //---------------------------------------------------------------------------
@@ -91,19 +92,25 @@
    if (   (WHEEL_MODE_SELECT    == currentWheelState)
        || (WHEEL_SUBMODE_SELECT == currentWheelState))
    {
-        if (WheelCurrent > WheelPrevious)
-        {
-           if (WHEEL_MODE_SELECT == currentWheelState)
-              LED_status_index = ++LED_status_index % LED_status_index_size;
-           direction = 1;
-        }
-        else
-            if (WheelCurrent < WheelPrevious)
-            {
-               if (WHEEL_MODE_SELECT == currentWheelState)
-                  LED_status_index = --LED_status_index % LED_status_index_size;
+      if (WheelCurrent > WheelPrevious)
+      {
+         if (WHEEL_MODE_SELECT == currentWheelState)
+            LED_status_index = ++LED_status_index % LED_status_index_size;
+         else
+            direction = 1;
+      }
+      else
+         if (WheelCurrent < WheelPrevious)
+         {
+            if (WHEEL_MODE_SELECT == currentWheelState)
+               LED_status_index = --LED_status_index % LED_status_index_size;
+            else
                direction = -1;
-            }
+         }
+
+      // only report back mode once selected
+      if (WHEEL_SUBMODE_SELECT == currentWheelState)
+         LED_status_reported = LED_status_index;
 
      // Keep resetting WheelStateTimer as long as wheel is moving
      if (WheelPrevious != WheelCurrent)