Skip to content

Commit

Permalink
fixed bug if no callback function handler was specified for target po…
Browse files Browse the repository at this point in the history
…sition
  • Loading branch information
pkerspe committed Jul 12, 2020
1 parent 439f4f3 commit 92e49cc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"type": "git",
"url": "https://github.com/pkerspe/ESP-FlexyStepper.git"
},
"version": "1.3",
"version": "1.3.1",
"license": "MIT",
"frameworks": "arduino",
"platforms": [
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=ESP-FlexyStepper
version=1.3
version=1.3.1
author=Paul Kerspe
maintainer=Paul Kerspe
sentence=This library is used to control one or more stepper motors from an ESP32 device
Expand Down
9 changes: 7 additions & 2 deletions src/ESP_FlexyStepper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1012,10 +1012,12 @@ bool ESP_FlexyStepper::processMovement(void)
if (this->isOnWayToHome)
{
this->setCurrentPositionAsHomeAndStop(); //clear isOnWayToHome flag and stop motion
if (this->_homeReachedCallback)

if (this->_homeReachedCallback != NULL)
{
this->_homeReachedCallback();
}

return true;
}
}
Expand Down Expand Up @@ -1110,7 +1112,10 @@ bool ESP_FlexyStepper::processMovement(void)
if (this->firstProcessingAfterTargetReached)
{
firstProcessingAfterTargetReached = false;
this->_targetPositionReachedCallback();
if (this->_targetPositionReachedCallback)
{
this->_targetPositionReachedCallback();
}
}
return (true);
}
Expand Down
12 changes: 6 additions & 6 deletions src/ESP_FlexyStepper.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,12 @@ class ESP_FlexyStepper
static const byte LIMIT_SWITCH_COMBINED_BEGIN_AND_END = 2;

private:
callbackFunction _homeReachedCallback;
callbackFunction _limitTriggeredCallback;
callbackFunction _emergencyStopTriggeredCallback;
callbackFunction _emergencyStopReleasedCallback;
callbackFunction _targetPositionReachedCallback;
callbackFunction _callbackFunctionForGoToLimit;
callbackFunction _homeReachedCallback = NULL;
callbackFunction _limitTriggeredCallback = NULL;
callbackFunction _emergencyStopTriggeredCallback = NULL;
callbackFunction _emergencyStopReleasedCallback = NULL;
callbackFunction _targetPositionReachedCallback = NULL;
callbackFunction _callbackFunctionForGoToLimit = NULL;

static void taskRunner(void *parameter);

Expand Down

0 comments on commit 92e49cc

Please sign in to comment.