mirror of
https://github.com/esphome/esphome.git
synced 2024-12-25 06:54:52 +01:00
a4988 wait 1ms when coming out of sleep (#1597)
This commit is contained in:
parent
848a5f1680
commit
08998caabc
2 changed files with 7 additions and 0 deletions
|
@ -11,6 +11,7 @@ void A4988::setup() {
|
|||
if (this->sleep_pin_ != nullptr) {
|
||||
this->sleep_pin_->setup();
|
||||
this->sleep_pin_->digital_write(false);
|
||||
this->sleep_pin_state_ = false;
|
||||
}
|
||||
this->step_pin_->setup();
|
||||
this->step_pin_->digital_write(false);
|
||||
|
@ -27,7 +28,12 @@ void A4988::dump_config() {
|
|||
void A4988::loop() {
|
||||
bool at_target = this->has_reached_target();
|
||||
if (this->sleep_pin_ != nullptr) {
|
||||
bool sleep_rising_edge = !sleep_pin_state_ & !at_target;
|
||||
this->sleep_pin_->digital_write(!at_target);
|
||||
this->sleep_pin_state_ = !at_target;
|
||||
if (sleep_rising_edge) {
|
||||
delayMicroseconds(1000);
|
||||
}
|
||||
}
|
||||
if (at_target) {
|
||||
this->high_freq_.stop();
|
||||
|
|
|
@ -21,6 +21,7 @@ class A4988 : public stepper::Stepper, public Component {
|
|||
GPIOPin *step_pin_;
|
||||
GPIOPin *dir_pin_;
|
||||
GPIOPin *sleep_pin_{nullptr};
|
||||
bool sleep_pin_state_;
|
||||
HighFrequencyLoopRequester high_freq_;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue