Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix : function name for acceleration and deceleration getters #39

Merged
merged 8 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 39 additions & 2 deletions src/ESP_FlexyStepper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ bool ESP_FlexyStepper::startAsService(int coreNumber)

if (coreNumber == 1)
{
#if ! (CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S2)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In such a case the whole if statement in the previous line would not make sense, since it would result in an empty block.
Please refactor so that we do not have an empty if block at all. Might need to simply exchange the if / else order.
At the end on such MCUs the function should return false if 1 is given as core number

disableCore1WDT(); // we have to disable the Watchdog timer to prevent it from rebooting the ESP all the time another option would be to add a vTaskDelay but it would slow down the stepper
#endif
}
else if (coreNumber == 0)
{
Expand Down Expand Up @@ -340,7 +342,7 @@ void ESP_FlexyStepper::setEnablePin(signed char enablePin, byte activeState)
this->enablePinActiveState = ESP_FlexyStepper::ACTIVE_LOW;
}

if(this->enablePin >= 0)
if (this->enablePin >= 0)
{
// configure the IO pins
pinMode((uint8_t)this->enablePin, OUTPUT);
Expand Down Expand Up @@ -418,7 +420,7 @@ bool ESP_FlexyStepper::isBrakeActive()
*/
void ESP_FlexyStepper::enableDriver(void)
{
if (this->_isEnableConfigured)
if (this->_isEnableConfigured)
{
digitalWrite((uint8_t)this->enablePin, (this->enablePinActiveState == ESP_FlexyStepper::ACTIVE_HIGH) ? 1 : 0);
this->_isDriverEnabled = true;
Expand Down Expand Up @@ -610,6 +612,41 @@ float ESP_FlexyStepper::getCurrentVelocityInMillimetersPerSecond()
return (getCurrentVelocityInStepsPerSecond() / stepsPerMillimeter);
}

/*
access the acceleration/deceleration parameters set by user
*/

float ESP_FlexyStepper::getConfiguredAccelerationInStepsPerSecondPerSecond()
{
return acceleration_InStepsPerSecondPerSecond;
}

float ESP_FlexyStepper::getConfiguredAccelerationInRevolutionsPerSecondPerSecond()
{
return acceleration_InStepsPerSecondPerSecond / stepsPerRevolution;
}

float ESP_FlexyStepper::getConfiguredAccelerationInMillimetersPerSecondPerSecond()
{
return acceleration_InStepsPerSecondPerSecond / stepsPerMillimeter;
}

float ESP_FlexyStepper::getConfiguredDecelerationInStepsPerSecondPerSecond()
{
return deceleration_InStepsPerSecondPerSecond;
}

float ESP_FlexyStepper::getConfiguredDecelerationInRevolutionsPerSecondPerSecond()
{
return deceleration_InStepsPerSecondPerSecond / stepsPerRevolution;
}

float ESP_FlexyStepper::getConfiguredDecelerationInMillimetersPerSecondPerSecond()
{
return deceleration_InStepsPerSecondPerSecond / stepsPerMillimeter;
}


// ---------------------------------------------------------------------------------
// Public functions with units in revolutions
// ---------------------------------------------------------------------------------
Expand Down
8 changes: 8 additions & 0 deletions src/ESP_FlexyStepper.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,14 @@ class ESP_FlexyStepper
float getCurrentVelocityInRevolutionsPerSecond();
float getCurrentVelocityInMillimetersPerSecond(void);

float getConfiguredAccelerationInStepsPerSecondPerSecond();
float getConfiguredAccelerationInRevolutionsPerSecondPerSecond();
float getConfiguredAccelerationInMillimetersPerSecondPerSecond();

float getConfiguredDecelerationInStepsPerSecondPerSecond();
float getConfiguredDecelerationInRevolutionsPerSecondPerSecond();
float getConfiguredDecelerationInMillimetersPerSecondPerSecond();

// positioning functions
void setCurrentPositionInSteps(long currentPositionInSteps);
void setCurrentPositionInMillimeters(float currentPositionInMillimeters);
Expand Down