From 725f19dff0b8ecc3cbaf8390d862bf10373b5919 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 19 Aug 2018 23:01:55 -0400 Subject: [PATCH] Move endstop polarity check to avoid flipping a disabled endstop --- Firmware/MotorControl/axis.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Firmware/MotorControl/axis.cpp b/Firmware/MotorControl/axis.cpp index f4f2e116..655747f9 100644 --- a/Firmware/MotorControl/axis.cpp +++ b/Firmware/MotorControl/axis.cpp @@ -107,11 +107,11 @@ void Axis::min_endstop_cb(){ if(config_.min_endstop.enabled){ min_endstop_state_ = HAL_GPIO_ReadPin(gpio_port, gpio_pin); + if(config_.min_endstop.is_active_high == false) + min_endstop_state_ = !min_endstop_state_; } else { min_endstop_state_ = false; } - if(config_.min_endstop.is_active_high == false) - min_endstop_state_ = !min_endstop_state_; } void Axis::set_min_endstop_enabled(bool enable){ @@ -138,12 +138,11 @@ void Axis::max_endstop_cb(){ if(config_.max_endstop.enabled){ max_endstop_state_ = HAL_GPIO_ReadPin(gpio_port, gpio_pin); + if(config_.max_endstop.is_active_high == false) + max_endstop_state_ = !max_endstop_state_; } else { max_endstop_state_ = false; } - - if(config_.max_endstop.is_active_high == false) - max_endstop_state_ = !max_endstop_state_; } void Axis::set_max_endstop_enabled(bool enable){