hardware classes

Dependencies:   mbed

Committer:
UAVguy
Date:
Wed Jun 02 21:40:10 2010 +0000
Revision:
0:1fc280fa2177

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
UAVguy 0:1fc280fa2177 1 #include "stdint.h"
UAVguy 0:1fc280fa2177 2 #include "mbed.h"
UAVguy 0:1fc280fa2177 3
UAVguy 0:1fc280fa2177 4 class Servo : private PwmOut
UAVguy 0:1fc280fa2177 5 {
UAVguy 0:1fc280fa2177 6 private:
UAVguy 0:1fc280fa2177 7 int period;
UAVguy 0:1fc280fa2177 8 int center;
UAVguy 0:1fc280fa2177 9 int maximum;
UAVguy 0:1fc280fa2177 10 int minimum;
UAVguy 0:1fc280fa2177 11 int position;
UAVguy 0:1fc280fa2177 12
UAVguy 0:1fc280fa2177 13 public:
UAVguy 0:1fc280fa2177 14 Servo(PinName);
UAVguy 0:1fc280fa2177 15 //constructor sets defaults and starts servo with 0% duty cycle
UAVguy 0:1fc280fa2177 16 void setposition (int);
UAVguy 0:1fc280fa2177 17 //set normalized servo position (-255 to 255), default = 0
UAVguy 0:1fc280fa2177 18 void setperiod (int);
UAVguy 0:1fc280fa2177 19 //set the period in us, default = 20000
UAVguy 0:1fc280fa2177 20 void setcenter (int);
UAVguy 0:1fc280fa2177 21 //set center deflection pulse width in us, default = 1500
UAVguy 0:1fc280fa2177 22 void setmaximum (int);
UAVguy 0:1fc280fa2177 23 //set maximum deflection pulse width in us, default = 2400
UAVguy 0:1fc280fa2177 24 void setminimum (int);
UAVguy 0:1fc280fa2177 25 //set minimum deflection pulse width in us, default = 600
UAVguy 0:1fc280fa2177 26 Servo& operator =(int);
UAVguy 0:1fc280fa2177 27 //shorthand for setposition, ex: "ServoObj = 231;"
UAVguy 0:1fc280fa2177 28 operator int();
UAVguy 0:1fc280fa2177 29 //shorthand for position reading, ex: "check = ServoObj;"
UAVguy 0:1fc280fa2177 30 /*NOTE: setposition must be called before any changes to
UAVguy 0:1fc280fa2177 31 period, center, maximum, or minimum can take effect*/
UAVguy 0:1fc280fa2177 32 };