Accessories
Arduino for motors and lights library.
PortTwoPins Class Reference

#include "PortTwoPins.hpp"

Inheritance diagram for PortTwoPins:
Port PortTwoPinsEnable

Public Member Functions

 PortTwoPins ()
 
void begin (int inPinA, int inPinB, PIN_TYPE inType)
 
bool IsActive () const
 
int GetPinA () const
 
GPIO_pin_t GetDIOPinA () const
 
int GetPinB () const
 
GPIO_pin_t GetDIOPinB () const
 
void MoveLeftDir (unsigned long inDuration = 0)
 
void MoveRightDir (unsigned long inDuration = 0)
 
void MoveStop ()
 
- Public Member Functions inherited from Port
PIN_TYPE GetPinType () const
 
PORT_STATE GetPortState () const
 
void SetPinType (PIN_TYPE inType)
 
void SetPortState (PORT_STATE inState)
 
int MapValue (int inValue, PIN_TYPE inType = UNDEFINED) const
 
int beginPin (int inPin, PIN_TYPE inType = UNDEFINED) const
 
void MovePin (int inPin, int inValue, PIN_TYPE inType = UNDEFINED) const
 
 Port ()
 
virtual void begin ()
 
virtual void beginByAccessory (int inStartingPosition)
 
int GetSpeed () const
 
virtual int SetSpeed (int inSpeed)
 
bool IsLeftDir () const
 
bool IsRightDir () const
 
bool IsStopped () const
 
void MoveLeftDir (unsigned long inDuration, int inSpeed)
 
void MoveRightDir (unsigned long inDuration, int inSpeed)
 
PORT_STATE MoveToggle (unsigned long inDuration = 0)
 
virtual void MovePosition (unsigned long inDuration, int inEndPosition)
 
virtual int GetPosition ()
 

Protected Attributes

int pinA
 
int pinB
 
- Protected Attributes inherited from Port
int speed
 
byte type_state
 

Detailed Description

This class describes a port for an accessory driven by two wires, two pins. Some turnouts or motors can be driven by this port.

Definition at line 10 of file PortTwoPins.hpp.

Constructor & Destructor Documentation

PortTwoPins::PortTwoPins ( )

Default constructor.

Definition at line 9 of file PortTwoPins.cpp.

Member Function Documentation

void PortTwoPins::begin ( int  inPinA,
int  inPinB,
PIN_TYPE  inType 
)

Initialize the instance.

Parameters
inPinAfirst pin to drive.
inPinBsecond pin to drive.
inTypekind of both pins.

Definition at line 13 of file PortTwoPins.cpp.

GPIO_pin_t PortTwoPins::GetDIOPinA ( ) const
inline

Gets the first Arduino pin.

Returns
Pin A number in DIO2 mode.

Definition at line 46 of file PortTwoPins.hpp.

GPIO_pin_t PortTwoPins::GetDIOPinB ( ) const
inline

Gets the second Arduino pin.

Returns
Pin B number in DIO2 mode.

Definition at line 54 of file PortTwoPins.hpp.

int PortTwoPins::GetPinA ( ) const
inline

Gets the first Arduino pin.

Returns
Pin A number in Arduino mode.

Definition at line 42 of file PortTwoPins.hpp.

int PortTwoPins::GetPinB ( ) const
inline

Gets the second Arduino pin.

Returns
Pin B number in Arduino mode.

Definition at line 50 of file PortTwoPins.hpp.

bool PortTwoPins::IsActive ( ) const
inline

Checks if this port is active. To be active, begin() must have been called.

Returns
true if the first pin number (pinA) is different than -1.

Definition at line 38 of file PortTwoPins.hpp.

void PortTwoPins::MoveLeftDir ( unsigned long  inDuration = 0)
virtual

Sets the current state of the port to PORT_LEFT.

Parameters
inDurationthe pins will be activated to left for the given delay.

Reimplemented from Port.

Reimplemented in PortTwoPinsEnable.

Definition at line 21 of file PortTwoPins.cpp.

void PortTwoPins::MoveRightDir ( unsigned long  inDuration = 0)
virtual

Sets the current state of the port to PORT_RIGHT.

Parameters
inDurationthe pins will be activated to right for the given delay.

Reimplemented from Port.

Reimplemented in PortTwoPinsEnable.

Definition at line 50 of file PortTwoPins.cpp.

void PortTwoPins::MoveStop ( )
virtual

Sets the current state of the port to PORT_STOP.

Reimplemented from Port.

Reimplemented in PortTwoPinsEnable.

Definition at line 79 of file PortTwoPins.cpp.

Member Data Documentation

int PortTwoPins::pinA
protected

First pin of this port. ANALOG or ANALOG_INVERTED : Classic Arduino pin number DIGITAL or DIGITAL_INVERTED : GPIO_pin_t casted in an integer.

Definition at line 17 of file PortTwoPins.hpp.

int PortTwoPins::pinB
protected

Second pin of this port. ANALOG or ANALOG_INVERTED : Classic Arduino pin number DIGITAL or DIGITAL_INVERTED : GPIO_pin_t casted in an integer.

Definition at line 22 of file PortTwoPins.hpp.


The documentation for this class was generated from the following files: