Skip to content

Commit

Permalink
rename method
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Feb 22, 2022
1 parent 7c5d634 commit f641794
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 12 deletions.
5 changes: 2 additions & 3 deletions Marlin/src/feature/probe_temp_comp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 4 additions & 2 deletions Marlin/src/feature/probe_temp_comp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 1 addition & 3 deletions Marlin/src/gcode/calibrate/M48.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,14 @@ 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
const bool was_enabled = planner.leveling_active;
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();
Expand Down
5 changes: 2 additions & 3 deletions Marlin/src/gcode/probe/G30.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/module/probe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f641794

Please sign in to comment.