Accessories
Arduino for motors and lights library.
PortSpeedDirBrake Class Reference

#include "PortSpeedDirBrake.hpp"

Inheritance diagram for PortSpeedDirBrake:
Port

Public Member Functions

 PortSpeedDirBrake ()
 
void begin (int inPinPWM, int inPinDir, int inPinBrake, PIN_TYPE inPWMType, PIN_TYPE inDigitalType)
 
bool IsActive () const
 
int GetPinPWM () const
 
int GetPinDir () const
 
GPIO_pin_t GetDIOPinDir () const
 
int GetPinBrake () const
 
GPIO_pin_t GetDIOPinBrake () 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)
 
PORT_STATE GetState () const
 
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 Member Functions

int MapDigitalValue (int inValue) const
 
- 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
 

Protected Attributes

int pinPWM
 
PIN_TYPE digitalType
 
GPIO_pin_t pinDir
 
GPIO_pin_t pinBrake
 
- Protected Attributes inherited from Port
PIN_TYPE pinType
 
PORT_STATE state
 
int speed
 

Detailed Description

This class describes a port for a motor driver like a LMD18200. Three pins will be used, for PWM, dir and brake connectors of the driver. PWM pin gives the power, the speed, dir pin gives the direction. One direction is when the pin is LOW, the other when the pin is HIGH. brake pin stops the motor if it is HIGH.

Definition at line 14 of file PortSpeedDirBrake.hpp.

Constructor & Destructor Documentation

PortSpeedDirBrake::PortSpeedDirBrake ( )

Default constructor.

Definition at line 11 of file PortSpeedDirBrake.cpp.

Member Function Documentation

void PortSpeedDirBrake::begin ( int  inPinPWM,
int  inPinDir,
int  inPinBrake,
PIN_TYPE  inPWMType,
PIN_TYPE  inDigitalType 
)

Initialize the instance.

Parameters
inPinPWMAnalog pin for power.
inPinDirDigital direction pin.
inPinBrakeBrake pin.
inPWMTypekind of analog PWM pin. Can be only ANALOG or ANALOG_INVERTED.
inDigitalTypekind of both digital pins dir and brake. Can only be DIGITAL or DIGITAL_INVERTED..

Definition at line 16 of file PortSpeedDirBrake.cpp.

GPIO_pin_t PortSpeedDirBrake::GetDIOPinBrake ( ) const
inline

Gets the brake pin.

Returns
Pin A number in DIO2 mode.

Definition at line 74 of file PortSpeedDirBrake.hpp.

GPIO_pin_t PortSpeedDirBrake::GetDIOPinDir ( ) const
inline

Gets the direction pin.

Returns
Pin A number in DIO2 mode.

Definition at line 66 of file PortSpeedDirBrake.hpp.

int PortSpeedDirBrake::GetPinBrake ( ) const
inline

Gets the brake pin.

Returns
pin number in Arduino mode.

Definition at line 70 of file PortSpeedDirBrake.hpp.

int PortSpeedDirBrake::GetPinDir ( ) const
inline

Gets the direction pin.

Returns
pin number in Arduino mode.

Definition at line 62 of file PortSpeedDirBrake.hpp.

int PortSpeedDirBrake::GetPinPWM ( ) const
inline

Gets the PWM pin.

Returns
pin number in Arduino mode.

Definition at line 58 of file PortSpeedDirBrake.hpp.

bool PortSpeedDirBrake::IsActive ( ) const
inline

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

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

Definition at line 54 of file PortSpeedDirBrake.hpp.

int PortSpeedDirBrake::MapDigitalValue ( int  inValue) const
protected

Map the digital value (HIGH o LOW) according to the inverted or not type of the pin.

Parameters
inValuevalue to map.
Returns
returns the adapted value according to the pin type :
type LOW HIGH
DIGITAL LOW HIGH
DIGITAL_INVERTED HIGH LOW

Definition at line 37 of file PortSpeedDirBrake.cpp.

void PortSpeedDirBrake::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 49 of file PortSpeedDirBrake.cpp.

void PortSpeedDirBrake::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 69 of file PortSpeedDirBrake.cpp.

void PortSpeedDirBrake::MoveStop ( )
virtual

Sets the current state of the port to PORT_STOP.

Reimplemented from Port.

Definition at line 88 of file PortSpeedDirBrake.cpp.

Member Data Documentation

PIN_TYPE PortSpeedDirBrake::digitalType
protected

Type of digital pins dir and brake.

Definition at line 20 of file PortSpeedDirBrake.hpp.

GPIO_pin_t PortSpeedDirBrake::pinBrake
protected

Brake pin of this port.

Definition at line 24 of file PortSpeedDirBrake.hpp.

GPIO_pin_t PortSpeedDirBrake::pinDir
protected

Direction pin of this port.

Definition at line 22 of file PortSpeedDirBrake.hpp.

int PortSpeedDirBrake::pinPWM
protected

PWM pin.

Definition at line 18 of file PortSpeedDirBrake.hpp.


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