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:
5:4f90b458dbdf
Parent:
4:b17c6556cf1f
Child:
6:05201ecabb95
--- a/main.cpp	Sun Sep 02 01:42:59 2018 +0000
+++ b/main.cpp	Sun Sep 02 20:26:22 2018 +0000
@@ -56,6 +56,8 @@
 DigitalOut  MOSI  (A6);    // 74HC595 SER (pin 14) & MAX7219 DIN (pin 1)
 DigitalIn   UN    (A7);    // Unused (in V1 PCB A5 and A7 must be connected)
 
+// LED on processor board
+DigitalOut led1(LED1);
 
 // definitions of peripherals and devices
 QEI     Wheel(D12, D11, NC, 16);    // Quadrature encoder
@@ -74,6 +76,7 @@
 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
 bool        Stopped = 0;        // status of counting activity
+bool        StartStopPressed = 0;// status of counting activity
 double      ADC_val;    // used to read ADC value
 
 // ----- Prototypes of routines (defined below the main) -------------------
@@ -93,18 +96,17 @@
 {
     
     PC.baud(115200);        // set baud-rate of virtual COM port (PC connection)
-    PC.printf("GEO COUNTER V1 2108\n");
+    PC.printf("\nGEO COUNTER V1 2108");
     PC.printf(__DATE__);
     PC.printf("  ");
     PC.printf(__TIME__);
-    PC.printf("\nReady...\n");
     
     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
 
-    Display_6D_write(0);
+    Display_6D_write(543210);
     Display_2D_write(TGATE);
     Display_init(); // initialize MAX7219
 
@@ -149,24 +151,27 @@
 void Update()   
 {               
     ADC_val = KEYB.read();  // read voltage from keyboard
-    PC.printf("%lf\n", ADC_val); 
-    if(ADC_val<0.1) // RESET pushbutton pressed
-    {    
-        PC.printf("reset pushed");
+    PC.printf("\nADC: %.02f", ADC_val); 
+    if (   (ADC_val<0.1)    // START/STOP pushbutton pressed
+        && (!StartStopPressed))
+    {
+        StartStopPressed = true;
+        Stopped=!Stopped;           // toggle status
+    }
+    else
+        StartStopPressed = false;
+    
+    if((ADC_val>0.6)&&(ADC_val<0.7))    // CLEAR pushbutton pressed
+    { 
         Count1 = 0; // clear counters     
         Count2 = 0;              
-    }        
-    
-    if((ADC_val>0.6)&&(ADC_val<0.7))    // START/STOP pushbutton pressed
-            { 
-            Stopped=!Stopped;           // toggle status
-            PC.printf("ADC > 0.6 but < 0.7");
-            }
+   }
+
     if(Stopped)
     {    
         // disable interrupts on TRIG1 and TRIG2
         
-        PC.printf("stopped");
+        PC.printf(" stopped");
         TRIG1.rise(NULL);      
         TRIG2.rise(NULL); 
         
@@ -183,7 +188,7 @@
     {
         // Enable interrupts on rising edge of digital inputs TRIG1 & TRIG2
         
-        PC.printf("started");
+        PC.printf(" started");
         TRIG1.rise(&Count1_up);     
         TRIG2.rise(&Count2_up);         
         
@@ -202,16 +207,13 @@
 
         Display_2D_write(gate);     // show gate time countdown 
         gate--;
-        
-        // Timestamp to PC (debug)
-        seconds = time(NULL);   // get current time 
-        //strftime(Text, 50, "%d-%b-%Y  %H:%M:%S", localtime(&seconds));
-        strftime(Text, 50, "%H:%M:%S", localtime(&seconds));
-        PC.printf("RTC: %s, CNT1: %7d CNT2: %7d\n",Text, Count1, Count2);
-    
     }
         
-    
+    // Timestamp to PC (debug)
+    seconds = time(NULL);   // get current time 
+    strftime(Text, 50, "%H:%M:%S", localtime(&seconds));
+    PC.printf(" RTC: %s, CNT1: %7d CNT2: %7d",Text, Count1, Count2);
+
     return;
 }