AccelStepperI2C
v 0.1
I2C wrapper (and a bit more) for the AccelStepper Arduino library
|
Go to the documentation of this file.
68 Serial.println(
"Slave not found! Check connections and restart.");
80 if (stepper.myNum < 0) {
81 Serial.println(
"Error: stepper could not be allocated");
85 stepper.setPinsInverted(
false,
false,
true);
86 stepper.enableOutputs();
95 stepper.enableEndstops();
96 if (stepper.endstops() != 0) {
97 Serial.println(
"\nWarning: Please move stepper away from endstop,\n"
98 "because I don't know in which direction I have to move to get away from it.\n\nHALTING.");
99 stepper.disableOutputs();
111 stepper.enableInterrupts();
153 Serial.print(
"Deviations after "); Serial.print(
cycles);
154 Serial.print(
" cycles, measured with a speed of "); Serial.print(sp);
170 stepper.setSpeed(-sp);
171 stepper.runSpeedState();
173 Serial.print(
"Error. Interrupt due to unexpected reason #");
180 stepper.setSpeed(sp);
181 stepper.runSpeedState();
183 Serial.print(
"Error. Interrupt due to unexpected reason.");
188 Serial.print(
"Endstops found at positions 0 (lower endstop) and ");
189 Serial.print(
upperEndStopPos); Serial.println(
" (upper endstop).\n\n");
203 if ((reasonAndUnit & 0xf) != stepper.myNum) {
204 Serial.println(
"Error. Interrupt cause from unknown unit.");
207 return reasonAndUnit >> 4;
221 long offLimits = (
range * chance / 100) / 2;
223 for (
int j = 0; j < repetitions; j++) {
229 Serial.print(
"Target reached as planned, setting new target to ");
231 Serial.println(newPos);
232 stepper.moveTo(newPos);
237 Serial.println(
"Ran into endstop, returning to middle position.");
243 Serial.print(
"Unexpected interrupt reason #");
244 Serial.println(reason);
A helper class for the AccelStepperI2C (and ServoI2C) library.
const uint8_t interruptReason_endstopHit
uint8_t clearInterrupt()
Acknowledge a received interrupt to slave so that it can clear the interupt condition and return the ...
An I2C wrapper class for the AccelStepper library.
void randomWalk(int repetitions, long chance)
const uint8_t interruptPinSlave
const uint8_t interruptPinMaster
bool ping()
Test if slave is listening.
void interruptFromSlave()
uint8_t waitForInterrupt()
void reset()
Tells the slave to reset to it's default state. It is recommended to reset the slave every time the m...
const uint8_t interruptReason_targetReachedByRun
void findEndstops(float sp)
volatile bool interruptFlag
void setInterruptPin(int8_t pin, bool activeHigh=true)
Define a global interrupt pin which can be used by device units (steppers, servos....