Skip to content

Commit

Permalink
Merge pull request #77 from laurb9/get-steps
Browse files Browse the repository at this point in the history
Added getStepsCompleted(), getStepsRemaining(), getDirection() incorp…
  • Loading branch information
laurb9 authored Jan 28, 2019
2 parents 9a0479b + aeb7fea commit 665355c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/BasicStepperDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,12 @@ void BasicStepperDriver::startBrake(void){
}
}
/*
* Stop movement immediately.
* Stop movement immediately and return remaining steps.
*/
void BasicStepperDriver::stop(void){
long BasicStepperDriver::stop(void){
long retval = steps_remaining;
steps_remaining = 0;
return retval;
}
/*
* Return calculated time to complete the given move
Expand Down
24 changes: 22 additions & 2 deletions src/BasicStepperDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,33 @@ class BasicStepperDriver {
void startBrake(void);
/*
* Immediate stop
* Returns the number of steps remaining.
*/
void stop(void);
long stop(void);
/*
* State querying
*/
enum State getCurrentState(void);

/*
* Get the number of completed steps so far.
* This is always a positive number
*/
long getStepsCompleted(void){
return step_count;
}
/*
* Get the number of steps remaining to complete the move
* This is always a positive number
*/
long getStepsRemaining(void){
return steps_remaining;
}
/*
* Get movement direction: forward +1, back -1
*/
int getDirection(void){
return (dir_state == HIGH) ? 1 : -1;
}
/*
* Return calculated time to complete the given move
*/
Expand Down

0 comments on commit 665355c

Please sign in to comment.