00001 // ServoSetter.h 00002 // 00003 // Setter class that outputs its value to a Servo 00004 /// \author Mike McCauley (mikem@open.com.au) 00005 /// 00006 // Copyright (C) 2010 Mike McCauley 00007 // $Id: ServoSetter.h,v 1.2 2010/06/21 01:33:53 mikem Exp $ 00008 00009 #ifndef ServoSetter_h 00010 #define ServoSetter_h 00011 00012 #include "Setter.h" 00013 00014 class Servo; 00015 00016 ///////////////////////////////////////////////////////////////////// 00017 /// \class ServoSetter ServoSetter.h <ServoSetter.h> 00018 /// \brief Setter class that limits its input to between specified min and max values 00019 /// 00020 class ServoSetter : public Setter 00021 { 00022 public: 00023 /// \param[in] servo The target Servo instance. It is the callers job to attach the Servo to 00024 /// the servo output pin 00025 ServoSetter(Servo* servo); 00026 00027 /// Input the value to be used to set the servo 00028 /// Servos are controlled within the range 0 to 180 degrees 00029 /// Input values in the range 0-255 are scaled to 0-180 00030 /// Values outside that range are limited to 0 and 255 00031 /// \param[in] value The input value 00032 virtual void input(int value); 00033 00034 /// Called when the source of input data is lost, and the Setter is required to fail in a safe way 00035 virtual void failsafe(); 00036 00037 protected: 00038 00039 private: 00040 Servo* _servo; 00041 }; 00042 00043 #endif