gin66 / FastAccelStepper

A high speed stepper library for Atmega 168/328p (nano), Atmega32u4, Atmega 2560, ESP32, ESP32S2, ESP32S3, ESP32C3 and Atmel SAM Due
MIT License
283 stars 67 forks source link

External autoEnable also controls pin 0 #199

Closed Carl-UB closed 9 months ago

Carl-UB commented 10 months ago

When using an external enable pin, and with autoEnable on, running the stepper motors also controls pin 0.

Failing test & workaround with test here.

Seems likely to be due to the _enablePinHighActive being 0 by default and not being changed when setting enable pins. Could it be instead initialised to PIN_UNDEFINED? It should still then be able to be set to a new value by the user but would avoid this bug.

Workaround is to manually call stepper->setEnablePin(PIN_UNDEFINED, false); to set _enablePinHighActive manually.

I presume that _enablePinLowActive could have the same sort of problem, I haven't tested that.

Carl-UB commented 10 months ago

Issue actually also occurs without external pins being used. Have updated the example repo and added tests using internal pins as well.

gin66 commented 10 months ago

Yes. Apparently the initialization of the internal variables _enablePinHighActive and _enablePinLowActive are missing.

gin66 commented 10 months ago

Could you please check, if this patch works as expected ?

Carl-UB commented 9 months ago

Yep, looks like that has worked. Thanks!