Accessories
Arduino for motors and lights library.
PortTwoPins.hpp
1 //-------------------------------------------------------------------
2 #ifndef __PortTwoPins_H__
3 #define __PortTwoPins_H__
4 //-------------------------------------------------------------------
5 
6 #include "Port.hpp"
7 
10 class PortTwoPins : public Port
11 {
12  protected:
17  int pinA;
22  int pinB;
23 
24  public:
26  PortTwoPins();
27 
33  void begin(int inPinA, int inPinB, PIN_TYPE inType);
34 
38  inline bool IsActive() const { return this->pinA > -1; }
42  inline int GetPinA() const { if (this->GetPinType() < ANALOG) return GPIO_to_Arduino_pin((GPIO_pin_t)this->pinA); return this->pinA; }
46  inline GPIO_pin_t GetDIOPinA() const { if (this->GetPinType() < ANALOG) return (GPIO_pin_t)this->pinA; return DP_INVALID; }
50  inline int GetPinB() const { if (this->GetPinType() < ANALOG) return GPIO_to_Arduino_pin((GPIO_pin_t)this->pinB); return this->pinB; }
54  inline GPIO_pin_t GetDIOPinB() const { if (this->GetPinType() < ANALOG) return (GPIO_pin_t)this->pinB; return DP_INVALID; }
55 
59  void MoveLeftDir(unsigned long inDuration = 0);
63  void MoveRightDir(unsigned long inDuration = 0);
65  void MoveStop();
66 
67 #ifdef ACCESSORIES_PRINT_ACCESSORIES
68 
71  void printPort();
72 #endif
73 
74  private:
75  void Move(int inValA, int inValB);
76 };
77 
78 //-------------------------------------------------------------------
79 #endif
80 //-------------------------------------------------------------------
void MoveStop()
Definition: PortTwoPins.cpp:79
void MoveRightDir(unsigned long inDuration = 0)
Definition: PortTwoPins.cpp:50
void MoveLeftDir(unsigned long inDuration = 0)
Definition: PortTwoPins.cpp:21
GPIO_pin_t GetDIOPinB() const
Definition: PortTwoPins.hpp:54
int GetPinB() const
Definition: PortTwoPins.hpp:50
int GetPinA() const
Definition: PortTwoPins.hpp:42
bool IsActive() const
Definition: PortTwoPins.hpp:38
virtual void begin()
Definition: Port.hpp:114
GPIO_pin_t GetDIOPinA() const
Definition: PortTwoPins.hpp:46
PIN_TYPE GetPinType() const
Definition: Port.hpp:74
Definition: Port.hpp:61