Skip to content
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
2 changes: 1 addition & 1 deletion src/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ void readConfig()
params[6] = (uint8_t)0; // backlash
params[7] = false; // deactivate output

if (command == kTypeStepperDeprecated2) {
if (command == kTypeStepperDeprecated2 || command == kTypeStepper) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops!

params[4] = readUintFromEEPROM(&addreeprom); // Button number
}

Expand Down
31 changes: 26 additions & 5 deletions src/MF_Stepper/MFStepper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ void MFStepper::detach()

void MFStepper::moveTo(long newPosition)
{
if (!_initialized)
return;

_resetting = false;
long currentPosition = _stepper->currentPosition();

Expand All @@ -100,13 +103,11 @@ void MFStepper::moveTo(long newPosition)
}
}

uint8_t MFStepper::getZeroPin()
{
return _zeroPin;
}

void MFStepper::setZero()
{
if (!_initialized)
return;

_stepper->setCurrentPosition(0);
if (_inMove == MOVE_CW) {
_stepper->moveTo(-_backlash);
Expand All @@ -115,6 +116,9 @@ void MFStepper::setZero()

void MFStepper::setZeroInReset()
{
if (!_initialized)
return;

if (_resetting) {
_stepper->setCurrentPosition(0);
_resetting = false;
Expand All @@ -123,6 +127,9 @@ void MFStepper::setZeroInReset()

void MFStepper::checkZeroPin()
{
if (!_initialized)
return;

uint8_t newState = (uint8_t)digitalRead(_zeroPin);
if (newState != _zeroPinState) {
_zeroPinState = newState;
Expand All @@ -132,6 +139,9 @@ void MFStepper::checkZeroPin()

void MFStepper::update()
{
if (!_initialized)
return;

_stepper->run();
checkZeroPin();
if (_stepper->currentPosition() == (_targetPos + _backlash * _inMove) && _deactivateOutput) {
Expand All @@ -142,6 +152,9 @@ void MFStepper::update()

void MFStepper::reset()
{
if (!_initialized)
return;

// we are not a auto reset stepper if this pin is 0
if (_zeroPin == 0)
return;
Expand All @@ -159,16 +172,24 @@ void MFStepper::reset()

void MFStepper::setMaxSpeed(uint16_t speed)
{
if (!_initialized)
return;

_stepper->setMaxSpeed(speed);
}

void MFStepper::setAcceleration(uint16_t acceleration)
{
if (!_initialized)
return;

_stepper->setAcceleration(acceleration);
}

void MFStepper::powerSavingMode(bool state)
{
if (!_initialized)
return;
if (state)
_stepper->disableOutputs();
else
Expand Down
1 change: 0 additions & 1 deletion src/MF_Stepper/MFStepper.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class MFStepper
void setMaxSpeed(uint16_t speed);
void setAcceleration(uint16_t acceleration);
void setZero();
uint8_t getZeroPin();
void powerSavingMode(bool state);

private:
Expand Down