#include "AccessoryServo.hpp"
Public Member Functions | |
AccessoryServo () | |
int | GetMinimumPosition () const |
int | GetMaximumPosition () const |
int | GetCurrentPosition () const |
void | SetMinMax (int inMinimum, int inMaximum) |
void | AddMinMaxMovingPositions (unsigned long inIdMin, unsigned long inIdMax) |
bool | IsMinimumOrLowerPosition () const |
bool | IsMaximumOrGreaterPosition () const |
bool | IsMiscPosition () const |
MovementSpeed | GetMovementSpeed () const |
bool | CanBePositional () const |
void | begin (Port *inpPort, unsigned long inDurationMilli = 0, int inMinimumPosition = 0, int inMaximumPosition = 180, int inMovingPositionsNumber = 1) |
void | SetPowerCommand (int inPin, unsigned long inDelay = 100) |
void | Event (unsigned long inId, ACCESSORIES_EVENT_TYPE inEvent = ACCESSORIES_EVENT_MOVEPOSITIONID, int inData = 0) |
int | EEPROMLoad (int inPos) |
void | MovePosition (int inPosition) |
void | Move (unsigned long inId) |
void | MoveMinimum () |
void | MoveMaximum () |
ACC_STATE | MoveToggle () |
![]() | |
Accessory () | |
void | begin (ACC_STATE inStartingState = STATE_NONE) |
Port * | GetPort () const |
ACC_STATE | GetState () const |
ACC_STATE | GetPreviousState () const |
bool | IsNone () const |
bool | IsFirst () const |
bool | IsSecond () const |
uint8_t | AddMovingPosition (unsigned long inId, int inPosition) |
unsigned int | GetDebounceDelay () const |
unsigned long | GetLastMoveTime () const |
unsigned long | GetDuration () const |
bool | loop () |
virtual int | EEPROMSave (int inPos, bool inSimulate = false) |
void | AdjustMovingPositionsSize (uint8_t inNewSize) |
bool | IsEmpty () const |
uint8_t | IndexOfMovingPosition (unsigned long inId) const |
int | GetMovingPosition (unsigned long inId) const |
int | GetMovingPositionByIndex (int inIndex) const |
unsigned long | GetMovingPositionIdByIndex (int 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 |
void | SetStateRaw (ACC_STATE inNewState) |
void | SetStartingMillis () |
void | ResetStartingMillis () |
Additional Inherited Members | |
![]() | |
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 () |
![]() | |
Port * | pPort |
ACC_STATE | prevState |
This class describes a servo powered by a port. A servo has a minimum, a maximum and a current position.
A movement can be splitted into small steps with a duration for each one.
Use AddMinMaxMovingPositions() to define MovingPosition for minimum and maximum positions. Use AddMovingPosition() to define intermediate positions.
To avoid erratic movements when the servo dont move, its power can be stopped by a pin connected to a relay or a transistor. In this case, the movement is:
MovePosition() Activate pin, power delay, full movement, power delay, Disactivate pin.
Definition at line 63 of file AccessoryServo.hpp.
AccessoryServo::AccessoryServo | ( | ) |
Default constructor.
Definition at line 12 of file AccessoryServo.cpp.
|
inline |
Defines two MovingPosition for minimum and maximum positions.
inIdMin | id for minimum position. |
inIdMax | id for maximum position. |
Definition at line 104 of file AccessoryServo.hpp.
void AccessoryServo::begin | ( | Port * | inpPort, |
unsigned long | inDurationMilli = 0 , |
||
int | inMinimumPosition = 0 , |
||
int | inMaximumPosition = 180 , |
||
int | inMovingPositionsNumber = 1 |
||
) |
Initialize the instance.
inpPort | Port driven this motor. |
inDurationMilli | Duration in milliseconds of a step for the movement. If 0, the movement will go as fast as possible. Default is 0. |
inMinimumPosition | Minimum position in degrees. Default is 0. |
inMaximumPosition | Maximum position in degrees. Default is 180. |
inMovingPositionsNumber | Size of a step for movement. Default is 1 degree. |
Definition at line 20 of file AccessoryServo.cpp.
|
inlinevirtual |
Checks if the accessory can be moved by an absolute value instead of a fix position.
Reimplemented from Accessory.
Definition at line 128 of file AccessoryServo.hpp.
|
virtual |
|
virtual |
Execute a new event.
inId | Id of an accessory or an accessory item. |
inEvent | Type of the new event. Default is ACCESSORIES_EVENT_MOVEPOSITIONID. |
inData | Associated data to the event type. Default is 0. |
Reimplemented from Accessory.
Definition at line 142 of file AccessoryServo.cpp.
|
inline |
Gets the current position of this servo.
Definition at line 92 of file AccessoryServo.hpp.
|
inline |
Gets the maximum position of this servo.
Definition at line 87 of file AccessoryServo.hpp.
|
inline |
Gets the minimum position of this servo.
Definition at line 82 of file AccessoryServo.hpp.
MovementSpeed AccessoryServo::GetMovementSpeed | ( | ) | const |
Gets the movement speed computed internally.
Definition at line 358 of file AccessoryServo.cpp.
|
inline |
Checks if the maximum position is reached.
Definition at line 114 of file AccessoryServo.hpp.
|
inline |
Checks if the minimum position is reached.
Definition at line 109 of file AccessoryServo.hpp.
|
inline |
Checks if the current position is in the limits.
Definition at line 119 of file AccessoryServo.hpp.
|
virtual |
Basic moving function.
[in] | inId | new position id from MovingPosition to reach. |
Implements Accessory.
Definition at line 113 of file AccessoryServo.cpp.
void AccessoryServo::MoveMaximum | ( | ) |
Move to maximum position.
Definition at line 60 of file AccessoryServo.cpp.
void AccessoryServo::MoveMinimum | ( | ) |
Move to minimum position.
Definition at line 51 of file AccessoryServo.cpp.
|
virtual |
Move to the given position.
[in] | inPosition | new position to reach in degrees. |
Reimplemented from Accessory.
Definition at line 134 of file AccessoryServo.cpp.
ACC_STATE AccessoryServo::MoveToggle | ( | ) |
Change from minimum to maximum or maximum to minimum.
Definition at line 69 of file AccessoryServo.cpp.
|
inline |
Sets the minimum and maximum positions.
inMinimum | minimum position in degrees. |
inMaximum | maximum position in degrees. |
Definition at line 98 of file AccessoryServo.hpp.
void AccessoryServo::SetPowerCommand | ( | int | inPin, |
unsigned long | inDelay = 100 |
||
) |
Sets the pin to control the servo power.
inPin | pin to set to HIGH to activate servo power. |
inDelay | delay to wait after the activation before starting the movement, and after the end of the movement before unactivate the pin. |
Definition at line 41 of file AccessoryServo.cpp.