#include <MotorDriver.h>
Public Member Functions | |
| void | configure (uint8_t position, uint8_t motorID) |
| void | goBackward () |
| void | goForward () |
| void | goLeft () |
| void | goRight () |
| void | init () |
| MotorDriver (PinName int1, PinName int2, PinName int3, PinName int4, PinName speedA, PinName speedB) | |
| void | rotate (uint8_t direction, uint8_t motor_position) |
| void | rotateWithID (uint8_t direction, uint8_t motorID) |
| void | setDirection (uint8_t direction, uint8_t motorID) |
| void | setSpeed (uint8_t speed, uint8_t motorID) |
| void | stop () |
| void | stop (uint8_t motorID) |
Public Attributes | |
| MotorStruct | motorA |
| MotorStruct | motorB |
Private Attributes | |
| DigitalOut | _int1 |
| DigitalOut | _int2 |
| DigitalOut | _int3 |
| DigitalOut | _int4 |
| SoftwarePWM | _speedA |
| SoftwarePWM | _speedB |
Motor Driver class. offer API to control the movement of motor
Definition at line 54 of file MotorDriver.h.
| MotorDriver::MotorDriver | ( | PinName | int1, |
| PinName | int2, | ||
| PinName | int3, | ||
| PinName | int4, | ||
| PinName | speedA, | ||
| PinName | speedB | ||
| ) | [inline] |
Create Motor Driver instance
| int1 | pin 1 of motor movement control |
| int2 | pin 2 of motor movement control |
| int3 | pin 3 of motor movement control |
| int4 | pin 4 of motor movement control |
| speedA | speed control of motorA |
| speedB | speed control of motorB |
Definition at line 67 of file MotorDriver.h.
| void MotorDriver::configure | ( | uint8_t | position, |
| uint8_t | motorID | ||
| ) |
config position of motor
| position | the position set to motor,MOTOR_POSITION_LEFT or MOTOR_POSITION_RIGHT will be allowed |
| motorID | the ID define which motor will be set, you can choose MOTORA or MOTORB |
Definition at line 37 of file MotorDriver.cpp.
| void MotorDriver::goBackward | ( | ) |
make motor go backward
Definition at line 87 of file MotorDriver.cpp.
| void MotorDriver::goForward | ( | ) |
make motor go forward
Definition at line 82 of file MotorDriver.cpp.
| void MotorDriver::goLeft | ( | ) |
make motor go left
Definition at line 92 of file MotorDriver.cpp.
| void MotorDriver::goRight | ( | ) |
make motor go right
Definition at line 97 of file MotorDriver.cpp.
| void MotorDriver::init | ( | ) |
set motor to initialized state
Definition at line 25 of file MotorDriver.cpp.
| void MotorDriver::rotate | ( | uint8_t | direction, |
| uint8_t | motor_position | ||
| ) |
rotate motor
| direction | the direction set to motor, MOTOR_CLOCKWISE or MOTOR_ANTICLOCKWISE will be allowed |
| motor_position | the position set to motor,MOTOR_POSITION_LEFT or MOTOR_POSITION_RIGHT will be allowed |
Definition at line 54 of file MotorDriver.cpp.
| void MotorDriver::rotateWithID | ( | uint8_t | direction, |
| uint8_t | motorID | ||
| ) |
rotate motorA or motorB
| direction | the direction set to motor, MOTOR_CLOCKWISE or MOTOR_ANTICLOCKWISE will be allowed |
| motorID | the ID define which motor will be set, you can choose MOTORA or MOTORB |
Definition at line 66 of file MotorDriver.cpp.
| void MotorDriver::setDirection | ( | uint8_t | direction, |
| uint8_t | motorID | ||
| ) |
set direction of motor,
| direction | the direction of motor, MOTOR_CLOCKWISE or MOTOR_ANTICLOCKWISE will be allowed |
| motorID | the ID define which motor will be set, you can choose MOTORA or MOTORB |
Definition at line 48 of file MotorDriver.cpp.
| void MotorDriver::setSpeed | ( | uint8_t | speed, |
| uint8_t | motorID | ||
| ) |
set speed of motor
| speed | speed value set to motor, [0,100] will be allowed |
| motorID | the ID define which motor will be set, you can choose MOTORA or MOTORB |
Definition at line 43 of file MotorDriver.cpp.
| void MotorDriver::stop | ( | ) |
make motor stop
Definition at line 103 of file MotorDriver.cpp.
| void MotorDriver::stop | ( | uint8_t | motorID | ) |
make motorA or motorB stop
| motorID | the ID define which motor will be set, you can choose MOTORA or MOTORB |
Definition at line 109 of file MotorDriver.cpp.
DigitalOut MotorDriver::_int1 [private] |
Definition at line 144 of file MotorDriver.h.
DigitalOut MotorDriver::_int2 [private] |
Definition at line 145 of file MotorDriver.h.
DigitalOut MotorDriver::_int3 [private] |
Definition at line 146 of file MotorDriver.h.
DigitalOut MotorDriver::_int4 [private] |
Definition at line 147 of file MotorDriver.h.
SoftwarePWM MotorDriver::_speedA [private] |
Definition at line 148 of file MotorDriver.h.
SoftwarePWM MotorDriver::_speedB [private] |
Definition at line 149 of file MotorDriver.h.
motor A
Definition at line 136 of file MotorDriver.h.
motor B
Definition at line 140 of file MotorDriver.h.