From f641794b0f70dc790a628e146dea9ff5fec384ef Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 21 Feb 2022 18:36:34 -0600 Subject: [PATCH] rename method --- Marlin/src/feature/probe_temp_comp.cpp | 5 ++--- Marlin/src/feature/probe_temp_comp.h | 6 ++++-- Marlin/src/gcode/calibrate/M48.cpp | 4 +--- Marlin/src/gcode/probe/G30.cpp | 5 ++--- Marlin/src/module/probe.cpp | 2 +- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/Marlin/src/feature/probe_temp_comp.cpp b/Marlin/src/feature/probe_temp_comp.cpp index f50776acf661..b5f636e698c9 100644 --- a/Marlin/src/feature/probe_temp_comp.cpp +++ b/Marlin/src/feature/probe_temp_comp.cpp @@ -171,15 +171,14 @@ bool ProbeTempComp::finish_calibration(const TempSensorID tsi) { return true; } -void ProbeTempComp::compensate_measurement(float &meas_z) { +void ProbeTempComp::apply_compensation(float &meas_z) { + if (!enabled) return; TERN_(PTC_BED, compensate_measurement(TSI_BED, thermalManager.degBed(), meas_z)); TERN_(PTC_PROBE, compensate_measurement(TSI_PROBE, thermalManager.degProbe(), meas_z)); TERN_(PTC_HOTEND, compensate_measurement(TSI_EXT, thermalManager.degHotend(0), meas_z)); } void ProbeTempComp::compensate_measurement(const TempSensorID tsi, const celsius_t temp, float &meas_z) { - if (!enabled) return; - const uint8_t measurements = cali_info[tsi].measurements; const celsius_t start_temp = cali_info[tsi].start_temp, res_temp = cali_info[tsi].temp_resolution, diff --git a/Marlin/src/feature/probe_temp_comp.h b/Marlin/src/feature/probe_temp_comp.h index 8fe0165ca054..42348db68473 100644 --- a/Marlin/src/feature/probe_temp_comp.h +++ b/Marlin/src/feature/probe_temp_comp.h @@ -87,8 +87,10 @@ class ProbeTempComp { static void prepare_new_calibration(const_float_t init_meas_z); static void push_back_new_measurement(const TempSensorID tsi, const_float_t meas_z); static bool finish_calibration(const TempSensorID tsi); - static void set_enabled(bool arg) {enabled = arg;} - static void compensate_measurement(float &meas_z); + static void set_enabled(const bool ena) { enabled = ena; } + + // Apply all temperature compensation adjustments + static void apply_compensation(float &meas_z); private: static uint8_t calib_idx; diff --git a/Marlin/src/gcode/calibrate/M48.cpp b/Marlin/src/gcode/calibrate/M48.cpp index e36847d8f954..8b6ea0bf1fae 100644 --- a/Marlin/src/gcode/calibrate/M48.cpp +++ b/Marlin/src/gcode/calibrate/M48.cpp @@ -105,8 +105,6 @@ void GcodeSuite::M48() { if (verbose_level > 2) SERIAL_ECHOLNPGM("Positioning the probe..."); - TERN_(HAS_PTC, const bool ptc_enabled = parser.seenval('C') ? !!parser.value_int() : true); - // Always disable Bed Level correction before probing... #if HAS_LEVELING @@ -114,7 +112,7 @@ void GcodeSuite::M48() { set_bed_leveling_enabled(false); #endif - TERN_(HAS_PTC, ptc.set_enabled(ptc_enabled)); + TERN_(HAS_PTC, ptc.set_enabled(!parser.seen('C') || parser.value_bool())); // Work with reasonable feedrates remember_feedrate_scaling_off(); diff --git a/Marlin/src/gcode/probe/G30.cpp b/Marlin/src/gcode/probe/G30.cpp index e52e5774c231..474f1f252a04 100644 --- a/Marlin/src/gcode/probe/G30.cpp +++ b/Marlin/src/gcode/probe/G30.cpp @@ -48,8 +48,6 @@ void GcodeSuite::G30() { const xy_pos_t pos = { parser.linearval('X', current_position.x + probe.offset_xy.x), parser.linearval('Y', current_position.y + probe.offset_xy.y) }; - TERN_(HAS_PTC, const bool ptc_enabled = parser.seenval('C') ? !!parser.value_int() : true); - if (!probe.can_reach(pos)) return; // Disable leveling so the planner won't mess with us @@ -58,7 +56,8 @@ void GcodeSuite::G30() { remember_feedrate_scaling_off(); const ProbePtRaise raise_after = parser.boolval('E', true) ? PROBE_PT_STOW : PROBE_PT_NONE; - TERN_(HAS_PTC, ptc.set_enabled(ptc_enabled)); + + TERN_(HAS_PTC, ptc.set_enabled(!parser.seen('C') || parser.value_bool())); const float measured_z = probe.probe_at_point(pos, raise_after, 1); TERN_(HAS_PTC, ptc.set_enabled(true)); if (!isnan(measured_z)) diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index 2c933e83cb09..95776ffda1af 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -807,7 +807,7 @@ float Probe::probe_at_point(const_float_t rx, const_float_t ry, const ProbePtRai float measured_z = NAN; if (!deploy()) { measured_z = run_z_probe(sanity_check) + offset.z; - TERN_(HAS_PTC, ptc.compensate_measurement(measured_z)); + TERN_(HAS_PTC, ptc.apply_compensation(measured_z)); } if (!isnan(measured_z)) { const bool big_raise = raise_after == PROBE_PT_BIG_RAISE;