Jon Fuge / MotorController

Dependents:   RenBuggy

MotorController.cpp

Committer:
jf1452
Date:
2014-01-15
Revision:
0:4aa0a6b134ea
Child:
1:548ee2d0bb89

File content as of revision 0:4aa0a6b134ea:

/*******************************************************************************
* RenBED DC Motor Drive for RenBuggy                                           *
* Copyright (c) 2014 Jon Fuge                                                  *
*                                                                              *
* Permission is hereby granted, free of charge, to any person obtaining a copy *
* of this software and associated documentation files (the "Software"), to deal*
* in the Software without restriction, including without limitation the rights *
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell    *
* copies of the Software, and to permit persons to whom the Software is        *
* furnished to do so, subject to the following conditions:                     *
*                                                                              *
* The above copyright notice and this permission notice shall be included in   *
* all copies or substantial portions of the Software.                          *
*                                                                              *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR   *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,     *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE  *
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER       *
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,*
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN    *
* THE SOFTWARE.                                                                *
*                                                                              *
* DCMotorDrive.h                                                               *
*                                                                              *
* V1.0 06/01/2014 First issue of code                      Jon Fuge            *
*******************************************************************************/

#ifndef _DCMOTORCONTROLLER_C
#define _DCMOTORCONTROLLER_C

#include "mbed.h"
#include "MotorController.h"

MotorController::MotorController(PinName LMotorOut, PinName LSensorIn, PinName RMotorOut, PinName RSensorIn):
    _LeftMotor(p5, p7), _RightMotor(p6, p8)
{
    _LeftMotor.SetMotorPwmAndRevolutions(18000,32);
    _RightMotor.SetMotorPwmAndRevolutions(18000,32);
}

void MotorController::LeftResetOdometer(void)
{
    _LeftMotor.ResetOdometer();
}

int MotorController::LeftReadOdometer(void)
{
    return(_LeftMotor.ReadOdometer());
}

int MotorController::LeftReadCaptureTime(void)
{
    return(_LeftMotor.ReadCaptureTime());
}

int MotorController::LeftReadLastTime(void)
{
    return(_LeftMotor.GetLastPulseTime());
}

void MotorController::RightResetOdometer(void)
{
    _RightMotor.ResetOdometer();
}

int MotorController::RightReadOdometer(void)
{
    return(_RightMotor.ReadOdometer());
}

int MotorController::RightReadCaptureTime(void)
{
    return(_RightMotor.ReadCaptureTime());
}

int MotorController::RightReadLastTime(void)
{
    return(_RightMotor.GetLastPulseTime());
}
#endif