57 Motor(PinName left, PinName right, PinName direction_left, PinName direction_right, PinName enable);
Encoder class with helper functions, derived from QEI.
Definition: encoder.h:28
Motor class to control the motors.
Definition: motor.h:22
float getFrequency() const
Get the frequency of the PwmOut.
DigitalOut m_direction_left
Direction for the left motor.
Definition: motor.h:25
static void turnleft(const double angle, Motor *const motor, Encoder *const left_encoder, Encoder *const right_encoder)
Control the motor to turn left.
PwmOut right_motor
Right motor PwmOut.
Definition: motor.h:44
static void reverse(const double distance, Motor *const motor, Encoder *const left_encoder, Encoder *const right_encoder)
Control the motor to cruise backwards.
void setDutycycle(char c, float dutycycle)
Set the duty cycle of the motors.
void setEnable()
Toggle the enable pin of the motor driver board, if no argument is given.
PwmOut left_motor
Left motor PwmOut.
Definition: motor.h:41
void setEnable(int enable)
Set the enable pin of the motor driver board, given the enable.
void setFrequency(float frequency)
Set the frequency of the PwmOut.
DigitalOut m_direction_right
Direction for the right motor.
Definition: motor.h:28
Motor(PinName left, PinName right, PinName direction_left, PinName direction_right, PinName enable)
Constructor.
int getEnable()
Get the enable status of the motor driver board.
void setDirection(char c)
Toggle the direction of the motors, if no direction given.
void setDirection(char c, int direction)
Set the direction of the motors, provided the direction.
static void forward(const double distance, Motor *const motor, Encoder *const left_encoder, Encoder *const right_encoder)
Control the motor to cruise forward.
static void turnright(const double angle, Motor *const motor, Encoder *const left_encoder, Encoder *const right_encoder)
Control the motor to turn right.
DigitalOut m_enable
Enable pin to motor driver board.
Definition: motor.h:31
std::pair< float, float > getDutycycle()
Get the duty cycle of the motors.
float m_period
Period of PWM output.
Definition: motor.h:37
std::pair< int, int > getDirection() const
Get the direction of the motors.