Dependents:   RobotBase

I2CMotor.h

Committer:
inst
Date:
2015-07-02
Revision:
0:89910534fad4
Child:
1:46cf8d086b38

File content as of revision 0:89910534fad4:

#ifndef INCLUDED_I2C_MOTOR_H
#define INCLUDED_I2C_MOTOR_H

#include "I2CDevice.h"
#include "mbed.h"

class I2CMotor : public I2CDevice{
public:
    enum ActionType{
        RELEASE,
        LEFT,
        RIGHT,
        BRAKE
    };
    I2CMotor( I2C* i2c, char address );
    
    void setActionType( ActionType action ){
        mActionType = action;
    }
    void setDuty( float duty ){
        if ( duty > 1.0f ){
            duty = 1.0f;
        } else if ( duty < 0.0f ){
            duty = 0.0f;
        }
        
        mDuty = duty;
    }
    ActionType getActionType(){
        return mActionType;
    }
    float getDuty(){
        return mDuty;
    }
    
    float getMaxDuty(){
        return mMaxDuty;
    }
    float getMinDuty(){
        return mMinDuty;
    }
    
protected:
    virtual void write();
    virtual void read(){}
private:
    ActionType mActionType;
    float mDuty;
    
    float mMaxDuty;
    float mMinDuty;
};

#endif