mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 15:12:06 +00:00 
			
		
		
		
	a4988 wait 1ms when coming out of sleep (#1597)
This commit is contained in:
		| @@ -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_; | ||||
| }; | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user