#include "PortStepper.hpp"
Public Member Functions | |
PortStepper () | |
void | begin (uint8_t inPin1, uint8_t inPin2, PIN_TYPE inType = DIGITAL, uint8_t *inpSteps = NULL) |
void | begin (uint8_t inPin1, uint8_t inPin2, uint8_t inPin3, uint8_t inPin4, PIN_TYPE inType = DIGITAL, uint8_t *inpSteps = NULL) |
void | MovePosition (unsigned long inDuration, int inEndPosition) |
void | MoveRelativePosition (unsigned long inDuration, int inIncrementalPosition) |
bool | run () |
long | currentPosition () |
long | targetPosition () |
int | GetPosition () |
![]() | |
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 |
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 | |
LocoStepper * | pMotor |
![]() | |
int | speed |
byte | type_state |
This class can drive a stepper motor, using the LocoStepper class.
Positions are specified by a signed long integer. At construction time, the current position of the motor is consider to be 0. Positive positions are clockwise from the initial position; negative positions are anticlockwise. The current position can be altered for instance after initialization positioning.
See LocoStepper class for more information.
Definition at line 25 of file PortStepper.hpp.
PortStepper::PortStepper | ( | ) |
Default constructor.
Definition at line 11 of file PortStepper.cpp.
void PortStepper::begin | ( | uint8_t | inPin1, |
uint8_t | inPin2, | ||
PIN_TYPE | inType = DIGITAL , |
||
uint8_t * | inpSteps = NULL |
||
) |
Initialize the instance of two pins stepper motor.
inPin1 | Command pin 1 for the stepper. |
inPin2 | Command pin 2 for the stepper. |
inType | kind of all the pins. Can be only DIGITAL or DIGITAL_INVERTED. Default is DIGITAL. |
inpSteps | specific step list. Default is NULL. It gives the caller the possibility to fix himself the sequence of pins activation. If nothing is specified, a default value will be used: B01, B11, B10, B00. |
Definition at line 15 of file PortStepper.cpp.
void PortStepper::begin | ( | uint8_t | inPin1, |
uint8_t | inPin2, | ||
uint8_t | inPin3, | ||
uint8_t | inPin4, | ||
PIN_TYPE | inType = DIGITAL , |
||
uint8_t * | inpSteps = NULL |
||
) |
Initialize the instance for four pins stepper motor.
inPin1 | Command pin 1 for the stepper. |
inPin2 | Command pin 2 for the stepper. |
inPin3 | Command pin 3 for the stepper. |
inPin4 | Command pin 4 for the stepper. |
inType | kind of all the pins. Can be only DIGITAL or DIGITAL_INVERTED. Default is DIGITAL. |
inpSteps | specific step list. Default is NULL. It gives the caller the possibility to fix himself the sequence of pins activation. If nothing is specified, a default value will be used: B1010, B0110, B0101, B1001 for four wires stepperThese steps are those working for a 28BYJ very common and inexpensive small stepper. |
Definition at line 20 of file PortStepper.cpp.
|
inline |
|
inlinevirtual |
Gets the current position.
Reimplemented from Port.
Definition at line 93 of file PortStepper.hpp.
|
virtual |
Move the stepper to the given position using a given duration.
inDuration | the movement should take the time of this delay. |
inEndPosition | final position to reach. |
Reimplemented from Port.
Definition at line 45 of file PortStepper.cpp.
void PortStepper::MoveRelativePosition | ( | unsigned long | inDuration, |
int | inIncrementalPosition | ||
) |
Move the servo of the given value from the current position using a given duration.
inDuration | the movement should take the time of this delay. |
inIncrementalPosition | position to move. |
Definition at line 57 of file PortStepper.cpp.
|
inline |
Poll the motor and step it if a step is due. You must call this as frequently as possible, but at least once per minimum step interval, preferably in your main loop.
Definition at line 79 of file PortStepper.hpp.
|
inline |
Gets the target position.
Definition at line 87 of file PortStepper.hpp.
|
protected |
Instance of LocoStepper class.
Definition at line 29 of file PortStepper.hpp.