Xbeat beta code as published by Andre Moehl ( http://mbed.org/users/hoppel/ ) With a slightly modified serial port definition
Diff: motor.cpp
- Revision:
- 0:badcd0d61c7b
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/motor.cpp Fri Feb 04 08:31:00 2011 +0000 @@ -0,0 +1,43 @@ +/* + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @file motor.cpp + * @author Andre Moehl + * @date 01/2011 + * @brief Servo Motor Class definition + */ + +/*--- Includes ------------------------*/ +#include "motor.h" + +// Constructor +Motor::Motor(PinName Pin, int periode): _PwmPin(Pin) +{ + _PwmPin.period_ms(periode); +} + +// Destructor +Motor::~Motor() +{ + _PwmPin.pulsewidth_us(0); +} + + +// set the pwm pulse witdh +void Motor::speed(int value) +{ + _PwmPin.pulsewidth_us(value); +} +