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:
37:6f7bb913e08b
Child:
39:dee91966b45c
--- a/main.cpp	Thu Sep 06 05:45:01 2018 -0700
+++ b/main.cpp	Thu Sep 06 10:03:01 2018 -0700
@@ -30,14 +30,15 @@
    CNT1,
    CNT2,
    PROSPECT,
-   VOLTS,
    NULL1,
    NULL2,
-   NULL3,
+   VOLTS,
+   VOLUME,
    DIM,
    NumberOfModes
 };
-uint8_t currentMode = CNT1;
+uint8_t currentMode          = CNT1;
+uint8_t currentModeToDisplay = CNT1;
 
 // LED on processor board
 DigitalOut led1(LED1);
@@ -61,6 +62,9 @@
 double      ADC_val;    // used to read ADC value
 float       direction = 0;
 
+#define maxVolume 10
+uint8_t     volume = maxVolume;
+
 // ----- Prototypes of routines (defined below the main) -------------------
 void UpdateInput(void);  // periodically called by the ticker
 void UpdateOutput(void);  // periodically called by the ticker
@@ -136,47 +140,33 @@
    // This must be called periodically to update the LEDs
    ModeSwitch.UpdateOutput();
       
-   switch (currentMode) {
+   switch (currentModeToDisplay) {
       case CNT1:
          DigitsDisplay.Display_6D_write(Count1);
-         DigitsDisplay.Display_2D_write(0);
+         // DigitsDisplay.Display_2D_write(0);
          break;
       case CNT2:
          DigitsDisplay.Display_6D_write(Count2);
-         DigitsDisplay.Display_2D_write(0);
+         // DigitsDisplay.Display_2D_write(0);
          break;
       case PROSPECT:
          DigitsDisplay.Display_6D_write(Count1);
-         DigitsDisplay.Display_2D_write(0);
-         break;
-      case VOLTS:
-         DigitsDisplay.Display_6D_write(0);
-         DigitsDisplay.Display_2D_write(0);
+         // DigitsDisplay.Display_2D_write(0);
          break;
       case NULL1:
          DigitsDisplay.Display_6D_write(0);
-         DigitsDisplay.Display_2D_write(0);
+         // DigitsDisplay.Display_2D_write(0);
          break;
       case NULL2:
          DigitsDisplay.Display_6D_write(0);
-         DigitsDisplay.Display_2D_write(0);
+         // DigitsDisplay.Display_2D_write(0);
          break;
-      case NULL3:
+      case VOLTS:
          DigitsDisplay.Display_6D_write(0);
-         DigitsDisplay.Display_2D_write(0);
+         // DigitsDisplay.Display_2D_write(0);
          break;
+      case VOLUME:
       case DIM:
-         if (direction > 0)
-         {
-            DigitsDisplay.Display_brightness_up();
-         }
-         else
-            if (direction < 0)
-            {
-               DigitsDisplay.Display_brightness_down();
-            }
-         DigitsDisplay.Display_2D_write(DigitsDisplay.GetBrightness());
-         break;
       default:
          break;
    }
@@ -200,37 +190,41 @@
 
 void UpdateInput()   
 {
-   DigitsDisplay.Display_2D_write(Count1); // Just to test 2D
-
    // This must be called periodically to monitor switch input
-   direction = ModeSwitch.UpdateInput();
+   direction   = ModeSwitch.UpdateInput();
    currentMode = ModeSwitch.GetPosition();
         
    switch (currentMode) {
       case CNT1:
-         break;
       case CNT2:
-         break;
       case PROSPECT:
-         break;
       case VOLTS:
+         currentModeToDisplay = currentMode;
          break;
       case NULL1:
-         break;
       case NULL2:
          break;
-      case NULL3:
+      case VOLUME:
+         if (!isnan(direction))
+         {
+            if (direction > 0)
+               (volume < maxVolume ? volume++:);
+            else
+               if (direction < 0)
+                  (volume > 0 ? volume--:);
+         }
+         DigitsDisplay.Display_2D_write(volume);
          break;
       case DIM:
-         if (direction > 0)
+         if (!isnan(direction))
          {
-            DigitsDisplay.Display_brightness_up();
+            if (direction > 0)
+               DigitsDisplay.Display_brightness_up();
+            else
+               if (direction < 0)
+                  DigitsDisplay.Display_brightness_down();
          }
-         else
-            if (direction < 0)
-            {
-               DigitsDisplay.Display_brightness_down();
-            }
+         DigitsDisplay.Display_2D_write(DigitsDisplay.GetBrightness());
          break;
       default:
          break;