From 8b7ac1bab2ab5f2ce238bccf41260a17b1ada90b Mon Sep 17 00:00:00 2001 From: Unknown Date: Sat, 8 Sep 2018 19:03:09 -0400 Subject: [PATCH] Fix seconds -> ms conversion error --- Firmware/MotorControl/endstop.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Firmware/MotorControl/endstop.cpp b/Firmware/MotorControl/endstop.cpp index df4f65eb..b9730984 100644 --- a/Firmware/MotorControl/endstop.cpp +++ b/Firmware/MotorControl/endstop.cpp @@ -12,11 +12,11 @@ static void endstop_cb_wrapper(void* ctx){ void Endstop::update() { if (config_.enabled) { float now = axis_->loop_counter_ * current_meas_period; - if((now - debounce_timer_) >= config_.debounce_ms) { // Debounce timer expired, take the new pin state - endstop_state_ = config_.is_active_high ? pin_state_ : !pin_state_; // endstop_state is the logical state - debounce_timer_ = now - config_.debounce_ms; // Ensure timer doesn't have overflow issues + if ((now - debounce_timer_) >= (config_.debounce_ms * 0.001)) { // Debounce timer expired, take the new pin state + endstop_state_ = config_.is_active_high ? pin_state_ : !pin_state_; // endstop_state is the logical state + debounce_timer_ = now - (config_.debounce_ms * 0.001); // Ensure timer doesn't have overflow issues } else { - endstop_state_ = endstop_state_; // Do nothing + endstop_state_ = endstop_state_; // Do nothing } } else { endstop_state_ = false;