Only imu output
Fork of FYDP_Final2 by
motors/motors.cpp@5:d2e955a94940, 2015-03-25 (annotated)
- Committer:
- tntmarket
- Date:
- Wed Mar 25 09:58:50 2015 +0000
- Revision:
- 5:d2e955a94940
- Parent:
- 0:21019d94ad33
only imu output
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
majik | 0:21019d94ad33 | 1 | #include "motors.h" |
majik | 0:21019d94ad33 | 2 | |
majik | 0:21019d94ad33 | 3 | Motors::Motors(TB6612 * L, TB6612 * R, PinName STBY): |
majik | 0:21019d94ad33 | 4 | Left(L), Right(R), enable(STBY) |
majik | 0:21019d94ad33 | 5 | { |
majik | 0:21019d94ad33 | 6 | enable = 1; |
majik | 0:21019d94ad33 | 7 | } |
majik | 0:21019d94ad33 | 8 | |
majik | 0:21019d94ad33 | 9 | void Motors::flip() |
majik | 0:21019d94ad33 | 10 | { |
majik | 0:21019d94ad33 | 11 | TB6612 * temp = Left; |
majik | 0:21019d94ad33 | 12 | Left = Right; |
majik | 0:21019d94ad33 | 13 | Right = temp; |
majik | 0:21019d94ad33 | 14 | |
majik | 0:21019d94ad33 | 15 | Left->scale *= -1; |
majik | 0:21019d94ad33 | 16 | Right->scale *= -1; |
majik | 0:21019d94ad33 | 17 | } |
majik | 0:21019d94ad33 | 18 | void Motors::reverse(bool m) |
majik | 0:21019d94ad33 | 19 | { |
majik | 0:21019d94ad33 | 20 | if(m) |
majik | 0:21019d94ad33 | 21 | Right->scale *= -1; //reverse right motor |
majik | 0:21019d94ad33 | 22 | else |
majik | 0:21019d94ad33 | 23 | Left->scale *= -1; //reverse left motor |
majik | 0:21019d94ad33 | 24 | } |
majik | 0:21019d94ad33 | 25 | |
majik | 0:21019d94ad33 | 26 | //TODO: write in a function that automatically sets the motors to be oriented properly. Use the |
majik | 0:21019d94ad33 | 27 | //gyroscopes and accelerometer to do this. |