Mateusz Grzywacz / Yellow2WheeledRobot_motor_shield

Files at this revision

API Documentation at this revision

Comitter:
amateusz
Date:
Fri Feb 05 16:28:29 2016 +0000
Parent:
4:aef786c67b2d
Commit message:
There is now a class for the shield as a whole, which makes managing easy. The whole thing have been rewritten.

Changed in this revision

YellowMotors.cpp Show annotated file Show diff for this revision Revisions of this file
YellowMotors.h Show annotated file Show diff for this revision Revisions of this file
--- a/YellowMotors.cpp	Fri Feb 05 15:49:11 2016 +0000
+++ b/YellowMotors.cpp	Fri Feb 05 16:28:29 2016 +0000
@@ -41,7 +41,7 @@
 };
 void YellowMotors::set(float value, int whichMotor )
 {
-    pc.printf("value: %.3f", value);
+    //pc.printf("value: %.3f", value);
     char directionsNew = _directions;
     if(whichMotor == -1) { // case set both;
         L = motorLinearizationL(abs(value));
@@ -116,11 +116,11 @@
 void YellowMotors::setDirections(char directions)
 {
     if (_led != 0) *_led = 1;
-    pc.printf("\n\r_led ma adres: %d\n\r", _led);
-    pc.printf("### set dirs: ");
+    //pc.printf("\n\r_led ma adres: %d\n\r", _led);
+    //pc.printf("### set dirs: ");
     for(int i=0; i<8; ++i)
-        pc.printf("%c", ((directions >> (7-i)) & 0x1)?'x':'_');
-    pc.printf(" ###\n\r");
+        //pc.printf("%c", ((directions >> (7-i)) & 0x1)?'x':'_');
+    //pc.printf(" ###\n\r");
     _directions = directions;
     _lat = 0;
     for (signed char i = 7; i >= 0; i--) {
--- a/YellowMotors.h	Fri Feb 05 15:49:11 2016 +0000
+++ b/YellowMotors.h	Fri Feb 05 16:28:29 2016 +0000
@@ -33,7 +33,7 @@
     public:
         PwmOut _pwmPin;
         float _pwmSigned; // signed with direction
-        int speed;
+        int speed;  // to be done
         MotorItself() : _pwmPin(NC) {};
         MotorItself(PinName pwmPin): _pwmPin(pwmPin) {};  // fuck you, you default constructor.
         /*
@@ -61,9 +61,9 @@
     YellowMotors(PinName clk = D4, PinName  lat = D12, PinName  dat = D8, PinName ena = D7, PinName Lpwm = D11, PinName Rpwm = D3);
     void setDirections(char); // shift directions to shift register on Adafruit motor shield v1
     void operator= (const float value);
-    void set(float value, int whichMotor = -1);
-    float get(int whichMotor = -1);
-    void attachled(DigitalOut & led);
+    void set(float value, int whichMotor = -1);  // set speed of a motor. float. second parameter is which motor. L is 0 , R is 1 , -1 is both (default)
+    float get(int whichMotor = -1); // get the value from the class, so you don't have to keep track of it by yourself
+    void attachled(DigitalOut & led); // pass an initalized DigitalOut object for a library to use it as debuging LED
     void dettachled() {
         delete _led;
     } ;