diff --git a/Grbl_Esp32/src/Motors/Motors.cpp b/Grbl_Esp32/src/Motors/Motors.cpp index 2ba09268..7bc54f42 100644 --- a/Grbl_Esp32/src/Motors/Motors.cpp +++ b/Grbl_Esp32/src/Motors/Motors.cpp @@ -367,10 +367,10 @@ void motors_read_settings() { // They can use this to setup things like Stall void motors_set_homing_mode(uint8_t homing_mask, bool isHoming) { for (uint8_t gang_index = 0; gang_index < 2; gang_index++) { - for (uint8_t axis = X_AXIS; axis < N_AXIS; axis++) - if (bit_istrue(homing_mask, bit(axis)) && (myMotor[axis][gang_index]->is_active)) + for (uint8_t axis = X_AXIS; axis < N_AXIS; axis++) { + if (bit_istrue(homing_mask, bit(axis)) && (myMotor[axis][gang_index]->is_active)) { myMotor[axis][gang_index]->set_homing_mode(homing_mask, isHoming); - } + } } } } diff --git a/Grbl_Esp32/src/Motors/TrinamicDriver.cpp b/Grbl_Esp32/src/Motors/TrinamicDriver.cpp index a078c6a4..eb16ba90 100644 --- a/Grbl_Esp32/src/Motors/TrinamicDriver.cpp +++ b/Grbl_Esp32/src/Motors/TrinamicDriver.cpp @@ -159,8 +159,9 @@ namespace Motors { float hold (as a percentage of run) */ void TrinamicDriver::read_settings() { - if (has_errors) { + if (has_errors) return; + uint16_t run_i_ma = (uint16_t)(axis_settings[_axis_index]->run_current->get() * 1000.0); float hold_i_percent; @@ -170,7 +171,6 @@ namespace Motors { hold_i_percent = axis_settings[_axis_index]->hold_current->get() / axis_settings[_axis_index]->run_current->get(); if (hold_i_percent > 1.0) hold_i_percent = 1.0; - } } //grbl_msg_sendf(CLIENT_SERIAL, MSG_LEVEL_INFO, "%s Current run %d hold %f", _axis_name, run_i_ma, hold_i_percent); diff --git a/Grbl_Esp32/src/Motors/UnipolarMotor.cpp b/Grbl_Esp32/src/Motors/UnipolarMotor.cpp index aea90e8f..25ffa82e 100644 --- a/Grbl_Esp32/src/Motors/UnipolarMotor.cpp +++ b/Grbl_Esp32/src/Motors/UnipolarMotor.cpp @@ -56,30 +56,25 @@ namespace Motors { if (!(step_mask & bit(_axis_index))) return; // a step is not required on this interrupt - } - if (!_enabled) { + if (!_enabled) return; // don't do anything, phase is not changed or lost - } - if (_half_step) { + if (_half_step) phase_max = 7; - } else { + else phase_max = 3; - } if (dir_mask & bit(_axis_index)) { // count up if (_current_phase == phase_max) _current_phase = 0; - } else { + else _current_phase++; - } } else { // count down - if (_current_phase == 0) { + if (_current_phase == 0) _current_phase = phase_max; - } else { + else _current_phase--; - } } /* 8 Step : A – AB – B – BC – C – CD – D – DA