src/ESPStepperMotorServer.cpp
int ESPStepperMotorServer::addOrUpdateStepper(ESPStepperMotorServer_StepperConfiguration *stepper, int stepperIndex)
{
    if (stepper->getStepIoPin() == ESPStepperMotorServer_StepperConfiguration::ESPServerStepperUnsetIoPinNumber ||
        stepper->getDirectionIoPin() == ESPStepperMotorServer_StepperConfiguration::ESPServerStepperUnsetIoPinNumber)
    {
        ESPStepperMotorServer_Logger::logWarningf("Either the step IO pin (%i) or direction IO (%i) pin, or both, are not set correctly. Use a valid IO Pin value between 0 and the highest available IO Pin on your ESP\n", stepper->getStepIoPin(), stepper->getDirectionIoPin());
        return -1;
    }
    //set IO Pins for stepper
    pinMode(stepper->getDirectionIoPin(), OUTPUT);
    digitalWrite(stepper->getDirectionIoPin(), LOW);
    pinMode(stepper->getStepIoPin(), OUTPUT);
    digitalWrite(stepper->getStepIoPin(), LOW);
    //add stepper to configuration or update existing one
    if (stepperIndex > -1)
    {
        this->serverConfiguration->setStepperConfiguration(stepper, stepperIndex);
    }
    else
    {
        stepperIndex = this->serverConfiguration->addStepperConfiguration(stepper);
    }

    return stepperIndex;
}
/**
 * add or updated an existing stepper configuration
 * return the id of the stepper config (in case a new one has been added, or the given one in case of an update)
 * -1 is returned in case of an error (e.g. maximum number of configs reached for this entity)
 */
add or updated an existing stepper configuration
return the id of the stepper config (in case a new one has been added, or the given one in case of an update)
-1 is returned in case of an error
add or updated an existing stepper configuration return the id of the stepper config ( in case a new one has been added or the given one in case of an update ) - 1 is returned in case of an error
int ESPStepperMotorServer::addOrUpdateStepper(ESPStepperMotorServer_StepperConfiguration *stepper, int stepperIndex)
{
    if (stepper->getStepIoPin() == ESPStepperMotorServer_StepperConfiguration::ESPServerStepperUnsetIoPinNumber ||
        stepper->getDirectionIoPin() == ESPStepperMotorServer_StepperConfiguration::ESPServerStepperUnsetIoPinNumber)
    {
        ESPStepperMotorServer_Logger::logWarningf("Either the step IO pin (%i) or direction IO (%i) pin, or both, are not set correctly. Use a valid IO Pin value between 0 and the highest available IO Pin on your ESP\n", stepper->getStepIoPin(), stepper->getDirectionIoPin());
        return -1;
    }
    pinMode(stepper->getDirectionIoPin(), OUTPUT);
    digitalWrite(stepper->getDirectionIoPin(), LOW);
    pinMode(stepper->getStepIoPin(), OUTPUT);
    digitalWrite(stepper->getStepIoPin(), LOW);
    if (stepperIndex > -1)
    {
        this->serverConfiguration->setStepperConfiguration(stepper, stepperIndex);
    }
    else
    {
        stepperIndex = this->serverConfiguration->addStepperConfiguration(stepper);
    }
    return stepperIndex;
}
int ESPStepperMotorServer :: addOrUpdateStepper ( ESPStepperMotorServer_StepperConfiguration * stepper , int stepperIndex ) { if ( stepper -> getStepIoPin ( ) == ESPStepperMotorServer_StepperConfiguration :: ESPServerStepperUnsetIoPinNumber || stepper -> getDirectionIoPin ( ) == ESPStepperMotorServer_StepperConfiguration :: ESPServerStepperUnsetIoPinNumber ) { ESPStepperMotorServer_Logger :: logWarningf ( " \n " , stepper -> getStepIoPin ( ) , stepper -> getDirectionIoPin ( ) ) ; return -1 ; } pinMode ( stepper -> getDirectionIoPin ( ) , OUTPUT ) ; digitalWrite ( stepper -> getDirectionIoPin ( ) , LOW ) ; pinMode ( stepper -> getStepIoPin ( ) , OUTPUT ) ; digitalWrite ( stepper -> getStepIoPin ( ) , LOW ) ; if ( stepperIndex > -1 ) { this -> serverConfiguration -> setStepperConfiguration ( stepper , stepperIndex ) ; } else { stepperIndex = this -> serverConfiguration -> addStepperConfiguration ( stepper ) ; } return stepperIndex ; }
add or updated an existing stepper configuration
 return the id of the stepper config (in case a new one has been added, or the given one in case of an update)
 -1 is returned in case of an error (e.g.
add or updated an existing stepper configuration return the id of the stepper config ( in case a new one has been added or the given one in case of an update ) - 1 is returned in case of an error ( e . g .
//set IO Pins for stepper //add stepper to configuration or update existing one