first commit

Dependencies:   mbed MMA8451Q

Revision:
6:d2bd68ba99c9
Parent:
5:636c3fe18aa8
Child:
7:05ea1c004b49
--- a/state_control.h	Mon Oct 25 02:14:11 2021 +0000
+++ b/state_control.h	Mon Oct 25 03:15:51 2021 +0000
@@ -29,15 +29,19 @@
 
 void _stop(void){
    steering_enabled =false;
-    // TODO: Activate brakes. Example: 
-    // left_brakes_enabled = true; 
+    // TODO: Activate brakes. Example: DONE
+    // left_brakes_enabled = true;  
     // right_brakes_enabled = true; 
+    brakeLeftBool = true;
+    brakeRightBool = true;
     motor_enabled = false;  
     turn_led(RED); 
  
     }; 
 void _run(void){
     // TODO: realease brakes, start the motors 
+    brakeLeftBool = false;
+    brakeLeftBool = false;
     motor_enabled = true; 
     turn_led(GREEN); 
     };
@@ -45,6 +49,8 @@
      // release brakes, turn on steering system, do not start the motor
      // left_brakes_enabled = false; 
      // right_brakes_enabled = false; 
+    brakeLeftBool = false;
+    brakeLeftBool = false;
     motor_enabled = false;
     steering_enabled = true;
      turn_led(YELLOW);
@@ -71,11 +77,21 @@
           _fault = true;
           fault_type = OFF_TRACK;
         }
-    else { 
+    else {                              //we should only set _fault to false when the user manually clears a fault w a button
         _fault = false; 
         fault_type = CLEAR;
-        };
-           
+        }
+     
+     
+     
+batteryVoltage = battInput * 3.3 * battDividerScalar;
+avgCellVoltage = batteryVoltage / 3.0;
+
+     if (avgCellVoltage <= 3.4){
+         _fault = true;
+         fault_type = LOW_VOLTAGE;
+         }
+             
          /*
     else if (hit something){