From 7bd10806bcb7f309f2aeb8369ec2b7c8c96ca1a5 Mon Sep 17 00:00:00 2001 From: Lasse Dalegaard Date: Tue, 7 Feb 2023 22:13:47 +0100 Subject: [PATCH] Fix tracking of e position through arcs --- lib/src/arcs.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/src/arcs.rs b/lib/src/arcs.rs index 146ac04..bec038f 100644 --- a/lib/src/arcs.rs +++ b/lib/src/arcs.rs @@ -32,19 +32,20 @@ impl ArcState { direction, args.mm_per_arc_segment, ); - let e_base = toolhead_state.position.w; - let e_per_move = args.e.map(|e| (e - e_base) / (segments as f64)); + let mut e_base = toolhead_state.position.w; + let e_per_move = args.e.map_or(0.0, |e| (e - e_base) / (segments as f64)); toolhead_state.set_speed(args.velocity); let old_pos_mode = toolhead_state.position_modes; toolhead_state.position_modes = [PositionMode::Absolute; 4]; - for (i, segment) in arc.enumerate() { + for segment in arc { + e_base += e_per_move; let coord = [ Some(segment.x), Some(segment.y), Some(segment.z), - e_per_move.map(|e| e_base + (i as f64) * e), + Some(e_base), ]; let mut pm = toolhead_state.perform_move(coord); pm.kind = move_kind;