Skip to content

Commit

Permalink
Move cali_info_init up
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Apr 3, 2020
1 parent e4a6df8 commit 649cce0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
10 changes: 5 additions & 5 deletions Marlin/src/feature/probe_temp_comp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@

ProbeTempComp temp_comp;

int16_t ProbeTempComp::z_offsets_probe[ProbeTempComp::cali_info_init[TSI_PROBE].measurements], // = {0}
ProbeTempComp::z_offsets_bed[ProbeTempComp::cali_info_init[TSI_BED].measurements]; // = {0}
int16_t ProbeTempComp::z_offsets_probe[cali_info_init[TSI_PROBE].measurements], // = {0}
ProbeTempComp::z_offsets_bed[cali_info_init[TSI_BED].measurements]; // = {0}

#if ENABLED(USE_TEMP_EXT_COMPENSATION)
int16_t ProbeTempComp::z_offsets_ext[ProbeTempComp::cali_info_init[TSI_EXT].measurements]; // = {0}
int16_t ProbeTempComp::z_offsets_ext[cali_info_init[TSI_EXT].measurements]; // = {0}
#endif

int16_t *ProbeTempComp::sensor_z_offsets[TSI_COUNT] = {
Expand All @@ -44,9 +44,9 @@ int16_t *ProbeTempComp::sensor_z_offsets[TSI_COUNT] = {
};

const temp_calib_t ProbeTempComp::cali_info[TSI_COUNT] = {
ProbeTempComp::cali_info_init[TSI_PROBE], ProbeTempComp::cali_info_init[TSI_BED]
cali_info_init[TSI_PROBE], cali_info_init[TSI_BED]
#if ENABLED(USE_TEMP_EXT_COMPENSATION)
, ProbeTempComp::cali_info_init[TSI_EXT]
, cali_info_init[TSI_EXT]
#endif
};

Expand Down
16 changes: 9 additions & 7 deletions Marlin/src/feature/probe_temp_comp.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,18 @@ typedef struct {
* Z-probes like the P.I.N.D.A V2 allow for compensation of
* measurement errors/shifts due to changed temperature.
*/

static constexpr temp_calib_t cali_info_init[TSI_COUNT] = {
{ 10, 5, 30, 30 + 10 * 5 }, // Probe
{ 10, 5, 60, 60 + 10 * 5 }, // Bed
#if ENABLED(USE_TEMP_EXT_COMPENSATION)
{ 20, 5, 180, 180 + 5 * 20 } // Extruder
#endif
};

class ProbeTempComp {
public:

static constexpr temp_calib_t cali_info_init[TSI_COUNT] = {
{ 10, 5, 30, 30 + 10 * 5 }, // Probe
{ 10, 5, 60, 60 + 10 * 5 }, // Bed
#if ENABLED(USE_TEMP_EXT_COMPENSATION)
{ 20, 5, 180, 180 + 5 * 20 } // Extruder
#endif
};
static const temp_calib_t cali_info[TSI_COUNT];

// Where to park nozzle to wait for probe cooldown
Expand Down
10 changes: 5 additions & 5 deletions Marlin/src/gcode/calibrate/G76_M871.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ void GcodeSuite::G76() {
SERIAL_ECHOLNPGM("!Received NAN. Aborting.");
else {
SERIAL_ECHOLNPAIR_F("Measured: ", measured_z);
if (targ == temp_comp.cali_info_init[sid].start_temp)
if (targ == cali_info_init[sid].start_temp)
temp_comp.prepare_new_calibration(measured_z);
else
temp_comp.push_back_new_measurement(sid, measured_z);
targ += temp_comp.cali_info_init[sid].temp_res;
targ += cali_info_init[sid].temp_res;
}
return measured_z;
};
Expand Down Expand Up @@ -172,7 +172,7 @@ void GcodeSuite::G76() {

if (do_bed_cal) {

uint16_t target_bed = temp_comp.cali_info_init[TSI_BED].start_temp,
uint16_t target_bed = cali_info_init[TSI_BED].start_temp,
target_probe = temp_comp.bed_calib_probe_temp;

SERIAL_ECHOLNPGM("Waiting for cooling.");
Expand Down Expand Up @@ -234,7 +234,7 @@ void GcodeSuite::G76() {
const uint16_t target_bed = temp_comp.probe_calib_bed_temp;
thermalManager.setTargetBed(target_bed);

uint16_t target_probe = temp_comp.cali_info_init[TSI_PROBE].start_temp;
uint16_t target_probe = cali_info_init[TSI_PROBE].start_temp;

report_targets(target_bed, target_probe);

Expand Down Expand Up @@ -263,7 +263,7 @@ void GcodeSuite::G76() {
if (timeout) break;

const float measured_z = g76_probe(TSI_PROBE, target_probe, probe_noz_pos);
if (isnan(measured_z) || target_probe > temp_comp.cali_info_init[TSI_PROBE].end_temp) break;
if (isnan(measured_z) || target_probe > cali_info_init[TSI_PROBE].end_temp) break;
}

SERIAL_ECHOLNPAIR("Retrieved measurements: ", temp_comp.get_index());
Expand Down

0 comments on commit 649cce0

Please sign in to comment.