Accessories
Arduino for motors and lights library.
PortOnePin Class Reference

#include "PortOnePin.hpp"

Inheritance diagram for PortOnePin:
Port

Public Member Functions

 PortOnePin ()
 
void begin (int inPin, PIN_TYPE inType)
 
int SetSpeed (int inSpeed)
 
bool IsActive () const
 
int GetPin () const
 
GPIO_pin_t GetDIOPin () const
 
void MoveLeftDir (unsigned long inDuration = 0)
 
void MoveRightDir (unsigned long inDuration = 0)
 
void MoveStop ()
 
- Public Member Functions inherited from Port
 Port ()
 
virtual void begin ()
 
virtual void beginByAccessory (int inStartingPosition)
 
PIN_TYPE GetPinType () const
 
PORT_STATE GetState () const
 
int GetSpeed () const
 
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 pin
 
- Protected Attributes inherited from Port
PIN_TYPE pinType
 
PORT_STATE state
 
int speed
 

Additional Inherited Members

- Protected Member Functions inherited from Port
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
 

Detailed Description

This class describes a port for a simple accessory driven by only one wire, one pin. Lights and uncoupling track can be driven by this kind of port.

Definition at line 10 of file PortOnePin.hpp.

Constructor & Destructor Documentation

PortOnePin::PortOnePin ( )

Default constructor.

Definition at line 11 of file PortOnePin.cpp.

Member Function Documentation

void PortOnePin::begin ( int  inPin,
PIN_TYPE  inType 
)

Initialize the instance.

Parameters
inPinpin to drive.
inTypekind of pin.

Definition at line 16 of file PortOnePin.cpp.

GPIO_pin_t PortOnePin::GetDIOPin ( ) const
inline

Gets the Arduino pin.

Returns
Pin number in DIO2 mode.

Definition at line 47 of file PortOnePin.hpp.

int PortOnePin::GetPin ( ) const
inline

Gets the Arduino pin.

Returns
Pin number in Arduino mode.

Definition at line 43 of file PortOnePin.hpp.

bool PortOnePin::IsActive ( ) const
inline

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

Returns
true if the pin number is different than -1.

Definition at line 39 of file PortOnePin.hpp.

void PortOnePin::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.

Definition at line 35 of file PortOnePin.cpp.

void PortOnePin::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.

Definition at line 54 of file PortOnePin.cpp.

void PortOnePin::MoveStop ( )
virtual

Sets the current state of the port to PORT_STOP.

Reimplemented from Port.

Definition at line 73 of file PortOnePin.cpp.

int PortOnePin::SetSpeed ( int  inSpeed)
virtual

Sets the current speed of the port.

Parameters
inSpeednew current speed of the port.
Returns
Previous speed.
Remarks
Speed is only available on ANALOG or ANALOG_INVERTED type of pin.

Reimplemented from Port.

Definition at line 22 of file PortOnePin.cpp.

Member Data Documentation

int PortOnePin::pin
protected

Main 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 PortOnePin.hpp.


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