Skip to content

Commit

Permalink
Added getStepsCompleted(), getStepsRemaining(), getDirection() incorp…
Browse files Browse the repository at this point in the history
…orating changes from

#72 by @harrylisby
#73 by @tognotommy

Addresses #57 and #45
  • Loading branch information
laurb9 committed Jan 28, 2019
1 parent 9a0479b commit aeb7fea
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 aeb7fea

Please sign in to comment.