Pulse Width Modulation RC Servomotor Library compatible with classic and extended models. Models limit are customizable
Dependents: FRC_2018 0hackton_08_06_18 0hackton_08_06_18_publish Kenya_2019 ... more
RC_Servo.h
- Committer:
- haarkon
- Date:
- 2018-05-21
- Revision:
- 0:b8dcca3dc509
- Child:
- 1:8482eba4d652
File content as of revision 0:b8dcca3dc509:
/** * @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 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