Wheelchair control

Dependencies:   BNO055 mbed

Fork of wheelchaircontrol by ryan lin

Revision:
6:8cd00c26bb47
Parent:
5:e0ccaab3959a
--- a/wheelchair.cpp	Tue Jul 17 07:19:04 2018 +0000
+++ b/wheelchair.cpp	Tue Jul 17 19:19:26 2018 +0000
@@ -1,24 +1,30 @@
 #include "wheelchair.h"
 
-Wheelchair::Wheelchair(PinName xPin, PinName yPin)
+// Note: 'def' is short for 'Default Position'
+
+// Initialize Wheelchair Pins
+Wheelchair::Wheelchair (PinName xPin, PinName yPin)
 {
     x = new PwmOut(xPin);
     y = new PwmOut(yPin);
     imu = new chair_imu();
 }
+
 /*
-* joystick has analog out of 200-700, scale values between 1.3 and 3.3
+*   Joystick has AnalogOut of 200-700, scale values between 1.3 and 3.3
 */
+
+// Convert Joystick Values to Move the Wheelchair
 void Wheelchair::move(float x_coor, float y_coor)
 {
-     
-    float scaled_x = ((x_coor * 1.6f) + 1.7f)/3.3f;
-    float scaled_y = (3.3f - (y_coor * 1.6f))/3.3f;
+   
+    float scaled_x = ((x_coor * 1.6f) + 1.7f) / 3.3f;
+    float scaled_y = (3.3f - (y_coor * 1.6f)) / 3.3f;
     x->write(scaled_x);
-    y->write(scaled_y);
-    
+    y->write(scaled_y); 
 }
 
+// Turn 90 degrees to the Right
 void Wheelchair::turn_right(){
     double start = imu->yaw();
     double final = start + 90;
@@ -30,6 +36,7 @@
         } 
 }
 
+// Turn 90 degrees to the Left
 void Wheelchair::turn_left(){
     double start = imu->yaw();
     double final = start - 90;
@@ -40,30 +47,31 @@
         Wheelchair::left();
         } 
 }
+
 void Wheelchair::forward()
 {
     x->write(high);
     y->write(def+offset);
 }
-
+ 
 void Wheelchair::backward()
 {
     x->write(low);
     y->write(def);
 }
-
+ 
 void Wheelchair::right()
 {
     x->write(def);
     y->write(high);
 }
-
+ 
 void Wheelchair::left()
 {
     x->write(def);
     y->write(low);
 }
-
+ 
 void Wheelchair::stop()
 {
     x->write(def);