Updated with Statistics Library

Dependencies:   QEI2 chair_BNO055 PID Watchdog VL53L1X_Filter ros_lib_kinetic

Revision:
28:e01253eb6c6f
Parent:
27:da718b990837
--- a/wheelchair.cpp	Fri Jun 28 21:16:26 2019 +0000
+++ b/wheelchair.cpp	Fri Jun 28 23:52:23 2019 +0000
@@ -35,6 +35,24 @@
     curr_pos = wheel->getDistance(53.975);
 }
 
+void Wheelchair::emergencyButton_thread ()
+{
+    while(1) {
+        while(!e_button) {
+
+            //Stop wheelchair
+            Wheelchair::stop();
+            printf("E-button has been pressed\n\n\n");
+            off->write(high);                              //turn off PCB
+            on->write(0);                                  //make sure PCB not on
+            //Reset Board
+            NVIC_SystemReset();
+
+        }
+
+    }
+}
+
 void Wheelchair::assistSafe_thread()
 {
     int ToFV[12];
@@ -103,7 +121,7 @@
     wheel = qei;   
     ToF = ToFT;                                                                         // passes pointer with addresses of ToF sensors
     
-    for(int i = 0; i < 12; i++)                                               // initializes the ToF Sensors
+    for(int i = 0; i < 12; i++)                                                         // initializes the ToF Sensors
     {
         (*(ToF+i))->initReading(0x31+((0x02)*i), 50000);
     }
@@ -116,8 +134,9 @@
         ledgeArrayRF[i] = (*(ToF+1))->readFromOneSensor();
     }
     int* aaa = ledgeArrayLF; 
-    statistics LFTStats(aaa, 100, 0); 
-    out->printf("stadistics = %f, %f",  LFTStats.mean(), LFTStats.stdev());
+    
+    statistics LFTStats(aaa, 99, 1); 
+    out->printf("Statistics: Mean = %f, Standard Dev = %f\n",  LFTStats.mean(), LFTStats.stdev());
     myPID.SetMode(AUTOMATIC);                                                           // PID mode: Automatic
 }
 
@@ -180,7 +199,7 @@
  */
 void Wheelchair::pid_right(int deg)
 {
-    bool overturn = false;                                                              //Boolean if angle over 360˚
+    bool overturn = false;                                                              // Boolean if angle over 360˚
     
     out->printf("pid right\r\r\n");                                
     x->write(def);                                                                      // Update x sent to chair to be stationary