pkerspe / ESP-StepperMotor-Server

Turn your ESP32 into a complete stepper motor control server with web UI, REST API and serial control interface
MIT License
225 stars 39 forks source link

ESP IO pin for motor brake is not saved #25

Closed dibg closed 2 years ago

dibg commented 3 years ago

Describe the bug "Save current configuration to device" button doesn't save the "ESP IO pin for motor brake" setting. On the next boot this must be re entered. I use the brake functionality to enable/disable the power of the stepper to save power.

Environment the same with : https://github.com/pkerspe/ESP-StepperMotor-Server/issues/24

Extra INFO This is what api/comfig returns

{

  "serverConfiguration": {

    "port": 80,

    "wififMode": 2,

    "wifiSsid": "******",

    "wifiPassword": "*****",

    "apName": "@",

    "apPassword": "*****"

  },

  "stepperConfigurations": [

    {

      "id": 0,

      "name": "X-Axis",

      "stepPin": 23,

      "directionPin": 22,

      "stepsPerRev": 200,

      "stepsPerMM": 100,

      "microsteppingDivisor": 8,

      "rpmLimit": 1200

    }

  ],

  "switchConfigurations": [],

  "rotaryEncoderConfigurations": []

And this is what i asked to be saved

Screenshot from 2021-02-20 11-55-06

denonbw commented 2 years ago

Sadly I have the same problem. As an interim solution you can simply create the stepper via Config and define the pin there.

void setup() 
{
  Serial.begin(115200);
  stepperMotorServer = new ESPStepperMotorServer(ESPServerRestApiEnabled | ESPServerWebserverEnabled | ESPServerSerialEnabled);
  stepperMotorServer->setWifiCredentials(wifiName, wifiSecret);
  stepperMotorServer->setWifiMode(ESPServerWifiModeClient); //start the server as a wifi client (DHCP client of an existing wifi network)

  stepperConfiguration = new ESPStepperMotorServer_StepperConfiguration(STEP_PIN, DIRECTION_PIN);
  stepperConfiguration->setDisplayName("M1");
  stepperConfiguration->setMicrostepsPerStep(1);
  stepperConfiguration->setBrakeIoPin(5, 1);
  stepperConfiguration->setStepsPerMM(200);
  stepperConfiguration->setStepsPerRev(800);
  stepperMotorServer->addOrUpdateStepper(stepperConfiguration);

  stepperMotorServer->start();
}
pkerspe commented 2 years ago

Currently adding the following details to the configuration persistence logic:

nestedStepperConfig["breakPin"] = stepperConfig->getBrakeIoPin();
nestedStepperConfig["breakPinActiveState"] = stepperConfig->getBrakePinActiveState();
nestedStepperConfig["breakEngageDelay"] = stepperConfig->getBrakeEngageDelayMs();
nestedStepperConfig["breakReleaseDelay"] = stepperConfig->getBrakeReleaseDelayMs();

Pushed to master branch, not yet tested

pkerspe commented 2 years ago

Has been fixed in version v0.4.8