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:
34:10550b327e3d
Parent:
33:35e3ab4d5ba7
Child:
37:6f7bb913e08b
diff -r 35e3ab4d5ba7 -r 10550b327e3d main.cpp
--- a/main.cpp	Wed Sep 05 14:38:42 2018 -0700
+++ b/main.cpp	Thu Sep 06 05:37:59 2018 -0700
@@ -26,6 +26,19 @@
 RotarySwitch ModeSwitch;
 LED7segDisplay DigitsDisplay;
 
+enum Modes {
+   CNT1,
+   CNT2,
+   PROSPECT,
+   VOLTS,
+   NULL1,
+   NULL1,
+   NULL3,
+   DIM,
+   NumberOfModes
+};
+uint8_t currentMode = CNT1;
+
 // LED on processor board
 DigitalOut led1(LED1);
 
@@ -82,10 +95,6 @@
    PWM.period_ms(3);    // set the PWM period
    PWM.write(0.8);      // set the PWM duty-cycle
     
-   // Enable interrupts on rising edge of digital inputs TRIG1 & TRIG2
-   TRIG1.rise(&Count1_up);     
-   TRIG2.rise(&Count2_up);         
-        
    Beep(); // initial beep    
     
    // set the 1 sec ticker to periodically call the Update() routine
@@ -127,21 +136,62 @@
    // This must be called periodically to update the LEDs
    ModeSwitch.UpdateOutput();
       
+   switch (currentMode) {
+      case CNT1:
+         DigitsDisplay.Display_6D_write(Count1);
+         DigitsDisplay.Display_2D_write(0);
+         break;
+      case CNT2:
+         DigitsDisplay.Display_6D_write(Count2);
+         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);
+         break;
+      case NULL1:
+         DigitsDisplay.Display_6D_write(0);
+         DigitsDisplay.Display_2D_write(0);
+         break;
+      case NULL1:
+         DigitsDisplay.Display_6D_write(0);
+         DigitsDisplay.Display_2D_write(0);
+         break;
+      case NULL3:
+         DigitsDisplay.Display_6D_write(0);
+         DigitsDisplay.Display_2D_write(0);
+         break;
+      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;
+   }
+
    if(Stopped)
    {    
       // disable interrupts on TRIG1 and TRIG2
       TRIG1.rise(NULL);      
       TRIG2.rise(NULL); 
-        
-      // show selected content on main display
-      DigitsDisplay.Display_6D_write(Count1);    // refresh the main display              
-      DigitsDisplay.Display_2D_write(0);
    }
-    
    else
    {
-      DigitsDisplay.Display_6D_write(Count1);    // refresh the main display 
-      DigitsDisplay.Display_2D_write(0);     // TBD
+      // Enable interrupts on rising edge of digital inputs TRIG1 & TRIG2
+      TRIG1.rise(&Count1_up);     
+      TRIG2.rise(&Count2_up);         
         
       Count1 = 0;     // clear both counters
       Count2 = 0;
@@ -154,16 +204,38 @@
 
    // This must be called periodically to monitor switch input
    direction = ModeSwitch.UpdateInput();
-   if (direction > 0)
-   {
-      DigitsDisplay.Display_brightness_up();
+   currentMode = ModeSwitch.GetPosition();
+        
+   switch (currentMode) {
+      case CNT1:
+         break;
+      case CNT2:
+         break;
+      case PROSPECT:
+         break;
+      case VOLTS:
+         break;
+      case NULL1:
+         break;
+      case NULL1:
+         break;
+      case NULL3:
+         break;
+      case DIM:
+         if (direction > 0)
+         {
+            DigitsDisplay.Display_brightness_up();
+         }
+         else
+            if (direction < 0)
+            {
+               DigitsDisplay.Display_brightness_down();
+            }
+         break;
+      default:
+         break;
    }
-   else
-      if (direction < 0)
-      {
-         DigitsDisplay.Display_brightness_down();
-      }
-        
+
    ADC_val = KEYB.read();  // read voltage from keyboard
    if (   (ADC_val<0.1)    // START/STOP pushbutton pressed
        && (!StartStopPressed))