00001 // DigitalSetter.h 00002 // 00003 // Setter class that outputs its value to a analog output pin 00004 /// \author Mike McCauley (mikem@open.com.au) 00005 /// 00006 // Copyright (C) 2010 Mike McCauley 00007 // $Id: DigitalSetter.h,v 1.2 2010/06/28 00:56:10 mikem Exp $ 00008 00009 #ifndef DigitalSetter_h 00010 #define DigitalSetter_h 00011 00012 #include "Setter.h" 00013 #include <inttypes.h> 00014 00015 ///////////////////////////////////////////////////////////////////// 00016 /// \class DigitalSetter DigitalSetter.h <DigitalSetter.h> 00017 /// \brief Setter class that sets its value to an analog output pin 00018 /// 00019 class DigitalSetter : public Setter 00020 { 00021 public: 00022 /// \param[in] pin The pin number of the digital output to set 00023 /// Caller is expected to have set it as an output already 00024 DigitalSetter(uint8_t pin); 00025 00026 /// Set or change the output pin 00027 /// \param[in] pin The Arduino pin to use for output 00028 void setPin(uint8_t pin); 00029 00030 /// Input the value to be used to set the analog output 00031 /// Digital outputs are 0 or 1 00032 /// Inout 0 produces digital output of 0. All other values produce output of 1 00033 /// \param[in] value The input 0 for off, all other values for on 00034 virtual void input(int value); 00035 00036 /// Called when the source of input data is lost, and the Setter is required to fail in a safe way 00037 virtual void failsafe(); 00038 protected: 00039 00040 private: 00041 /// The analog output pin number 00042 uint8_t _pin; 00043 }; 00044 00045 #endif