AccelStepperI2C
v 0.1
I2C wrapper (and a bit more) for the AccelStepper Arduino library
|
Go to the documentation of this file.
60 #ifndef AccelStepperI2C_h
61 #define AccelStepperI2C_h
63 #define DEBUG // uncomment for debug output to Serial (which has to be begun() in the main sketch)
66 #include <AccelStepper.h>
70 #define log(...) Serial.print(__VA_ARGS__)
204 void attach(uint8_t interface = AccelStepper::FULL4WIRE,
212 void moveTo(
long absolute);
213 void move(
long relative);
267 void setPinsInverted(
bool directionInvert =
false,
bool stepInvert =
false,
bool enableInvert =
false);
268 void setPinsInverted(
bool pin1Invert,
bool pin2Invert,
bool pin3Invert,
bool pin4Invert,
bool enableInvert);
313 void setEndstopPin(int8_t pin,
bool activeLow,
bool internalPullup);
const uint8_t diagnosticsCmd
A helper class for the AccelStepperI2C (and ServoI2C) library.
boolean runSpeedToPosition()
Don't use this, use state machine instead with runSpeedToPositionState().
const uint8_t interruptReason_endstopHit
const uint8_t diagnosticsResult
void setPinsInverted(bool directionInvert=false, bool stepInvert=false, bool enableInvert=false)
void setState(uint8_t newState)
Set the state machine's state manually.
const uint8_t state_runSpeed
corresponds to AccelStepper::runSpeed(), will remain active until stopped by user or endstop
const uint8_t setMinPulseWidthCmd
const uint8_t interruptReason_targetReachedByRunSpeedToPosition
void moveTo(long absolute)
const uint8_t speedResult
const uint8_t runToNewPositionCmd
void setEnablePin(uint8_t enablePin=0xff)
const uint8_t currentPositionResult
void diagnostics(diagnosticsReport *report)
Get most recent diagnostics data. Needs diagnostics enabled and a slave which was compiled with the D...
const uint8_t isRunningCmd
void stopState()
Will stop any of the above states, i.e. stop polling. It does nothing else, so the master is solely i...
void runSpeedState()
Will poll runSpeed(), i.e. run at constant speed until told otherwise (see AccelStepperI2C::stopState...
const uint8_t runSpeedCmd
uint32_t cycles
Number of slave's main loop executions since the last reboot.
const uint8_t enableDiagnosticsCmd
const uint8_t disableOutputsCmd
const uint8_t setMaxSpeedCmd
int8_t myNum
Stepper number with myNum >= 0 for successfully added steppers.
const uint8_t enableInterruptsCmd
const uint8_t targetPositionResult
const uint8_t getStateResult
uint8_t endstops()
Read current state of endstops.
const uint8_t AccelStepperI2CmaxBuf
const uint8_t currentPositionCmd
An I2C wrapper class for the AccelStepper library.
const uint8_t endstopsResult
void setMaxSpeed(float speed)
uint16_t lastProcessTime
microseconds the slave needed to process (interpret) most recently received command
boolean run()
Don't use this, use state machine instead with runState().
const uint8_t setPinsInverted1Cmd
A helper class for the AccelStepperI2C (and ServoI2C) library.
const uint8_t runSpeedResult
const uint8_t state_run
corresponds to AccelStepper::run(), will fall back to state_stopped if target reached or endstop hit
AccelStepperI2C(I2Cwrapper *w)
Constructor.
const uint8_t getStateCmd
void enableDiagnostics(bool enable)
Turn on/off diagnostic speed logging.
void runSpeedToPositionState()
Will poll runSpeedToPosition(), i.e. run at constant speed until target has been reached.
const uint8_t setEnablePinCmd
void runToNewPosition(long position)
This is a blocking function in the original, it will only return after the new target has been reache...
const uint8_t runSpeedToPositionResult
void runState()
Will poll run(), i.e. run to the target with acceleration and stop the state machine upon reaching it...
void setAcceleration(float acceleration)
const uint8_t setAccelerationCmd
const uint8_t setPinsInverted2Cmd
const uint8_t setCurrentPositionCmd
const uint8_t state_stopped
stepper state machine states
const uint8_t attachResult
boolean runSpeed()
Don't use this, use state machine instead with runSpeedState().
Used to transmit diagnostic info with AccelStepperI2C::diagnostics().
const uint8_t endstopsCmd
const uint8_t setEndstopPinCmd
void setSpeed(float speed)
const uint8_t distanceToGoCmd
const uint8_t maxSpeedCmd
const uint8_t state_runSpeedToPosition
corresponds to AccelStepper::state_runSpeedToPosition(), will fall back to state_stopped if target po...
const uint8_t isRunningResult
const uint8_t targetPositionCmd
void attach(uint8_t interface=AccelStepper::FULL4WIRE, uint8_t pin1=2, uint8_t pin2=3, uint8_t pin3=4, uint8_t pin4=5, bool enable=true)
Replaces the AccelStepper constructor and takes the same arguments. Will allocate an AccelStepper obj...
const uint8_t enableOutputsCmd
void setCurrentPosition(long position)
void enableInterrupts(bool enable=true)
Start or stop sending interrupts to master for this stepper. An interrupt will be sent whenever a sta...
void setEndstopPin(int8_t pin, bool activeLow, bool internalPullup)
Define a new endstop pin. Each stepper can have up to two, so don't call this more than twice per ste...
const uint8_t runToPositionCmd
void runToPosition()
This is a blocking function in the original, it will only return after the target has been reached....
const uint8_t setSpeedCmd
uint8_t getState()
Read the state machine's state (it may have been changed by endstop or target reached condition).
const uint8_t setStateCmd
const uint8_t enableEndstopsCmd
void setMinPulseWidth(unsigned int minWidth)
uint16_t lastRequestTime
microseconds the slave spent in the most recent onRequest() interrupt
void enableEndstops(bool enable=true)
Tell the state machine to check the endstops regularly. If any of the (one or two) stepper's endstops...
const uint8_t interruptReason_targetReachedByRun
const uint8_t runSpeedToPositionCmd
const uint8_t maxSpeedResult
uint16_t lastReceiveTime
microseconds the slave spent in the most recent onReceive() interrupt
const uint8_t distanceToGoResult