Embed:
(wiki syntax)
Show/hide line numbers
DigitalIn.h
00001 #ifndef CPP_TO_PIGPIO_DIGITALIN_HEADER 00002 #define CPP_TO_PIGPIO_DIGITALIN_HEADER 00003 namespace CPPToPigpio{ 00004 /** The DigitalIn interface is used to read the value of a digital input pin. 00005 */ 00006 class DigitalIn : public CPPToPigpio{ 00007 private: 00008 short _pinNumber; //Internally track which pin this input is on 00009 friend class BusIn; 00010 public: 00011 /** Create a DigitalIn connected to the specified pin 00012 * 00013 * @param pin DigitalIn pin to connect to 00014 */ 00015 DigitalIn(PinName pin); //Construct a Digital Input without a PullUp or PullDown resistor 00016 00017 /** Create a DigitalIn connected to the specified pin 00018 * 00019 * @param pin DigitalIn pin to connect to 00020 * @param mode the initial mode of the pin 00021 */ 00022 DigitalIn(PinName pin, PinMode mode); //mode is PullUp, PullDown, or PullNone 00023 00024 /** Create a DigitalIn connected to the specified pin 00025 * 00026 * @param pin DigitalIn pin to connect to 00027 */ 00028 DigitalIn(int pin); //handles int args as a static cast 00029 00030 /** Create a DigitalIn connected to the specified pin 00031 * 00032 * @param pin DigitalIn pin to connect to 00033 * @param mode the initial mode of the pin 00034 */ 00035 DigitalIn(int pin, PinMode mode); 00036 00037 /** Read the input, represented as 0 or 1 (int) 00038 * 00039 * @returns 00040 * An integer representing the state of the input pin, 00041 * 0 for logical 0, 1 for logical 1 00042 */ 00043 int read(); //longform way to get the value on the pin 00044 00045 /** An operator shorthand for read() 00046 * \sa DigitalIn::read() 00047 */ 00048 operator int(); //conversion operator 00049 00050 /** Set the input pin mode 00051 * 00052 * @param pull PullUp, PullDown, PullNone, OpenDrain 00053 */ 00054 void mode(PinMode mode); //Sets the pin to be PullUp, PullDown, or PullNone 00055 00056 /** Check equality of pin to other DigitalIn pin 00057 */ 00058 bool operator==(int); 00059 00060 /** Check equality of pin to other DigitalIn pin 00061 */ 00062 bool operator==(DigitalIn &); 00063 00064 /** Deconstructor 00065 */ 00066 ~DigitalIn(); 00067 }; 00068 } 00069 #endif
Generated on Tue Jul 12 2022 14:39:23 by
