Calling AccelStepper _direction protected boolean

I'm trying to do things based on the direction the stepper is moving. As a test, I tried running

    while (drive.isRunning())
    {
        Serial.print(drive._direction);
        Serial.println();
    }

but when I wennt to build the sketch I got the error

Building in release mode
Compiling .pio/build/teensy40/src/main.cpp.o
In file included from src/main.cpp:2:0:
/Users/jacksonlindley/.platformio/packages/framework-arduinoteensy/libraries/AccelStepper/src/AccelStepper.h: In function 'void loop()':
/Users/jacksonlindley/.platformio/packages/framework-arduinoteensy/libraries/AccelStepper/src/AccelStepper.h:598:13: error: 'boolean AccelStepper::_direction' is protected
     boolean _direction; // 1 == CW
             ^
src/main.cpp:32:28: error: within this context
         Serial.print(drive._direction);
                            ^
*** [.pio/build/teensy40/src/main.cpp.o] Error 1

Is there a way to create actions based on current direction?

ie if(stepper.isRunning() && stepper._direction == 1) ... do thing

drive.distanceToGo() returns a signed value, the sign will tell you the current direction, and
if its zero you'll know its stopped.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.