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:
24:db7494389c03
Parent:
23:41260ab0f49d
Child:
26:166dbe6022e8
--- a/RotarySwitch.cpp	Tue Sep 04 17:51:33 2018 -0700
+++ b/RotarySwitch.cpp	Wed Sep 05 16:05:07 2018 +0000
@@ -74,7 +74,7 @@
 void RotarySwitch::UpdateOutput()   
 {
     // Blink mode LED
-    if (WHEEL_MODE_SELECT == currentWheelState)
+    if (WHEEL_SUBMODE_SELECT == currentWheelState)
        LEDs_write(0);
 
    if (WheelStateTimer)
@@ -88,9 +88,11 @@
    }
 }
 
-void RotarySwitch::UpdateInput()   
-{               
-   if (WHEEL_INACTIVE_SELECT == currentWheelState)
+float RotarySwitch::UpdateInput()   
+{
+   float direction = 0; // used to return direction of rotation
+   
+   if (WHEEL_INACTIVE == currentWheelState)
       LEDs_write(0);
    else
       LEDs_write(LED_statuses[LED_status_index]);
@@ -103,10 +105,16 @@
      if (WHEEL_MODE_SELECT == currentWheelState)
      {
         if (WheelCurrent > WheelPrevious)
+        {
            LED_status_index = ++LED_status_index % sizeof(LED_statuses);
+           direction = 1;
+        }
         else
             if (WheelCurrent < WheelPrevious)
+            {
                LED_status_index = --LED_status_index % sizeof(LED_statuses);
+               direction = -1;
+            }
      }
      // Keep resetting WheelStateTimer as long as wheel is moving
      if (WheelPrevious != WheelCurrent)
@@ -130,7 +138,7 @@
          WheelStateMachine(WHEEL_Pressed);
       }
     
-   return;
+   return direction;
 }
 
 void RotarySwitch::WheelStateMachine(WheelStateEvent event)