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 all 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
49 changes: 42 additions & 7 deletions src/ESP_FlexyStepper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,16 @@ ESP_FlexyStepper::~ESP_FlexyStepper()
// TODO: use https://github.com/nrwiersma/ESP8266Scheduler/blob/master/examples/simple/simple.ino for ESP8266
bool ESP_FlexyStepper::startAsService(int coreNumber)
{

if (coreNumber == 1)
if (coreNumber == 0)
{
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
disableCore0WDT(); // 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
}
else if (coreNumber == 0)
#if !(CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S2)
else if (coreNumber == 1)
{
disableCore0WDT(); // 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
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
{
// invalid core number given
Expand Down Expand Up @@ -340,7 +341,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 +419,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 +611,40 @@ 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