SmartWheels self-driving race car. Designed for NXP Cup. Uses FRDM-KL25Z, area-scan camera, and simple image processing to detect and navigate any NXP spec track.

Dependencies:   TSI USBDevice mbed-dev

Fork of SmartWheels by haofan Zheng

Hardwares/Motor.h

Committer:
hazheng
Date:
2017-03-29
Revision:
44:15de535c4005
Parent:
11:676ea42afd56
Child:
46:a5eb9bd3bb55

File content as of revision 44:15de535c4005:

#pragma once

#include <mbed.h>

#define MotorDir unsigned char
#define MDIR_Forward  0
#define MDIR_Backward 1

namespace SW
{
    class Core;
}

class Motor{

public:
    Motor(SW::Core& core);
    
    ~Motor();
    
    void Update(float deltaTime);
    
    void setLeftSpeed(const float speed);
    
    void setRightSpeed(const float speed);
    
    void setSpeeds(const float speedLeft, const float speedRight);
    
    void setLeftDirection(MotorDir dir);
    
    void setRightDirection(MotorDir dir);
    
    void setDirections(MotorDir dirL, MotorDir dirR);

private:

    SW::Core& m_core;
    
    DigitalOut m_dirL;
    DigitalOut m_dirR;
    
    PwmOut m_pwmL;
    PwmOut m_pwmR;
    
    Motor();
};