offensichtlich hab ich keine Ahnung was ich da mache.
bool runBedLeveling(int s) {
Com::printFLN(PSTR("P1"));HAL::delayMilliseconds(1000);
bool success = true;
#if DISTORTION_CORRECTION
bool distEnabled = Printer::distortion.isEnabled();
Printer::distortion.disable(
false); // if level has changed, distortion is also invalid
#endif
Printer::prepareForProbing();
#if defined(Z_PROBE_MIN_TEMPERATURE) && Z_PROBE_MIN_TEMPERATURE && Z_PROBE_REQUIRES_HEATING
float actTemp[NUM_EXTRUDER];
for (int i = 0; i < NUM_EXTRUDER; i++) {
actTemp[i] = extruder[i].tempControl.targetTemperatureC;
Com::printFLN(PSTR("P3"));HAL::delayMilliseconds(1000);
}
Printer::moveToReal(
IGNORE_COORDINATE, IGNORE_COORDINATE,
RMath::max(EEPROM::zProbeBedDistance() + (EEPROM::zProbeHeight() > 0 ? EEPROM::zProbeHeight() : 0),
static_cast<float>(ZHOME_HEAT_HEIGHT)),
IGNORE_COORDINATE, Printer::homingFeedrate[Z_AXIS]);
Commands::waitUntilEndOfAllMoves();
Com::printFLN(PSTR("P3"));HAL::delayMilliseconds(1000);
#if ZHOME_HEAT_ALL
for (int i = 0; i < NUM_EXTRUDER; i++) {
Extruder::setTemperatureForExtruder(
RMath::max(actTemp[i], static_cast<float>(ZPROBE_MIN_TEMPERATURE)), i,
false, false);
}
for (int i = 0; i < NUM_EXTRUDER; i++) {
if (extruder[i].tempControl.currentTemperatureC < ZPROBE_MIN_TEMPERATURE)
Extruder::setTemperatureForExtruder(
RMath::max(actTemp[i], static_cast<float>(ZPROBE_MIN_TEMPERATURE)), i,
false, true);
}
#else
if (extruder[Extruder::current->id].tempControl.currentTemperatureC < ZPROBE_MIN_TEMPERATURE)
Extruder::setTemperatureForExtruder(
RMath::max(actTemp[Extruder::current->id],
static_cast<float>(ZPROBE_MIN_TEMPERATURE)),
Extruder::current->id, false, true);
#endif
#endif // defined(Z_PROBE_MIN_TEMPERATURE) ...
float h1, h2, h3, hc, oldFeedrate = Printer::feedrate;
Printer::setAutolevelActive(false); // iterate
Printer::resetTransformationMatrix(
true); // in case we switch from matrix to motorized!
#if DRIVE_SYSTEM == DELTA
// It is not possible to go to the edges at the top, also users try
// it often and wonder why the coordinate system is then wrong.
// For that reason we ensure a correct behavior by code.
if (!Printer::isHomedAll()) {
Printer::homeAxis(true, true, true);
}
Printer::moveTo(IGNORE_COORDINATE, IGNORE_COORDINATE,
EEPROM::zProbeBedDistance() + (EEPROM::zProbeHeight() > 0 ? EEPROM::zProbeHeight() : 0),
IGNORE_COORDINATE, Printer::homingFeedrate[Z_AXIS]);
#else
if (!Printer::isXHomed() || !Printer::isYHomed())
Printer::homeAxis(true, true, false);
Printer::updateCurrentPosition(true);
// Printer::moveTo(EEPROM::zProbeX1(), EEPROM::zProbeY1(), IGNORE_COORDINATE,
// IGNORE_COORDINATE, EEPROM::zProbeXYSpeed());
Printer::moveTo(IGNORE_COORDINATE, IGNORE_COORDINATE, IGNORE_COORDINATE,
IGNORE_COORDINATE, EEPROM::zProbeXYSpeed());
Com::printFLN(PSTR("P2"));HAL::delayMilliseconds(1000);
#endif
Printer::coordinateOffset[X_AXIS] = Printer::coordinateOffset[Y_AXIS] = Printer::coordinateOffset[Z_AXIS] = 0;
if (!Printer::startProbing(true)) {
return false;
Com::printFLN(PSTR("P3"));HAL::delayMilliseconds(1000);
}
// GCode::executeFString(Com::tZProbeStartScript);
Plane plane;
#if BED_CORRECTION_METHOD == 1
success = false;
for (int r = 0; r < BED_LEVELING_REPETITIONS; r++) {
#if DRIVE_SYSTEM == DELTA
if (r > 0) {
Printer::finishProbing();
Printer::homeAxis(true, true, true);
Printer::moveTo(
IGNORE_COORDINATE, IGNORE_COORDINATE,
EEPROM::zProbeBedDistance() + (EEPROM::zProbeHeight() > 0 ? EEPROM::zProbeHeight() : 0),
IGNORE_COORDINATE, Printer::homingFeedrate[Z_AXIS]);
if (!Printer::startProbing(true)) {
return false;
Com::printFLN(PSTR("P4"));HAL::delayMilliseconds(1000);
}
}
#endif // DELTA
#endif // BED_CORRECTION_METHOD == 1
if (!measureAutolevelPlane(plane)) {
Com::printErrorFLN(
PSTR("Probing had returned errors - autoleveling canceled."));
UI_MESSAGE(1);
return false;
}
correctAutolevel(plane);
// Leveling is finished now update own positions and store leveling data if
// needed
// float currentZ = plane.z((float)Printer::currentPositionSteps[X_AXIS]
// Printer::invAxisStepsPerMM[X_AXIS],(float)Printer::currentPositionSteps[Y_AXIS]
// * Printer::invAxisStepsPerMM[Y_AXIS]);
float currentZ = plane.z(
0.0, 0.0); // we rotated around this point, so that is now z height
// With max z end stop we adjust z length so after next homing we have also
// a calibrated printer
Printer::zMin = 0;
#if MAX_HARDWARE_ENDSTOP_Z
// float xRot,yRot,zRot;
// Printer::transformFromPrinter(Printer::currentPosition[X_AXIS],Printer::currentPosition[Y_AXIS],Printer::currentPosition[Z_AXIS],xRot,yRot,zRot);
// Com::printFLN(PSTR("Z after rotation:"),zRot);
// With max z end stop we adjust z length so after next homing we have also
// a calibrated printer
if (s != 0) {
// at origin rotations have no influence so use values there to update
Printer::zLength += currentZ - Printer::currentPosition[Z_AXIS];
// Printer::zLength += /*currentZ*/
// plane.z((float)Printer::currentPositionSteps[X_AXIS] *
// Printer::invAxisStepsPerMM[X_AXIS],(float)Printer::currentPositionSteps[Y_AXIS]
// * Printer::invAxisStepsPerMM[Y_AXIS]) - zRot;
Com::printFLN(Com::tZProbePrinterHeight, Printer::zLength);
Com::printFLN(PSTR("P5"));HAL::delayMilliseconds(1000);
}
#endif