RCKit
DigitalSetter.h
1 // DigitalSetter.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: DigitalSetter.h,v 1.2 2010/06/28 00:56:10 mikem Exp $
8 
9 #ifndef DigitalSetter_h
10 #define DigitalSetter_h
11 
12 #include "Setter.h"
13 #include <inttypes.h>
14 
15 /////////////////////////////////////////////////////////////////////
16 /// \class DigitalSetter DigitalSetter.h <DigitalSetter.h>
17 /// \brief Setter class that sets its value to an analog output pin
18 ///
19 class DigitalSetter : public Setter
20 {
21 public:
22  /// \param[in] pin The pin number of the digital output to set
23  /// Caller is expected to have set it as an output already
24  DigitalSetter(uint8_t pin);
25 
26  /// Set or change the output pin
27  /// \param[in] pin The Arduino pin to use for output
28  void setPin(uint8_t pin);
29 
30  /// Input the value to be used to set the analog output
31  /// Digital outputs are 0 or 1
32  /// Inout 0 produces digital output of 0. All other values produce output of 1
33  /// \param[in] value The input 0 for off, all other values for on
34  virtual void input(int value);
35 
36  /// Called when the source of input data is lost, and the Setter is required to fail in a safe way
37  virtual void failsafe();
38 protected:
39 
40 private:
41  /// The analog output pin number
42  uint8_t _pin;
43 };
44 
45 #endif