PM2_Lib

Dependencies:   LSM9DS1 RangeFinder FastPWM

Committer:
pmic
Date:
Tue Mar 22 08:33:25 2022 +0000
Revision:
18:21c0a669d6ef
Parent:
16:69911e81dfd4
Child:
20:ea222b81350e
Introduced min and max value for input in Servo class (bugfix)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
pmic 0:86129f1b4a93 1 /* mbed Servo Library without using PWM pins
pmic 0:86129f1b4a93 2 * Copyright (c) 2010 Jasper Denkers
pmic 0:86129f1b4a93 3 *
pmic 0:86129f1b4a93 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
pmic 0:86129f1b4a93 5 * of this software and associated documentation files (the "Software"), to deal
pmic 0:86129f1b4a93 6 * in the Software without restriction, including without limitation the rights
pmic 0:86129f1b4a93 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
pmic 0:86129f1b4a93 8 * copies of the Software, and to permit persons to whom the Software is
pmic 0:86129f1b4a93 9 * furnished to do so, subject to the following conditions:
pmic 0:86129f1b4a93 10 *
pmic 0:86129f1b4a93 11 * The above copyright notice and this permission notice shall be included in
pmic 0:86129f1b4a93 12 * all copies or substantial portions of the Software.
pmic 0:86129f1b4a93 13 *
pmic 0:86129f1b4a93 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
pmic 0:86129f1b4a93 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
pmic 0:86129f1b4a93 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
pmic 0:86129f1b4a93 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
pmic 0:86129f1b4a93 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
pmic 0:86129f1b4a93 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
pmic 0:86129f1b4a93 20 * THE SOFTWARE.
pmic 0:86129f1b4a93 21 */
pmic 0:86129f1b4a93 22
pmic 0:86129f1b4a93 23 #ifndef MBED_SERVO_H
pmic 0:86129f1b4a93 24 #define MBED_SERVO_H
pmic 0:86129f1b4a93 25
pmic 10:fe74e8909d3f 26 #include "mbed.h"
pmic 10:fe74e8909d3f 27
pmic 4:9c003c402033 28 class Servo
pmic 4:9c003c402033 29 {
pmic 0:86129f1b4a93 30
pmic 0:86129f1b4a93 31 public:
pmic 16:69911e81dfd4 32
pmic 0:86129f1b4a93 33 Servo(PinName Pin);
pmic 16:69911e81dfd4 34 void SetPosition(float _Input);
pmic 16:69911e81dfd4 35 void Enable(float _StartInput, int _Period);
pmic 0:86129f1b4a93 36 void Disable();
pmic 0:86129f1b4a93 37
pmic 0:86129f1b4a93 38 private:
pmic 18:21c0a669d6ef 39
pmic 18:21c0a669d6ef 40 static const float MIN_INPUT;
pmic 18:21c0a669d6ef 41 static const float MAX_INPUT;
pmic 18:21c0a669d6ef 42
pmic 0:86129f1b4a93 43 void StartPulse();
pmic 0:86129f1b4a93 44 void EndPulse();
pmic 0:86129f1b4a93 45
pmic 16:69911e81dfd4 46 int Position, Period;
pmic 0:86129f1b4a93 47 DigitalOut ServoPin;
pmic 0:86129f1b4a93 48 Ticker Pulse;
pmic 0:86129f1b4a93 49 Timeout PulseStop;
pmic 0:86129f1b4a93 50 };
pmic 0:86129f1b4a93 51
pmic 0:86129f1b4a93 52 #endif