Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: SoftPWM
Fork of RC_Servo by
RC_Servo.h
- Committer:
- haarkon
- Date:
- 2018-05-21
- Revision:
- 1:8482eba4d652
- Parent:
- 0:b8dcca3dc509
- Child:
- 2:a762abad6301
File content as of revision 1:8482eba4d652:
/**
* @author Hugues Angelis
*
* @section LICENSE
*
* 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.
*
* @section DESCRIPTION
*
* Any classic RC Servomotor Library
*
* This library will operate any servo using a simple PWM to be driven.
*
* The library générate a PWM signal with a period of 20ms
*
* It may operate in classic mode (eg : min = 1ms, max = 2ms) or
* in extended mode (eg : Min = 400us, Max = 2,4ms) if you set _extended.
*/
#ifndef Servo_H
#define Servo_H
/**
* Includes
*/
#include "mbed.h"
/**
* RC_Servo Class
*/
class RC_Servo {
public :
/**
* Constructor.
*
* @param PWM is the Mbed pin used to generate the PWM signal
* @param _extended (= 0) if set modified the fonctioning limits
*/
RC_Servo(PinName PWM, int _extended = 0);
/**
* Set the min and max time associeted with both position
*
* @param Tmin pulsewidth (in us) associated with Min position (must be more than 400)
* @param Tmax pulsewidth (in us) associated with Max position (must be less than 2400)
* @return 0 if OK, any other value if FAIL
*/
int setLimits (int Tmin, int Tmax);
/**
* Set the position of the Servo
*
* @param position float number between 0 and 1 (0 = Min, 1 = Max)
*/
void write (float position);
/**
* A short hand for write
*/
RC_Servo& operator= (float position);
private :
int _pMin, _pMax;
protected :
PwmOut _pwm ;
};
#endif //GP2A_H
