kusano kiyoshige / servo

Dependents:   17robo_fuzi 17robo_tokyo_kaede

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers servo.h Source File

servo.h

00001 /*
00002 
00003 
00004 */
00005 
00006 #ifndef MBED_SERVO_H
00007 #define MBED_SERVO_H
00008 #include "mbed.h"
00009 
00010 class Servo {
00011 
00012 public:
00013     Servo(PinName pin);
00014     void write(float percent);
00015     void setRange(float maxrange, float minrange);
00016     void setMax();
00017     void setMin();
00018     float read();
00019     void position(float degrees);
00020     
00021     /**  Allows calibration of the range and angles for a particular servo
00022      *
00023      * @param range Pulsewidth range from center (1.5ms) to maximum/minimum position in seconds
00024      * @param degrees Angle from centre to maximum/minimum position in degrees
00025      */
00026     //range : 1.5msを中心とした、最大最小までのパルス幅の指定
00027     //degrees : 中心から最大最小までの角度の指定
00028     void calibrate(float range = 0.0005, float degrees = 45.0); 
00029         
00030     /**  Shorthand for the write and read functions */
00031     Servo& operator= (float percent);
00032     Servo& operator= (Servo& rhs);
00033     operator float();
00034 
00035 protected:
00036     PwmOut _pwm;
00037     float _range;
00038     float _degrees;
00039     float _p;
00040     float maxRange, minRange;
00041 };
00042 
00043 #endif