Accessories
Arduino for motors and lights library.
AccessoryStepper Class Reference

#include "AccessoryStepper.hpp"

Inheritance diagram for AccessoryStepper:
Accessory

Public Member Functions

 AccessoryStepper ()
 
bool CanBePositional () const
 
void begin (Port *inpPort, int inStepsNumber, int inReduction, unsigned int inSpeed = 0, int inMovingPositionsNumber = 1)
 
void Event (unsigned long inId, ACCESSORIES_EVENT_TYPE inEvent = ACCESSORIES_EVENT_MOVEPOSITIONINDEX, int inData = 0)
 
void StartCalibration ()
 
void EndCalibration ()
 
void MovePosition (int inAbsolutePosition)
 
void MoveRelativePosition (int inRelativePosition)
 
void Move (unsigned long inId)
 
ACC_STATE MoveToggle ()
 
- Public Member Functions inherited from Accessory
 Accessory ()
 
void begin (ACC_STATE inStartingState = STATE_NONE)
 
PortGetPort () const
 
ACC_STATE GetState () const
 
ACC_STATE GetPreviousState () const
 
bool IsNone () const
 
bool IsFirst () const
 
bool IsSecond () const
 
unsigned int GetDebounceDelay () const
 
unsigned long GetLastMoveTime () const
 
unsigned long GetDuration () const
 
bool loop ()
 
virtual int EEPROMSave (int inPos, bool inSimulate = false)
 
virtual int EEPROMLoad (int inPos)
 
uint8_t AddMovingPosition (unsigned long inId, int inPosition)
 
uint8_t AddMovingPositions (const MovingPosition *inMovingPositions_P)
 
void AdjustMovingPositionsSize (uint8_t inNewSize)
 
bool IsEmpty () const
 
uint8_t IndexOfMovingPositionById (unsigned long inId) const
 
int GetMovingPositionValueById (unsigned long inId) const
 
int GetMovingPositionValueByIndex (uint8_t inIndex) const
 
unsigned long GetMovingPositionIdByIndex (uint8_t inIndex) const
 
const uint8_t GetLastMovingPosition () const
 
const uint8_t GetMovingPositionSize () const
 
void SetLastMovingPosition (uint8_t inLastPositionIndex)
 
void SetDebounceDelay (unsigned int inDebounceDelay)
 
void SetLastMoveTime ()
 
void SetDuration (unsigned long inDuration)
 
void SetNextAccessory (Accessory *inAccessory)
 
Accessory * GetNextAccessory () const
 
unsigned long GetActionStartingMillis () const
 
virtual void StartAction ()
 
virtual void StartAction (ACC_STATE inState)
 
virtual void ResetAction ()
 
bool IsActionDelayPending () const
 
virtual bool IsGroupActionPending () const
 
virtual void SetState (ACC_STATE inNewState)
 
void SetStateRaw (ACC_STATE inNewState)
 
void SetStartingMillis ()
 
void ResetStartingMillis ()
 

Additional Inherited Members

- Static Public Member Functions inherited from Accessory
static void ExecuteEvent (unsigned long inId, ACCESSORIES_EVENT_TYPE inEvent = ACCESSORIES_EVENT_MOVEPOSITIONID, int inData = 0)
 
static uint8_t GetCount ()
 
static bool IsActionPending ()
 
static Accessory * GetFirstAccessory ()
 
- Protected Attributes inherited from Accessory
PortpPort
 
ACC_STATE prevState
 

Detailed Description

This class describes a stepper motor powered by a port. See http://www.tigoe.net/pcomp/code/circuits/motors/stepper-motors/ to explanations about the stepper motors. This class can handle two or four coils motors, by using two or four pins and activate them in the right order. Every stepper motor can differ from a brand/model to another one with the order of activations to apply (the sequence), so this can be defined manually by the user for the PortStepper of this Accessory.

By construction, this kind of motor can only move with relative values. This class maintains a current position and is able to move this motor in absolute mode. To continue with construction facts, a stepper motor can have a tolerance for the movements.

Events handled :

id type data effect
stepper id ACCESSORIES_EVENT_TOGGLE Move to the next position in moving positions array.
stepper id ACCESSORIES_EVENT_MOVE ACCESSORIES_MOVE_STRAIGHT Moves the stepper to minimum position...
stepper id ACCESSORIES_EVENT_MOVE ACCESSORIES_MOVE_TOP Stops the stepper.
stepper id ACCESSORIES_EVENT_MOVE ACCESSORIES_MOVE_LEFT Stops the stepper.
stepper id ACCESSORIES_EVENT_MOVE ACCESSORIES_MOVE_DIVERGE Stops the stepper.
stepper id ACCESSORIES_EVENT_MOVE ACCESSORIES_MOVE_BOTTOM Stops the stepper.
stepper id ACCESSORIES_EVENT_MOVE ACCESSORIES_MOVE_RIGHT Stops the stepper.
stepper id ACCESSORIES_EVENT_MOVE ACCESSORIES_MOVE_STOP Stops the stepper.
stepper id ACCESSORIES_EVENT_MOVE ACCESSORIES_MOVE_OFF Stops the stepper.
stepper id ACCESSORIES_EVENT_MOVE ACCESSORIES_MOVE_MORE Move to the next position in moving positions array.
stepper id ACCESSORIES_EVENT_MOVE ACCESSORIES_MOVE_LESS Move to the previous position in moving positions array.
stepper id ACCESSORIES_EVENT_MOVEPOSITION Absolute value to reach Moves the stepper to the given position.
stepper position id ACCESSORIES_EVENT_MOVEPOSITIONID Use the id to reach this moving position
stepper position id ACCESSORIES_EVENT_MOVEPOSITIONINDEX Index Use the index to reach this moving position
stepper id ACCESSORIES_EVENT_SETSPEED New speed Change the current speed.
stepper id ACCESSORIES_EVENT_SETDURATION New duration Change the current duration.

Definition at line 44 of file AccessoryStepper.hpp.

Constructor & Destructor Documentation

AccessoryStepper::AccessoryStepper ( )

Default constructor.

Definition at line 13 of file AccessoryStepper.cpp.

Member Function Documentation

void AccessoryStepper::begin ( Port inpPort,
int  inStepsNumber,
int  inReduction,
unsigned int  inSpeed = 0,
int  inMovingPositionsNumber = 1 
)

Initialize the instance.

Parameters
inpPortPort driven this motor.
inStepsNumberNumber of steps for a complete rotation of the axis. You can find it in the motor's data-sheet.
inReductionreduction between the motorized axis and the output axis. You can find it in the motor's data-sheet.
inSpeedSpeed to control power to the motor. Default is 0.
inMovingPositionsNumberNumber of steps for one movement. Default is 1 step.

Definition at line 18 of file AccessoryStepper.cpp.

bool AccessoryStepper::CanBePositional ( ) const
inlinevirtual

Checks if the accessory can be moved by an absolute value instead of a fix position.

Returns
true if the accessory can be moved with move() function using an absolute value.

Reimplemented from Accessory.

Definition at line 59 of file AccessoryStepper.hpp.

void AccessoryStepper::EndCalibration ( )
inline

Not yet implemented.

Definition at line 81 of file AccessoryStepper.hpp.

void AccessoryStepper::Event ( unsigned long  inId,
ACCESSORIES_EVENT_TYPE  inEvent = ACCESSORIES_EVENT_MOVEPOSITIONINDEX,
int  inData = 0 
)
virtual

Execute a new event.

Parameters
inIdId of an accessory or an accessory item.
inEventType of the new event. Default is ACCESSORIES_EVENT_MOVEPOSITIONID.
inDataAssociated data to the event type. Default is 0.

Reimplemented from Accessory.

Definition at line 95 of file AccessoryStepper.cpp.

void AccessoryStepper::Move ( unsigned long  inId)
virtual

Basic moving function.

Parameters
[in]inIdnew position id from MovingPosition to reach.

Implements Accessory.

Definition at line 52 of file AccessoryStepper.cpp.

void AccessoryStepper::MovePosition ( int  inAbsolutePosition)
virtual

Move to the given absolute value..

Parameters
[in]inAbsolutePositionnew position to reach.

Reimplemented from Accessory.

Definition at line 68 of file AccessoryStepper.cpp.

void AccessoryStepper::MoveRelativePosition ( int  inRelativePosition)

Move of the given value.

Parameters
[in]inRelativePositionmovement to do. Can be positive or negative.

Definition at line 81 of file AccessoryStepper.cpp.

ACC_STATE AccessoryStepper::MoveToggle ( )

Move to the next MovingPosition.

Returns
returns the new state.

Definition at line 32 of file AccessoryStepper.cpp.

void AccessoryStepper::StartCalibration ( )
inline

Not yet implemented.

Definition at line 79 of file AccessoryStepper.hpp.


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