From 0427f3cc3b64eaf2c2a774b00a5268e041a83150 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 21 Sep 2016 17:07:34 -0500 Subject: [PATCH] Use memcpy/memset in planner --- Marlin/planner.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Marlin/planner.cpp b/Marlin/planner.cpp index c90f5571c..8f1e043bf 100644 --- a/Marlin/planner.cpp +++ b/Marlin/planner.cpp @@ -135,8 +135,8 @@ Planner::Planner() { init(); } void Planner::init() { block_buffer_head = block_buffer_tail = 0; - memset(position, 0, sizeof(position)); // clear position - LOOP_XYZE(i) previous_speed[i] = 0.0; + memset(position, 0, sizeof(position)); + memset(previous_speed, 0, sizeof(previous_speed)); previous_nominal_speed = 0.0; #if ENABLED(AUTO_BED_LEVELING_LINEAR) bed_level_matrix.set_to_identity(); @@ -1134,7 +1134,7 @@ void Planner::buffer_line(ARG_X, ARG_Y, ARG_Z, const float &e, float fr_mm_s, co block->recalculate_flag = true; // Always calculate trapezoid for new block // Update previous path unit_vector and nominal speed - LOOP_XYZE(i) previous_speed[i] = current_speed[i]; + memcpy(previous_speed, current_speed, sizeof(previous_speed)); previous_nominal_speed = block->nominal_speed; #if ENABLED(LIN_ADVANCE) @@ -1180,8 +1180,8 @@ void Planner::buffer_line(ARG_X, ARG_Y, ARG_Z, const float &e, float fr_mm_s, co // Move buffer head block_buffer_head = next_buffer_head; - // Update position - LOOP_XYZE(i) position[i] = target[i]; + // Update the position (only when a move was queued) + memcpy(position, target, sizeof(position)); recalculate(); @@ -1207,7 +1207,7 @@ void Planner::set_position_mm(ARG_X, ARG_Y, ARG_Z, const float &e) { stepper.set_position(nx, ny, nz, ne); previous_nominal_speed = 0.0; // Resets planner junction speeds. Assumes start from rest. - LOOP_XYZE(i) previous_speed[i] = 0.0; + memset(previous_speed, 0, sizeof(previous_speed)); } /**