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.3 2018/09/17 23:09:57 mikem Exp mikem $
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
DigitalSetter::DigitalSetter
DigitalSetter(uint8_t pin)
Definition: DigitalSetter.cpp:17
Setter::_failsafeValue
int _failsafeValue
Definition: Setter.h:63
DigitalSetter
Setter class that sets its value to an analog output pin.
Definition: DigitalSetter.h:19
DigitalSetter::failsafe
virtual void failsafe()
Called when the source of input data is lost, and the Setter is required to fail in a safe way.
Definition: DigitalSetter.cpp:37
DigitalSetter::setPin
void setPin(uint8_t pin)
Definition: DigitalSetter.cpp:23
DigitalSetter::input
virtual void input(int value)
Definition: DigitalSetter.cpp:29
Setter
Virtual base class for classes that receive a value, maybe transform it and then do something with it...
Definition: Setter.h:25