#include "PortSpeedDirBrake.hpp"
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 () |
![]() | |
Port () | |
virtual void | begin () |
virtual void | beginByAccessory (int inStartingPosition) |
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 |
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 |
![]() | |
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 |
![]() | |
PIN_TYPE | pinType |
PORT_STATE | state |
int | speed |
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.
PortSpeedDirBrake::PortSpeedDirBrake | ( | ) |
Default constructor.
Definition at line 11 of file PortSpeedDirBrake.cpp.
void PortSpeedDirBrake::begin | ( | int | inPinPWM, |
int | inPinDir, | ||
int | inPinBrake, | ||
PIN_TYPE | inPWMType, | ||
PIN_TYPE | inDigitalType | ||
) |
Initialize the instance.
inPinPWM | Analog pin for power. |
inPinDir | Digital direction pin. |
inPinBrake | Brake pin. |
inPWMType | kind of analog PWM pin. Can be only ANALOG or ANALOG_INVERTED. |
inDigitalType | kind of both digital pins dir and brake. Can only be DIGITAL or DIGITAL_INVERTED.. |
Definition at line 16 of file PortSpeedDirBrake.cpp.
|
inline |
Gets the brake pin.
Definition at line 74 of file PortSpeedDirBrake.hpp.
|
inline |
Gets the direction pin.
Definition at line 66 of file PortSpeedDirBrake.hpp.
|
inline |
Gets the brake pin.
Definition at line 70 of file PortSpeedDirBrake.hpp.
|
inline |
Gets the direction pin.
Definition at line 62 of file PortSpeedDirBrake.hpp.
|
inline |
Gets the PWM pin.
Definition at line 58 of file PortSpeedDirBrake.hpp.
|
inline |
Checks if this port is active. To be active, begin() must have been called.
Definition at line 54 of file PortSpeedDirBrake.hpp.
|
protected |
Map the digital value (HIGH o LOW) according to the inverted or not type of the pin.
inValue | value to map. |
type | LOW | HIGH |
---|---|---|
DIGITAL | LOW | HIGH |
DIGITAL_INVERTED | HIGH | LOW |
Definition at line 37 of file PortSpeedDirBrake.cpp.
|
virtual |
Sets the current state of the port to PORT_LEFT.
inDuration | the pins will be activated to left for the given delay. |
Reimplemented from Port.
Definition at line 49 of file PortSpeedDirBrake.cpp.
|
virtual |
Sets the current state of the port to PORT_RIGHT.
inDuration | the pins will be activated to right for the given delay. |
Reimplemented from Port.
Definition at line 69 of file PortSpeedDirBrake.cpp.
|
virtual |
Sets the current state of the port to PORT_STOP.
Reimplemented from Port.
Definition at line 88 of file PortSpeedDirBrake.cpp.
|
protected |
Type of digital pins dir and brake.
Definition at line 20 of file PortSpeedDirBrake.hpp.
|
protected |
Brake pin of this port.
Definition at line 24 of file PortSpeedDirBrake.hpp.
|
protected |
Direction pin of this port.
Definition at line 22 of file PortSpeedDirBrake.hpp.
|
protected |
PWM pin.
Definition at line 18 of file PortSpeedDirBrake.hpp.