From 06b8e4df274dbc4adf045882b0753fdc1e75f06f Mon Sep 17 00:00:00 2001 From: Alex Konradi Date: Tue, 4 May 2021 22:32:15 -0400 Subject: [PATCH] Call Stepper::should_step_ every loop iteration (#1373) --- esphome/components/uln2003/uln2003.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/esphome/components/uln2003/uln2003.cpp b/esphome/components/uln2003/uln2003.cpp index 38eadc9dc8..9bf34490ec 100644 --- a/esphome/components/uln2003/uln2003.cpp +++ b/esphome/components/uln2003/uln2003.cpp @@ -14,8 +14,8 @@ void ULN2003::setup() { this->loop(); } void ULN2003::loop() { - bool at_target = this->has_reached_target(); - if (at_target) { + int dir = this->should_step_(); + if (dir == 0 && this->has_reached_target()) { this->high_freq_.stop(); if (this->sleep_when_done_) { @@ -28,8 +28,6 @@ void ULN2003::loop() { } } else { this->high_freq_.start(); - - int dir = this->should_step_(); this->current_uln_pos_ += dir; }