RCKit
AnalogSetter.h
1 // AnalogSetter.h
2 //
3 // Setter class that outputs its value to a analog output pin
4 /// \author Mike McCauley (mikem@airspayce.com)
5 ///
6 // Copyright (C) 2010 Mike McCauley
7 // $Id: AnalogSetter.h,v 1.2 2010/06/21 01:33:53 mikem Exp $
8 
9 #ifndef AnalogSetter_h
10 #define AnalogSetter_h
11 
12 #include "Setter.h"
13 #include <inttypes.h>
14 
15 /////////////////////////////////////////////////////////////////////
16 /// \class AnalogSetter AnalogSetter.h <AnalogSetter.h>
17 /// \brief Setter class that sets its value to an analog output pin
18 ///
19 class AnalogSetter : public Setter
20 {
21 public:
22  /// \param[in] pin The pin number of the analog output to set
23  AnalogSetter(uint8_t pin);
24 
25  /// Set or change the output pin
26  /// \param[in] pin The Arduino pin to use for output
27  void setPin(uint8_t pin);
28 
29  /// Input the value to be used to set the analog output
30  /// Analog outputs are within the range 0 to 255 for 0.0 to 5.0 V
31  /// On Duemilanove, output is PWM at approx 1kHz
32  /// \param[in] value The input value
33  virtual void input(int value);
34 
35  /// Called when the source of input data is lost, and the Setter is required to fail in a safe way
36  virtual void failsafe();
37 
38 protected:
39 
40 private:
41  /// The analog output pin number
42  uint8_t _pin;
43 };
44 
45 #endif