A library for H-Bridge dual motor control

DualMotorController.hpp

Committer:
Cornelius Bezuidenhout
Date:
2017-10-22
Revision:
1:b85eb4e982a9
Parent:
0:9ac0748f78d4
Child:
2:c0e11aaa32e7

File content as of revision 1:b85eb4e982a9:

#ifndef _DUALMOTORCONTROLLER_
#define _DUALMOTORCONTROLLER_

#include "mbed.h"

class DualMotorController {

public:
    DualMotorController(PinName pwmL, PinName dirL0, PinName dirL1, PinName pwmR, PinName dirR0, PinName dirR1, float frequency = 100000.0f);

    void SetLeft(float speed, bool forward);
    void SetRight(float speed, bool forward);

    //TODO : Invert direction
    //TODO : Get current values
    //TODO : Add braking


private:
    PwmOut _pwmL, _pwmR;
    DigitalOut _dirL0, _dirR0;
    DigitalOut _dirL1, _dirR1;

    float _speedL, _speedR;
    boolean _inverted;
};
#endif