first lib
Dependents: 17robo_fuzi 17robo_tokyo_kaede
servo.h@0:41758331f8d1, 2017-09-24 (annotated)
- Committer:
- echo_piyo
- Date:
- Sun Sep 24 06:19:24 2017 +0000
- Revision:
- 0:41758331f8d1
(??)???????????????
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
echo_piyo | 0:41758331f8d1 | 1 | /* |
echo_piyo | 0:41758331f8d1 | 2 | |
echo_piyo | 0:41758331f8d1 | 3 | |
echo_piyo | 0:41758331f8d1 | 4 | */ |
echo_piyo | 0:41758331f8d1 | 5 | |
echo_piyo | 0:41758331f8d1 | 6 | #ifndef MBED_SERVO_H |
echo_piyo | 0:41758331f8d1 | 7 | #define MBED_SERVO_H |
echo_piyo | 0:41758331f8d1 | 8 | #include "mbed.h" |
echo_piyo | 0:41758331f8d1 | 9 | |
echo_piyo | 0:41758331f8d1 | 10 | class Servo { |
echo_piyo | 0:41758331f8d1 | 11 | |
echo_piyo | 0:41758331f8d1 | 12 | public: |
echo_piyo | 0:41758331f8d1 | 13 | Servo(PinName pin); |
echo_piyo | 0:41758331f8d1 | 14 | void write(float percent); |
echo_piyo | 0:41758331f8d1 | 15 | void setRange(float maxrange, float minrange); |
echo_piyo | 0:41758331f8d1 | 16 | void setMax(); |
echo_piyo | 0:41758331f8d1 | 17 | void setMin(); |
echo_piyo | 0:41758331f8d1 | 18 | float read(); |
echo_piyo | 0:41758331f8d1 | 19 | void position(float degrees); |
echo_piyo | 0:41758331f8d1 | 20 | |
echo_piyo | 0:41758331f8d1 | 21 | /** Allows calibration of the range and angles for a particular servo |
echo_piyo | 0:41758331f8d1 | 22 | * |
echo_piyo | 0:41758331f8d1 | 23 | * @param range Pulsewidth range from center (1.5ms) to maximum/minimum position in seconds |
echo_piyo | 0:41758331f8d1 | 24 | * @param degrees Angle from centre to maximum/minimum position in degrees |
echo_piyo | 0:41758331f8d1 | 25 | */ |
echo_piyo | 0:41758331f8d1 | 26 | //range : 1.5msを中心とした、最大最小までのパルス幅の指定 |
echo_piyo | 0:41758331f8d1 | 27 | //degrees : 中心から最大最小までの角度の指定 |
echo_piyo | 0:41758331f8d1 | 28 | void calibrate(float range = 0.0005, float degrees = 45.0); |
echo_piyo | 0:41758331f8d1 | 29 | |
echo_piyo | 0:41758331f8d1 | 30 | /** Shorthand for the write and read functions */ |
echo_piyo | 0:41758331f8d1 | 31 | Servo& operator= (float percent); |
echo_piyo | 0:41758331f8d1 | 32 | Servo& operator= (Servo& rhs); |
echo_piyo | 0:41758331f8d1 | 33 | operator float(); |
echo_piyo | 0:41758331f8d1 | 34 | |
echo_piyo | 0:41758331f8d1 | 35 | protected: |
echo_piyo | 0:41758331f8d1 | 36 | PwmOut _pwm; |
echo_piyo | 0:41758331f8d1 | 37 | float _range; |
echo_piyo | 0:41758331f8d1 | 38 | float _degrees; |
echo_piyo | 0:41758331f8d1 | 39 | float _p; |
echo_piyo | 0:41758331f8d1 | 40 | float maxRange, minRange; |
echo_piyo | 0:41758331f8d1 | 41 | }; |
echo_piyo | 0:41758331f8d1 | 42 | |
echo_piyo | 0:41758331f8d1 | 43 | #endif |