Accessories
Arduino for motors and lights library.
PortServo Class Reference

#include "PortServo.hpp"

Inheritance diagram for PortServo:
Port

Public Member Functions

 PortServo ()
 
void begin (int inPin)
 
void beginByAccessory (int inStartingPosition)
 
bool IsActive () const
 
int GetPin () const
 
GPIO_pin_t GetDIOPin () const
 
void MovePosition (unsigned long inDuration, int inEndPosition)
 
int GetPosition ()
 
- Public Member Functions inherited from Port
 Port ()
 
virtual void begin ()
 
PIN_TYPE GetPinType () const
 
PORT_STATE GetState () const
 
int GetSpeed () const
 
virtual int SetSpeed (int inSpeed)
 
bool IsLeftDir () const
 
bool IsRightDir () const
 
bool IsStopped () const
 
virtual void MoveLeftDir (unsigned long inDuration = 0)
 
virtual void MoveRightDir (unsigned long inDuration = 0)
 
void MoveLeftDir (unsigned long inDuration, int inSpeed)
 
void MoveRightDir (unsigned long inDuration, int inSpeed)
 
PORT_STATE MoveToggle (unsigned long inDuration = 0)
 
virtual void MoveStop ()
 

Protected Attributes

int pin
 
Servo servo
 
- 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

As the name of the class try to tell, this class s dedicated for a servo port. It uses the library Servo installed with the Arduino IDE.

Definition at line 13 of file PortServo.hpp.

Constructor & Destructor Documentation

PortServo::PortServo ( )

Default constructor.

Definition at line 11 of file PortServo.cpp.

Member Function Documentation

void PortServo::begin ( int  inPin)

Initialize the instance.

Parameters
inPinCommand pin for the servo.

Definition at line 17 of file PortServo.cpp.

void PortServo::beginByAccessory ( int  inStartingPosition)
virtual

Initialize the starting position of the servo.

Parameters
inStartingPositionNew position. The servo will physically move if necessary !

Reimplemented from Port.

Definition at line 24 of file PortServo.cpp.

GPIO_pin_t PortServo::GetDIOPin ( ) const
inline

Gets the pin.

Returns
Pin number in DIO2 mode.

Definition at line 45 of file PortServo.hpp.

int PortServo::GetPin ( ) const
inline

Gets the pin.

Returns
Pin number in Arduino mode.

Definition at line 41 of file PortServo.hpp.

int PortServo::GetPosition ( )
virtual

Gets the current position of the port.

Returns
Current position of the port.

Reimplemented from Port.

Definition at line 60 of file PortServo.cpp.

bool PortServo::IsActive ( ) const
inline

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

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

Definition at line 37 of file PortServo.hpp.

void PortServo::MovePosition ( unsigned long  inDuration,
int  inEndPosition 
)
virtual

Move the servo to the given position using a given duration.

Parameters
inDurationthe movement should take the time of this delay.
inEndPositionfinal position to reach.

Reimplemented from Port.

Definition at line 42 of file PortServo.cpp.

Member Data Documentation

int PortServo::pin
protected

Command pin connected to the servo.

Definition at line 17 of file PortServo.hpp.

Servo PortServo::servo
protected

Instance of the class Servo.

Definition at line 19 of file PortServo.hpp.


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