Xbeat beta code as published by Andre Moehl ( http://mbed.org/users/hoppel/ ) With a slightly modified serial port definition

Dependencies:   mbed

Committer:
n0p
Date:
Fri Feb 04 08:31:00 2011 +0000
Revision:
0:badcd0d61c7b

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
n0p 0:badcd0d61c7b 1 /*
n0p 0:badcd0d61c7b 2 *
n0p 0:badcd0d61c7b 3 * This program is free software; you can redistribute it and/or modify
n0p 0:badcd0d61c7b 4 * it under the terms of the GNU General Public License as published by
n0p 0:badcd0d61c7b 5 * the Free Software Foundation; either version 3 of the License, or
n0p 0:badcd0d61c7b 6 * (at your option) any later version.
n0p 0:badcd0d61c7b 7 *
n0p 0:badcd0d61c7b 8 * This program is distributed in the hope that it will be useful,
n0p 0:badcd0d61c7b 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
n0p 0:badcd0d61c7b 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
n0p 0:badcd0d61c7b 11 * GNU General Public License for more details.
n0p 0:badcd0d61c7b 12 *
n0p 0:badcd0d61c7b 13 * You should have received a copy of the GNU General Public License
n0p 0:badcd0d61c7b 14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
n0p 0:badcd0d61c7b 15 *
n0p 0:badcd0d61c7b 16 * @file drive.cpp
n0p 0:badcd0d61c7b 17 * @author Andre Moehl
n0p 0:badcd0d61c7b 18 * @date 01/2011
n0p 0:badcd0d61c7b 19 * @brief Driver Class definition
n0p 0:badcd0d61c7b 20 */
n0p 0:badcd0d61c7b 21
n0p 0:badcd0d61c7b 22 /*--- Includes ------------------------*/
n0p 0:badcd0d61c7b 23 #include "drive.h"
n0p 0:badcd0d61c7b 24
n0p 0:badcd0d61c7b 25 /*--- Functions -----------------------*/
n0p 0:badcd0d61c7b 26 //Contructor
n0p 0:badcd0d61c7b 27 Drive::Drive(PinName LeftPin,PinName RightPin): _Left(LeftPin, DUTYCYCLE), _Right(RightPin, DUTYCYCLE)
n0p 0:badcd0d61c7b 28 {
n0p 0:badcd0d61c7b 29 offset_L = 0;
n0p 0:badcd0d61c7b 30 offset_R = 0;
n0p 0:badcd0d61c7b 31 }
n0p 0:badcd0d61c7b 32
n0p 0:badcd0d61c7b 33 /**
n0p 0:badcd0d61c7b 34 * @ brief Sets the linear speed
n0p 0:badcd0d61c7b 35 * @parameter speed value between -100 and 100 % */
n0p 0:badcd0d61c7b 36 void Drive::move(int left, int right)
n0p 0:badcd0d61c7b 37 {
n0p 0:badcd0d61c7b 38 if (left > 120) left = 120;
n0p 0:badcd0d61c7b 39 if (left < -120) left = -120;
n0p 0:badcd0d61c7b 40 if (right > 120) right = 120;
n0p 0:badcd0d61c7b 41 if (right < -120) right = -120;
n0p 0:badcd0d61c7b 42
n0p 0:badcd0d61c7b 43 _Left.speed(ZERO + offset_L + left*6);
n0p 0:badcd0d61c7b 44 _Right.speed(ZERO - offset_R - right*6);
n0p 0:badcd0d61c7b 45 }
n0p 0:badcd0d61c7b 46
n0p 0:badcd0d61c7b 47 /**
n0p 0:badcd0d61c7b 48 * @brief sets the motor zero offset
n0p 0:badcd0d61c7b 49 * @parameter left left motor offset
n0p 0:badcd0d61c7b 50 * @parameter right right motor offset
n0p 0:badcd0d61c7b 51 */
n0p 0:badcd0d61c7b 52 void Drive::setoffset(int left, int right)
n0p 0:badcd0d61c7b 53 {
n0p 0:badcd0d61c7b 54 offset_L = left;
n0p 0:badcd0d61c7b 55 offset_R = right;
n0p 0:badcd0d61c7b 56 }
n0p 0:badcd0d61c7b 57