Skip to content

Commit 94ce0d2

Browse files
👷 Add optimal stepper.set_e_position() (#27293)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
1 parent cdea1b8 commit 94ce0d2

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

Marlin/src/module/planner.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -3192,7 +3192,7 @@ void Planner::set_position_mm(const xyze_pos_t &xyze) {
31923192
if (has_blocks_queued())
31933193
buffer_sync_block(BLOCK_BIT_SYNC_POSITION);
31943194
else
3195-
stepper.set_axis_position(E_AXIS, position.e);
3195+
stepper.set_e_position(position.e);
31963196
}
31973197

31983198
#endif // HAS_EXTRUDERS

Marlin/src/module/stepper.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -3407,6 +3407,18 @@ void Stepper::set_axis_position(const AxisEnum a, const int32_t &v) {
34073407
#endif
34083408
}
34093409

3410+
#if HAS_EXTRUDERS
3411+
3412+
void Stepper::set_e_position(const int32_t &v) {
3413+
planner.synchronize();
3414+
3415+
AVR_ATOMIC_SECTION_START();
3416+
count_position.e = v;
3417+
AVR_ATOMIC_SECTION_END();
3418+
}
3419+
3420+
#endif // HAS_EXTRUDERS
3421+
34103422
#if ENABLED(FT_MOTION)
34113423

34123424
void Stepper::ftMotion_syncPosition() {

Marlin/src/module/stepper.h

+5
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,11 @@ class Stepper {
540540
static void set_position(const xyze_long_t &spos);
541541
static void set_axis_position(const AxisEnum a, const int32_t &v);
542542

543+
#if HAS_EXTRUDERS
544+
// Save a little when E is the only one used
545+
static void set_e_position(const int32_t &v);
546+
#endif
547+
543548
// Report the positions of the steppers, in steps
544549
static void report_a_position(const xyz_long_t &pos);
545550
static void report_positions();

0 commit comments

Comments
 (0)