ELCT 302 / Mbed 2 deprecated Top_Fuel_Dragster

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
KDrainEE
Date:
Tue Apr 24 01:47:06 2018 +0000
Parent:
15:d820f7c1898e
Commit message:
It counts and displays; States work pretty well, offtrack works the first time...; Still controllable from terminal; Needs a lot of tuning; Bumpers work; Buttons work; TODO: ; 1. Clean up states; 2. Tuning; 3. Don't cry; 4. Cry a lot;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Tue Apr 24 01:31:48 2018 +0000
+++ b/main.cpp	Tue Apr 24 01:47:06 2018 +0000
@@ -60,6 +60,7 @@
 
 Ticker control;
 Timer ctrlTimer;
+Timer checkpointTimer;
 
 bool lTrig = false;
 bool rTrig = false;
@@ -239,21 +240,30 @@
     if(Setpoint < MINM) Setpoint = MINM;    
 }
 
+void incrimentCheckpoint()
+{
+    if (checkpointTimer > 0.1)
+    {
+        checkpoint++;
+        checkpointTimer.reset();
+    }
+    displayCheckpoint();
+    
+}    
 
 void incL()
 {      
     leftCount++;
-    checkpoint++;
     lTrig = true;
-    displayCheckpoint();
+    incrimentCheckpoint();
+    
 }
 
 void incR()
 {
     rightCount++;
-    checkpoint++;
     rTrig = true;
-    displayCheckpoint();
+    incrimentCheckpoint();
 }
 
 void steer()
@@ -314,6 +324,7 @@
     servoSig.period(STEER_FREQ);
     gateDrive.period(.00005f);
     gateDrive.write(Setpoint);
+    checkpointTimer.start();
    
 
     ctrlTimer.start();
@@ -330,6 +341,7 @@
     stopButton.fall(&stopState);
     waitState();
     while(1) {
+        if (checkpoint > 10) checkpoint = 0;
         checkLED.write(checkpoint);
         if(lTrig){
             bt.putc('l');