Browse Source

🎨 steps_to_mm => mm_per_step (#22847)

vanilla_fb_2.0.x
espr14 3 years ago
committed by Scott Lahteine
parent
commit
604a01cd1a
  1. 2
      Marlin/src/feature/encoder_i2c.cpp
  2. 2
      Marlin/src/feature/runout.h
  3. 2
      Marlin/src/gcode/config/M92.cpp
  4. 8
      Marlin/src/lcd/extui/ui_api.cpp
  5. 2
      Marlin/src/lcd/menu/menu.cpp
  6. 2
      Marlin/src/lcd/menu/menu_advanced.cpp
  7. 6
      Marlin/src/lcd/menu/menu_tune.cpp
  8. 2
      Marlin/src/lcd/tft/ui_1024x600.cpp
  9. 2
      Marlin/src/lcd/tft/ui_320x240.cpp
  10. 2
      Marlin/src/lcd/tft/ui_480x320.cpp
  11. 6
      Marlin/src/module/motion.cpp
  12. 72
      Marlin/src/module/planner.cpp
  13. 4
      Marlin/src/module/planner.h
  14. 2
      Marlin/src/module/settings.cpp
  15. 2
      Marlin/src/module/temperature.cpp

2
Marlin/src/feature/encoder_i2c.cpp

@ -173,7 +173,7 @@ void I2CPositionEncoder::update() {
LOOP_L_N(i, I2CPE_ERR_PRST_ARRAY_SIZE) sumP += errPrst[i]; LOOP_L_N(i, I2CPE_ERR_PRST_ARRAY_SIZE) sumP += errPrst[i];
const int32_t errorP = int32_t(sumP * RECIPROCAL(I2CPE_ERR_PRST_ARRAY_SIZE)); const int32_t errorP = int32_t(sumP * RECIPROCAL(I2CPE_ERR_PRST_ARRAY_SIZE));
SERIAL_CHAR(axis_codes[encoderAxis]); SERIAL_CHAR(axis_codes[encoderAxis]);
SERIAL_ECHOLNPGM(" : CORRECT ERR ", errorP * planner.steps_to_mm[encoderAxis], "mm"); SERIAL_ECHOLNPGM(" : CORRECT ERR ", errorP * planner.mm_per_step[encoderAxis], "mm");
babystep.add_steps(encoderAxis, -LROUND(errorP)); babystep.add_steps(encoderAxis, -LROUND(errorP));
errPrstIdx = 0; errPrstIdx = 0;
} }

2
Marlin/src/feature/runout.h

@ -373,7 +373,7 @@ class FilamentSensorBase {
// Only trigger on extrusion with XYZ movement to allow filament change and retract/recover. // Only trigger on extrusion with XYZ movement to allow filament change and retract/recover.
const uint8_t e = b->extruder; const uint8_t e = b->extruder;
const int32_t steps = b->steps.e; const int32_t steps = b->steps.e;
runout_mm_countdown[e] -= (TEST(b->direction_bits, E_AXIS) ? -steps : steps) * planner.steps_to_mm[E_AXIS_N(e)]; runout_mm_countdown[e] -= (TEST(b->direction_bits, E_AXIS) ? -steps : steps) * planner.mm_per_step[E_AXIS_N(e)];
} }
} }
}; };

2
Marlin/src/gcode/config/M92.cpp

@ -76,7 +76,7 @@ void GcodeSuite::M92() {
if (parser.seen('H') || wanted) { if (parser.seen('H') || wanted) {
const uint16_t argH = parser.ushortval('H'), const uint16_t argH = parser.ushortval('H'),
micro_steps = argH ?: Z_MICROSTEPS; micro_steps = argH ?: Z_MICROSTEPS;
const float z_full_step_mm = micro_steps * planner.steps_to_mm[Z_AXIS]; const float z_full_step_mm = micro_steps * planner.mm_per_step[Z_AXIS];
SERIAL_ECHO_START(); SERIAL_ECHO_START();
SERIAL_ECHOPGM("{ micro_steps:", micro_steps, ", z_full_step_mm:", z_full_step_mm); SERIAL_ECHOPGM("{ micro_steps:", micro_steps, ", z_full_step_mm:", z_full_step_mm);
if (wanted) { if (wanted) {

8
Marlin/src/lcd/extui/ui_api.cpp

@ -755,7 +755,7 @@ namespace ExtUI {
* what nozzle is printing. * what nozzle is printing.
*/ */
void smartAdjustAxis_steps(const int16_t steps, const axis_t axis, bool linked_nozzles) { void smartAdjustAxis_steps(const int16_t steps, const axis_t axis, bool linked_nozzles) {
const float mm = steps * planner.steps_to_mm[axis]; const float mm = steps * planner.mm_per_step[axis];
UNUSED(mm); UNUSED(mm);
if (!babystepAxis_steps(steps, axis)) return; if (!babystepAxis_steps(steps, axis)) return;
@ -791,12 +791,12 @@ namespace ExtUI {
* steps that is at least mm long. * steps that is at least mm long.
*/ */
int16_t mmToWholeSteps(const_float_t mm, const axis_t axis) { int16_t mmToWholeSteps(const_float_t mm, const axis_t axis) {
const float steps = mm / planner.steps_to_mm[axis]; const float steps = mm / planner.mm_per_step[axis];
return steps > 0 ? CEIL(steps) : FLOOR(steps); return steps > 0 ? CEIL(steps) : FLOOR(steps);
} }
float mmFromWholeSteps(int16_t steps, const axis_t axis) { float mmFromWholeSteps(int16_t steps, const axis_t axis) {
return steps * planner.steps_to_mm[axis]; return steps * planner.mm_per_step[axis];
} }
#endif // BABYSTEPPING #endif // BABYSTEPPING
@ -806,7 +806,7 @@ namespace ExtUI {
#if HAS_BED_PROBE #if HAS_BED_PROBE
+ probe.offset.z + probe.offset.z
#elif ENABLED(BABYSTEP_DISPLAY_TOTAL) #elif ENABLED(BABYSTEP_DISPLAY_TOTAL)
+ planner.steps_to_mm[Z_AXIS] * babystep.axis_total[BS_AXIS_IND(Z_AXIS)] + planner.mm_per_step[Z_AXIS] * babystep.axis_total[BS_AXIS_IND(Z_AXIS)]
#endif #endif
); );
} }

2
Marlin/src/lcd/menu/menu.cpp

@ -315,7 +315,7 @@ void scroll_screen(const uint8_t limit, const bool is_menu) {
const int16_t babystep_increment = int16_t(ui.encoderPosition) * (BABYSTEP_SIZE_Z); const int16_t babystep_increment = int16_t(ui.encoderPosition) * (BABYSTEP_SIZE_Z);
ui.encoderPosition = 0; ui.encoderPosition = 0;
const float diff = planner.steps_to_mm[Z_AXIS] * babystep_increment, const float diff = planner.mm_per_step[Z_AXIS] * babystep_increment,
new_probe_offset = probe.offset.z + diff, new_probe_offset = probe.offset.z + diff,
new_offs = TERN(BABYSTEP_HOTEND_Z_OFFSET new_offs = TERN(BABYSTEP_HOTEND_Z_OFFSET
, do_probe ? new_probe_offset : hotend_offset[active_extruder].z - diff , do_probe ? new_probe_offset : hotend_offset[active_extruder].z - diff

2
Marlin/src/lcd/menu/menu_advanced.cpp

@ -532,7 +532,7 @@ void menu_advanced_steps_per_mm() {
if (e == active_extruder) if (e == active_extruder)
planner.refresh_positioning(); planner.refresh_positioning();
else else
planner.steps_to_mm[E_AXIS_N(e)] = 1.0f / planner.settings.axis_steps_per_mm[E_AXIS_N(e)]; planner.mm_per_step[E_AXIS_N(e)] = 1.0f / planner.settings.axis_steps_per_mm[E_AXIS_N(e)];
}); });
#elif E_STEPPERS #elif E_STEPPERS
EDIT_ITEM_FAST(float51, MSG_E_STEPS, &planner.settings.axis_steps_per_mm[E_AXIS], 5, 9999, []{ planner.refresh_positioning(); }); EDIT_ITEM_FAST(float51, MSG_E_STEPS, &planner.settings.axis_steps_per_mm[E_AXIS], 5, 9999, []{ planner.refresh_positioning(); });

6
Marlin/src/lcd/menu/menu_tune.cpp

@ -65,8 +65,8 @@
babystep.add_steps(axis, steps); babystep.add_steps(axis, steps);
} }
if (ui.should_draw()) { if (ui.should_draw()) {
const float spm = planner.steps_to_mm[axis]; const float mps = planner.mm_per_step[axis];
MenuEditItemBase::draw_edit_screen(msg, BABYSTEP_TO_STR(spm * babystep.accum)); MenuEditItemBase::draw_edit_screen(msg, BABYSTEP_TO_STR(mps * babystep.accum));
#if ENABLED(BABYSTEP_DISPLAY_TOTAL) #if ENABLED(BABYSTEP_DISPLAY_TOTAL)
const bool in_view = TERN1(HAS_MARLINUI_U8GLIB, PAGE_CONTAINS(LCD_PIXEL_HEIGHT - MENU_FONT_HEIGHT, LCD_PIXEL_HEIGHT - 1)); const bool in_view = TERN1(HAS_MARLINUI_U8GLIB, PAGE_CONTAINS(LCD_PIXEL_HEIGHT - MENU_FONT_HEIGHT, LCD_PIXEL_HEIGHT - 1));
if (in_view) { if (in_view) {
@ -81,7 +81,7 @@
lcd_put_u8str_P(GET_TEXT(MSG_BABYSTEP_TOTAL)); lcd_put_u8str_P(GET_TEXT(MSG_BABYSTEP_TOTAL));
lcd_put_wchar(':'); lcd_put_wchar(':');
#endif #endif
lcd_put_u8str(BABYSTEP_TO_STR(spm * babystep.axis_total[BS_TOTAL_IND(axis)])); lcd_put_u8str(BABYSTEP_TO_STR(mps * babystep.axis_total[BS_TOTAL_IND(axis)]));
} }
#endif #endif
} }

2
Marlin/src/lcd/tft/ui_1024x600.cpp

@ -667,7 +667,7 @@ static void moveAxis(const AxisEnum axis, const int8_t direction) {
#if ENABLED(BABYSTEP_ZPROBE_OFFSET) #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
const int16_t babystep_increment = direction * BABYSTEP_SIZE_Z; const int16_t babystep_increment = direction * BABYSTEP_SIZE_Z;
const bool do_probe = DISABLED(BABYSTEP_HOTEND_Z_OFFSET) || active_extruder == 0; const bool do_probe = DISABLED(BABYSTEP_HOTEND_Z_OFFSET) || active_extruder == 0;
const float bsDiff = planner.steps_to_mm[Z_AXIS] * babystep_increment, const float bsDiff = planner.mm_per_step[Z_AXIS] * babystep_increment,
new_probe_offset = probe.offset.z + bsDiff, new_probe_offset = probe.offset.z + bsDiff,
new_offs = TERN(BABYSTEP_HOTEND_Z_OFFSET new_offs = TERN(BABYSTEP_HOTEND_Z_OFFSET
, do_probe ? new_probe_offset : hotend_offset[active_extruder].z - bsDiff , do_probe ? new_probe_offset : hotend_offset[active_extruder].z - bsDiff

2
Marlin/src/lcd/tft/ui_320x240.cpp

@ -652,7 +652,7 @@ static void moveAxis(const AxisEnum axis, const int8_t direction) {
#if ENABLED(BABYSTEP_ZPROBE_OFFSET) #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
const int16_t babystep_increment = direction * BABYSTEP_SIZE_Z; const int16_t babystep_increment = direction * BABYSTEP_SIZE_Z;
const bool do_probe = DISABLED(BABYSTEP_HOTEND_Z_OFFSET) || active_extruder == 0; const bool do_probe = DISABLED(BABYSTEP_HOTEND_Z_OFFSET) || active_extruder == 0;
const float bsDiff = planner.steps_to_mm[Z_AXIS] * babystep_increment, const float bsDiff = planner.mm_per_step[Z_AXIS] * babystep_increment,
new_probe_offset = probe.offset.z + bsDiff, new_probe_offset = probe.offset.z + bsDiff,
new_offs = TERN(BABYSTEP_HOTEND_Z_OFFSET new_offs = TERN(BABYSTEP_HOTEND_Z_OFFSET
, do_probe ? new_probe_offset : hotend_offset[active_extruder].z - bsDiff , do_probe ? new_probe_offset : hotend_offset[active_extruder].z - bsDiff

2
Marlin/src/lcd/tft/ui_480x320.cpp

@ -654,7 +654,7 @@ static void moveAxis(const AxisEnum axis, const int8_t direction) {
#if ENABLED(BABYSTEP_ZPROBE_OFFSET) #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
const int16_t babystep_increment = direction * BABYSTEP_SIZE_Z; const int16_t babystep_increment = direction * BABYSTEP_SIZE_Z;
const bool do_probe = DISABLED(BABYSTEP_HOTEND_Z_OFFSET) || active_extruder == 0; const bool do_probe = DISABLED(BABYSTEP_HOTEND_Z_OFFSET) || active_extruder == 0;
const float bsDiff = planner.steps_to_mm[Z_AXIS] * babystep_increment, const float bsDiff = planner.mm_per_step[Z_AXIS] * babystep_increment,
new_probe_offset = probe.offset.z + bsDiff, new_probe_offset = probe.offset.z + bsDiff,
new_offs = TERN(BABYSTEP_HOTEND_Z_OFFSET new_offs = TERN(BABYSTEP_HOTEND_Z_OFFSET
, do_probe ? new_probe_offset : hotend_offset[active_extruder].z - bsDiff , do_probe ? new_probe_offset : hotend_offset[active_extruder].z - bsDiff

6
Marlin/src/module/motion.cpp

@ -1682,7 +1682,7 @@ void prepare_line_to_destination() {
int16_t phaseDelta = (home_phase[axis] - phaseCurrent) * stepperBackoutDir; int16_t phaseDelta = (home_phase[axis] - phaseCurrent) * stepperBackoutDir;
// Check if home distance within endstop assumed repeatability noise of .05mm and warn. // Check if home distance within endstop assumed repeatability noise of .05mm and warn.
if (ABS(phaseDelta) * planner.steps_to_mm[axis] / phasePerUStep < 0.05f) if (ABS(phaseDelta) * planner.mm_per_step[axis] / phasePerUStep < 0.05f)
SERIAL_ECHOLNPGM("Selected home phase ", home_phase[axis], SERIAL_ECHOLNPGM("Selected home phase ", home_phase[axis],
" too close to endstop trigger phase ", phaseCurrent, " too close to endstop trigger phase ", phaseCurrent,
". Pick a different phase for ", AS_CHAR(AXIS_CHAR(axis))); ". Pick a different phase for ", AS_CHAR(AXIS_CHAR(axis)));
@ -1691,7 +1691,7 @@ void prepare_line_to_destination() {
if (phaseDelta < 0) phaseDelta += 1024; if (phaseDelta < 0) phaseDelta += 1024;
// Convert TMC µsteps(phase) to whole Marlin µsteps to effector backout direction to mm // Convert TMC µsteps(phase) to whole Marlin µsteps to effector backout direction to mm
const float mmDelta = int16_t(phaseDelta / phasePerUStep) * effectorBackoutDir * planner.steps_to_mm[axis]; const float mmDelta = int16_t(phaseDelta / phasePerUStep) * effectorBackoutDir * planner.mm_per_step[axis];
// Optional debug messages // Optional debug messages
if (DEBUGGING(LEVELING)) { if (DEBUGGING(LEVELING)) {
@ -1999,7 +1999,7 @@ void prepare_line_to_destination() {
// Delta homing treats the axes as normal linear axes. // Delta homing treats the axes as normal linear axes.
const float adjDistance = delta_endstop_adj[axis], const float adjDistance = delta_endstop_adj[axis],
minDistance = (MIN_STEPS_PER_SEGMENT) * planner.steps_to_mm[axis]; minDistance = (MIN_STEPS_PER_SEGMENT) * planner.mm_per_step[axis];
// Retrace by the amount specified in delta_endstop_adj if more than min steps. // Retrace by the amount specified in delta_endstop_adj if more than min steps.
if (adjDistance * (Z_HOME_DIR) < 0 && ABS(adjDistance) > minDistance) { // away from endstop, more than min distance if (adjDistance * (Z_HOME_DIR) < 0 && ABS(adjDistance) > minDistance) { // away from endstop, more than min distance

72
Marlin/src/module/planner.cpp

@ -138,7 +138,7 @@ planner_settings_t Planner::settings; // Initialized by settings.load(
uint32_t Planner::max_acceleration_steps_per_s2[DISTINCT_AXES]; // (steps/s^2) Derived from mm_per_s2 uint32_t Planner::max_acceleration_steps_per_s2[DISTINCT_AXES]; // (steps/s^2) Derived from mm_per_s2
float Planner::steps_to_mm[DISTINCT_AXES]; // (mm) Millimeters per step float Planner::mm_per_step[DISTINCT_AXES]; // (mm) Millimeters per step
#if HAS_JUNCTION_DEVIATION #if HAS_JUNCTION_DEVIATION
float Planner::junction_deviation_mm; // (mm) M205 J float Planner::junction_deviation_mm; // (mm) M205 J
@ -1702,7 +1702,7 @@ void Planner::endstop_triggered(const AxisEnum axis) {
} }
float Planner::triggered_position_mm(const AxisEnum axis) { float Planner::triggered_position_mm(const AxisEnum axis) {
return stepper.triggered_position(axis) * steps_to_mm[axis]; return stepper.triggered_position(axis) * mm_per_step[axis];
} }
void Planner::finish_and_disable() { void Planner::finish_and_disable() {
@ -1759,7 +1759,7 @@ float Planner::get_axis_position_mm(const AxisEnum axis) {
#endif #endif
return axis_steps * steps_to_mm[axis]; return axis_steps * mm_per_step[axis];
} }
/** /**
@ -2015,51 +2015,51 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
} steps_dist_mm; } steps_dist_mm;
#if IS_CORE #if IS_CORE
#if CORE_IS_XY #if CORE_IS_XY
steps_dist_mm.head.x = da * steps_to_mm[A_AXIS]; steps_dist_mm.head.x = da * mm_per_step[A_AXIS];
steps_dist_mm.head.y = db * steps_to_mm[B_AXIS]; steps_dist_mm.head.y = db * mm_per_step[B_AXIS];
steps_dist_mm.z = dc * steps_to_mm[Z_AXIS]; steps_dist_mm.z = dc * mm_per_step[Z_AXIS];
steps_dist_mm.a = (da + db) * steps_to_mm[A_AXIS]; steps_dist_mm.a = (da + db) * mm_per_step[A_AXIS];
steps_dist_mm.b = CORESIGN(da - db) * steps_to_mm[B_AXIS]; steps_dist_mm.b = CORESIGN(da - db) * mm_per_step[B_AXIS];
#elif CORE_IS_XZ #elif CORE_IS_XZ
steps_dist_mm.head.x = da * steps_to_mm[A_AXIS]; steps_dist_mm.head.x = da * mm_per_step[A_AXIS];
steps_dist_mm.y = db * steps_to_mm[Y_AXIS]; steps_dist_mm.y = db * mm_per_step[Y_AXIS];
steps_dist_mm.head.z = dc * steps_to_mm[C_AXIS]; steps_dist_mm.head.z = dc * mm_per_step[C_AXIS];
steps_dist_mm.a = (da + dc) * steps_to_mm[A_AXIS]; steps_dist_mm.a = (da + dc) * mm_per_step[A_AXIS];
steps_dist_mm.c = CORESIGN(da - dc) * steps_to_mm[C_AXIS]; steps_dist_mm.c = CORESIGN(da - dc) * mm_per_step[C_AXIS];
#elif CORE_IS_YZ #elif CORE_IS_YZ
steps_dist_mm.x = da * steps_to_mm[X_AXIS]; steps_dist_mm.x = da * mm_per_step[X_AXIS];
steps_dist_mm.head.y = db * steps_to_mm[B_AXIS]; steps_dist_mm.head.y = db * mm_per_step[B_AXIS];
steps_dist_mm.head.z = dc * steps_to_mm[C_AXIS]; steps_dist_mm.head.z = dc * mm_per_step[C_AXIS];
steps_dist_mm.b = (db + dc) * steps_to_mm[B_AXIS]; steps_dist_mm.b = (db + dc) * mm_per_step[B_AXIS];
steps_dist_mm.c = CORESIGN(db - dc) * steps_to_mm[C_AXIS]; steps_dist_mm.c = CORESIGN(db - dc) * mm_per_step[C_AXIS];
#endif #endif
#if LINEAR_AXES >= 4 #if LINEAR_AXES >= 4
steps_dist_mm.i = di * steps_to_mm[I_AXIS]; steps_dist_mm.i = di * mm_per_step[I_AXIS];
#endif #endif
#if LINEAR_AXES >= 5 #if LINEAR_AXES >= 5
steps_dist_mm.j = dj * steps_to_mm[J_AXIS]; steps_dist_mm.j = dj * mm_per_step[J_AXIS];
#endif #endif
#if LINEAR_AXES >= 6 #if LINEAR_AXES >= 6
steps_dist_mm.k = dk * steps_to_mm[K_AXIS]; steps_dist_mm.k = dk * mm_per_step[K_AXIS];
#endif #endif
#elif ENABLED(MARKFORGED_XY) #elif ENABLED(MARKFORGED_XY)
steps_dist_mm.head.x = da * steps_to_mm[A_AXIS]; steps_dist_mm.head.x = da * mm_per_step[A_AXIS];
steps_dist_mm.head.y = db * steps_to_mm[B_AXIS]; steps_dist_mm.head.y = db * mm_per_step[B_AXIS];
steps_dist_mm.z = dc * steps_to_mm[Z_AXIS]; steps_dist_mm.z = dc * mm_per_step[Z_AXIS];
steps_dist_mm.a = (da - db) * steps_to_mm[A_AXIS]; steps_dist_mm.a = (da - db) * mm_per_step[A_AXIS];
steps_dist_mm.b = db * steps_to_mm[B_AXIS]; steps_dist_mm.b = db * mm_per_step[B_AXIS];
#else #else
LINEAR_AXIS_CODE( LINEAR_AXIS_CODE(
steps_dist_mm.a = da * steps_to_mm[A_AXIS], steps_dist_mm.a = da * mm_per_step[A_AXIS],
steps_dist_mm.b = db * steps_to_mm[B_AXIS], steps_dist_mm.b = db * mm_per_step[B_AXIS],
steps_dist_mm.c = dc * steps_to_mm[C_AXIS], steps_dist_mm.c = dc * mm_per_step[C_AXIS],
steps_dist_mm.i = di * steps_to_mm[I_AXIS], steps_dist_mm.i = di * mm_per_step[I_AXIS],
steps_dist_mm.j = dj * steps_to_mm[J_AXIS], steps_dist_mm.j = dj * mm_per_step[J_AXIS],
steps_dist_mm.k = dk * steps_to_mm[K_AXIS] steps_dist_mm.k = dk * mm_per_step[K_AXIS]
); );
#endif #endif
TERN_(HAS_EXTRUDERS, steps_dist_mm.e = esteps_float * steps_to_mm[E_AXIS_N(extruder)]); TERN_(HAS_EXTRUDERS, steps_dist_mm.e = esteps_float * mm_per_step[E_AXIS_N(extruder)]);
TERN_(LCD_SHOW_E_TOTAL, e_move_accumulator += steps_dist_mm.e); TERN_(LCD_SHOW_E_TOTAL, e_move_accumulator += steps_dist_mm.e);
@ -2889,7 +2889,7 @@ bool Planner::buffer_segment(const abce_pos_t &abce
// When changing extruders recalculate steps corresponding to the E position // When changing extruders recalculate steps corresponding to the E position
#if ENABLED(DISTINCT_E_FACTORS) #if ENABLED(DISTINCT_E_FACTORS)
if (last_extruder != extruder && settings.axis_steps_per_mm[E_AXIS_N(extruder)] != settings.axis_steps_per_mm[E_AXIS_N(last_extruder)]) { if (last_extruder != extruder && settings.axis_steps_per_mm[E_AXIS_N(extruder)] != settings.axis_steps_per_mm[E_AXIS_N(last_extruder)]) {
position.e = LROUND(position.e * settings.axis_steps_per_mm[E_AXIS_N(extruder)] * steps_to_mm[E_AXIS_N(last_extruder)]); position.e = LROUND(position.e * settings.axis_steps_per_mm[E_AXIS_N(extruder)] * mm_per_step[E_AXIS_N(last_extruder)]);
last_extruder = extruder; last_extruder = extruder;
} }
#endif #endif
@ -3168,11 +3168,11 @@ void Planner::reset_acceleration_rates() {
} }
/** /**
* Recalculate 'position' and 'steps_to_mm'. * Recalculate 'position' and 'mm_per_step'.
* Must be called whenever settings.axis_steps_per_mm changes! * Must be called whenever settings.axis_steps_per_mm changes!
*/ */
void Planner::refresh_positioning() { void Planner::refresh_positioning() {
LOOP_DISTINCT_AXES(i) steps_to_mm[i] = 1.0f / settings.axis_steps_per_mm[i]; LOOP_DISTINCT_AXES(i) mm_per_step[i] = 1.0f / settings.axis_steps_per_mm[i];
set_position_mm(current_position); set_position_mm(current_position);
reset_acceleration_rates(); reset_acceleration_rates();
} }

4
Marlin/src/module/planner.h

@ -374,7 +374,7 @@ class Planner {
#endif #endif
static uint32_t max_acceleration_steps_per_s2[DISTINCT_AXES]; // (steps/s^2) Derived from mm_per_s2 static uint32_t max_acceleration_steps_per_s2[DISTINCT_AXES]; // (steps/s^2) Derived from mm_per_s2
static float steps_to_mm[DISTINCT_AXES]; // Millimeters per step static float mm_per_step[DISTINCT_AXES]; // Millimeters per step
#if HAS_JUNCTION_DEVIATION #if HAS_JUNCTION_DEVIATION
static float junction_deviation_mm; // (mm) M205 J static float junction_deviation_mm; // (mm) M205 J
@ -489,7 +489,7 @@ class Planner {
static void reset_acceleration_rates(); static void reset_acceleration_rates();
/** /**
* Recalculate 'position' and 'steps_to_mm'. * Recalculate 'position' and 'mm_per_step'.
* Must be called whenever settings.axis_steps_per_mm changes! * Must be called whenever settings.axis_steps_per_mm changes!
*/ */
static void refresh_positioning(); static void refresh_positioning();

2
Marlin/src/module/settings.cpp

@ -557,7 +557,7 @@ void MarlinSettings::postprocess() {
TERN_(EXTENSIBLE_UI, ExtUI::onPostprocessSettings()); TERN_(EXTENSIBLE_UI, ExtUI::onPostprocessSettings());
// Refresh steps_to_mm with the reciprocal of axis_steps_per_mm // Refresh mm_per_step with the reciprocal of axis_steps_per_mm
// and init stepper.count[], planner.position[] with current_position // and init stepper.count[], planner.position[] with current_position
planner.refresh_positioning(); planner.refresh_positioning();

2
Marlin/src/module/temperature.cpp

@ -1102,7 +1102,7 @@ void Temperature::min_temp_error(const heater_id_t heater_id) {
lpq[lpq_ptr] = 0; lpq[lpq_ptr] = 0;
if (++lpq_ptr >= lpq_len) lpq_ptr = 0; if (++lpq_ptr >= lpq_len) lpq_ptr = 0;
work_pid[ee].Kc = (lpq[lpq_ptr] * planner.steps_to_mm[E_AXIS]) * PID_PARAM(Kc, ee); work_pid[ee].Kc = (lpq[lpq_ptr] * planner.mm_per_step[E_AXIS]) * PID_PARAM(Kc, ee);
pid_output += work_pid[ee].Kc; pid_output += work_pid[ee].Kc;
} }
#endif // PID_EXTRUSION_SCALING #endif // PID_EXTRUSION_SCALING

Loading…
Cancel
Save