Skip to content

Commit

Permalink
Update GyverStepper.h
Browse files Browse the repository at this point in the history
  • Loading branch information
LKosoj committed Feb 10, 2024
1 parent e3398e7 commit 4392246
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions libraries/GyverStepper/src/GyverStepper.h
Original file line number Diff line number Diff line change
Expand Up @@ -391,15 +391,15 @@ class GStepper : public Stepper<_DRV, _TYPE> {
int speed2 = (int)abs(_accelSpeed);
_speedPlannerPrd = map(max(speed1, speed2), 1000, 20000, 15000, 2000);
_speedPlannerPrd = constrain(_speedPlannerPrd, 15000, 2000);
stepTime = abs(1000000.0 / _accelSpeed);
stepTime = abs(1000000.0f / _accelSpeed);
}
} else { // резкий старт
if (speed == 0) { // скорость 0? Отключаемся и выходим
brake();
return;
}
_accelSpeed = _speed;
stepTime = abs(1000000.0 / _speed);
stepTime = abs(1000000.0f / _speed);
}
enable();
}
Expand Down Expand Up @@ -537,7 +537,7 @@ class GStepper : public Stepper<_DRV, _TYPE> {
if (_stopSpeed == 0) _accelSpeed = constrain(_accelSpeed, -_maxSpeed, _maxSpeed); // ограничение
else _accelSpeed = constrain(_accelSpeed, -_stopSpeed, _stopSpeed);

if (abs(_accelSpeed) > _MIN_SPEED_FP) stepTime = abs(1000000.0 / _accelSpeed); // ограничение на мин. скорость
if (abs(_accelSpeed) > _MIN_SPEED_FP) stepTime = abs(1000000.0f / _accelSpeed); // ограничение на мин. скорость
else stepTime = _MAX_PERIOD_FP;
dir = _sign(_accelSpeed); // направление для шагов
}
Expand All @@ -558,7 +558,7 @@ class GStepper : public Stepper<_DRV, _TYPE> {
_speedPlannerTime = tickUs;
_accelSpeed += (_accelTime * _speedPlannerPrd * _sign(_speed - _accelSpeed));
dir = _sign(_accelSpeed);
stepTime = abs(1000000.0 / _accelSpeed);
stepTime = abs(1000000.0f / _accelSpeed);
if (_stopF && abs(_accelSpeed) <= _MIN_STEP_SPEED) brake();
}
}
Expand Down

0 comments on commit 4392246

Please sign in to comment.