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
Diff: RC_Servo.h
- Revision:
- 0:b8dcca3dc509
- Child:
- 1:8482eba4d652
diff -r 000000000000 -r b8dcca3dc509 RC_Servo.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/RC_Servo.h Mon May 21 15:55:54 2018 +0000 @@ -0,0 +1,78 @@ +/** + * @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 \ No newline at end of file