Add stepper.set_acceleration and stepper.set_deceleration to stepper component (#1977)

This commit is contained in:
WeekendWarrior1
2021-07-05 11:22:43 +10:00
committed by GitHub
parent ab31117bf3
commit 79b9d0579d
2 changed files with 69 additions and 1 deletions
+30
View File
@@ -77,5 +77,35 @@ template<typename... Ts> class SetSpeedAction : public Action<Ts...> {
Stepper *parent_;
};
template<typename... Ts> class SetAccelerationAction : public Action<Ts...> {
public:
explicit SetAccelerationAction(Stepper *parent) : parent_(parent) {}
TEMPLATABLE_VALUE(float, acceleration);
void play(Ts... x) override {
float acceleration = this->acceleration_.value(x...);
this->parent_->set_acceleration(acceleration);
}
protected:
Stepper *parent_;
};
template<typename... Ts> class SetDecelerationAction : public Action<Ts...> {
public:
explicit SetDecelerationAction(Stepper *parent) : parent_(parent) {}
TEMPLATABLE_VALUE(float, deceleration);
void play(Ts... x) override {
float deceleration = this->deceleration_.value(x...);
this->parent_->set_deceleration(deceleration);
}
protected:
Stepper *parent_;
};
} // namespace stepper
} // namespace esphome