Update stepper.cpp to use enum

This commit is contained in:
cvwillegen 2024-05-28 11:40:57 +02:00 committed by GitHub
parent eccf7860b5
commit 6f91a36275
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -38,7 +38,7 @@ int32_t Stepper::should_step_() {
// assumes this method is called in a constant interval
uint32_t dt = now - this->last_step_;
if (dt >= (1 / this->current_speed_) * 1e6f) {
int32_t mag = (rotation_ == 0 ? (this->target_position > this->current_position ? 1 : -1) : rotation_);
int32_t mag = (rotation_ == ROTATION_BOTH ? (this->target_position > this->current_position ? 1 : -1) : (rotation_ == ROTATION_CW ? 1 : -1));
this->last_step_ = now;
this->current_position += mag;
return mag;