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:
28:c81d00ec28a3
Parent:
25:0161bf1adc81
Child:
30:2fa7fcabf7c7
--- a/main.cpp	Wed Sep 05 11:24:15 2018 -0700
+++ b/main.cpp	Wed Sep 05 12:33:47 2018 -0700
@@ -26,10 +26,6 @@
 RotarySwitch ModeSwitch;
 LED7segDisplay DigitsDisplay;
 
-// definitions of fixed parameters
-
-#define TGATE   10       // gate time (currently fixed for testing purpose)
-
 // LED on processor board
 DigitalOut led1(LED1);
 
@@ -44,7 +40,6 @@
 // Global variables
 time_t      seconds;       // Real-Time Clock (RTC) timestamp
 unsigned int value = 0;    // displayed value on the 6-digits of the display
-uint8_t     gate = TGATE;          // displayed value on the 2-digits display
 uint32_t    Count1, Count2;    // pulse counters (32-bit)
 char        Text[40]="";   // used to send messages over the serial port
 uint8_t     Disp_mode = 0x01, Disp_unit = 0xA0;   // status of 1st row and 2nd rows of LEDs
@@ -66,42 +61,46 @@
 int main() 
 {
     
-    PC.baud(115200);        // set baud-rate of virtual COM port (PC connection)
-    PC.printf("\nGEO COUNTER V1 2108");
-    PC.printf(__DATE__);
-    PC.printf("  ");
-    PC.printf(__TIME__);
+   PC.baud(115200);        // set baud-rate of virtual COM port (PC connection)
+   PC.printf("\nGEO COUNTER V1 2108");
+   PC.printf(__DATE__);
+   PC.printf("  ");
+   PC.printf(__TIME__);
     
-    GPS.baud(9600); // set the baud-rate of the serial port dedicated to the GPS
+   GPS.baud(9600); // set the baud-rate of the serial port dedicated to the GPS
     
-    CS1 = 1;    // presets CS of MAX7219
-    CS2 = 1;    // preset CS of 74HC595
+   CS1 = 1;    // presets CS of MAX7219
+   CS2 = 1;    // preset CS of 74HC595
 
-    DigitsDisplay.Display_6D_write(0x543210);
-    DigitsDisplay.Display_2D_write(TGATE);
+   DigitsDisplay.Display_6D_write(0x543210);
+   DigitsDisplay.Display_2D_write(0);
 
-    // RTC is supposed to be loose time at power down (no backup battery)
-    // An initialization is performed anyway 
-    set_time(0); // Set time
+   // RTC is supposed to be loose time at power down (no backup battery)
+   // An initialization is performed anyway 
+   set_time(0); // Set time
     
-    PWM.period_ms(3);    // set the PWM period
-    PWM.write(0.8);      // set the PWM duty-cycle
+   PWM.period_ms(3);    // set the PWM period
+   PWM.write(0.8);      // set the PWM duty-cycle
     
-    Beep(); // initial beep    
+   // 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
-    // NOTE: this is also the 1-sec time base for counters. A better approach
-    // would replace the ticker with an interrupt from the RTC (to be implemented)
-    SecTenth_Beat.attach_us(&UpdateInput,  100000);  
-    Sec_Beat.attach_us(&UpdateOutput, 1000000);  
-    //RTC::attach(&Update, RTC::Second);
-    //RTC::detach(RTC::Second);  
+   // set the 1 sec ticker to periodically call the Update() routine
+   // NOTE: this is also the 1-sec time base for counters. A better approach
+   // would replace the ticker with an interrupt from the RTC (to be implemented)
+   SecTenth_Beat.attach_us(&UpdateInput,  100000);  
+   Sec_Beat.attach_us(&UpdateOutput, 1000000);  
+   //RTC::attach(&Update, RTC::Second);
+   //RTC::detach(RTC::Second);  
   
-    // main loop does nothing as all activities are interrupt driven    
-    while(1) 
-    {
-        // dance (or drink a beer)                
-    }
+   // main loop does nothing as all activities are interrupt driven    
+   while(1) 
+   {
+      // dance (or drink a beer)                
+   }
 }
 
 
@@ -125,41 +124,27 @@
 
 void UpdateOutput()   
 {
-    // This must be called periodically to update the LEDs
-    ModeSwitch.UpdateOutput();
+   // This must be called periodically to update the LEDs
+   ModeSwitch.UpdateOutput();
       
    if(Stopped)
    {    
       // disable interrupts on TRIG1 and TRIG2
-        
       TRIG1.rise(NULL);      
       TRIG2.rise(NULL); 
         
-      // show zero gate time   
-      gate = 0;                   
-      DigitsDisplay.Display_2D_write(gate);
-        
       // show selected content on main display
       DigitsDisplay.Display_6D_write(Count1);    // refresh the main display              
+      DigitsDisplay.Display_2D_write(0);
    }
     
    else
    {
-      // Enable interrupts on rising edge of digital inputs TRIG1 & TRIG2
-      TRIG1.rise(&Count1_up);     
-      TRIG2.rise(&Count2_up);         
-        
-      if(gate==0) // show the counter value at the end of the gate time
-      {
-         DigitsDisplay.Display_6D_write(Count1);    // refresh the main display 
+      DigitsDisplay.Display_6D_write(Count1);    // refresh the main display 
+      DigitsDisplay.Display_2D_write(0);     // TBD
         
-         Count1 = 0;     // clear both counters
-         Count2 = 0;
-         gate = TGATE;// and reload the gate time
-      }
-
-      DigitsDisplay.Display_2D_write(gate);     // show gate time countdown 
-      gate--;
+      Count1 = 0;     // clear both counters
+      Count2 = 0;
    }
 }
 
@@ -173,9 +158,9 @@
    }
    else
       if (direction < 0)
-   {
-       DigitsDisplay.Display_brightness_down();
-   }
+      {
+         DigitsDisplay.Display_brightness_down();
+      }
         
    ADC_val = KEYB.read();  // read voltage from keyboard
    if (   (ADC_val<0.1)    // START/STOP pushbutton pressed
@@ -201,8 +186,8 @@
 
 void Count1_up(void)
 {                       
-    Count1++;                        
-    return; 
+   Count1++;                        
+   return; 
 }
 
 //---------------------------------------------------------------------------
@@ -210,8 +195,8 @@
 
 void Count2_up(void)
 {                      
-    Count2++;                        
-    return; 
+   Count2++;                        
+   return; 
 }
 
 
@@ -220,10 +205,10 @@
 
 void Beep(void)       
 {                       
-    BUZZ = 1;         // turn-on the buzzer
-    wait(0.3);        // wait
-    BUZZ = 0;         // turn-off the buzzer   
-    return; 
+   BUZZ = 1;         // turn-on the buzzer
+   wait(0.3);        // wait
+   BUZZ = 0;         // turn-off the buzzer   
+   return; 
 }
 
 //-------- END OF FILE --------------