Skip to content

Commit

Permalink
Merge pull request #39 from ameisso/master
Browse files Browse the repository at this point in the history
Fix : function name for acceleration and deceleration getters
  • Loading branch information
pkerspe authored Jan 16, 2024
2 parents 216b021 + 345d2d7 commit 80fa50c
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 7 deletions.
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

0 comments on commit 80fa50c

Please sign in to comment.