I've took liberty of writing code for Z-Homing using z-probe. But since I have no idea how internals of FV work, this code can be buggy, or some important aspects could be omitted. It does however work for me. It should be added at the beginning of Printer::homeZAxis for cartesian printers.
/*
Code intended for usage with inductive sensor triggered before extruder can touch platform.
XY Homing MUST be executed before Z-Homing, as Z-Homing will require valid XY coordinates to
move probe into P0 position.
No ifdef, compiler should optimize this anyway
*/
if (!MIN_HARDWARE_ENDSTOP_Z && !MAX_HARDWARE_ENDSTOP_Z && FEATURE_Z_PROBE && Z_PROBE_AS_MIN_ENDSTOP && Z_HOME_DIR == -1)
{
float probeX = EEPROM::zProbeX1();
float probeY = EEPROM::zProbeY1();
UI_STATUS_UPD_F(Com::translatedF(UI_TEXT_HOME_Z_ID));
// Check if probe is triggered, if it is, probe is too low. So rise it by Z_PROBE_BED_DISTANCE.
if (digitalRead(Z_PROBE_PIN) == Z_PROBE_ON_HIGH)
{
PrintLine::moveRelativeDistanceInSteps(0, 0, Z_PROBE_BED_DISTANCE * axisStepsPerMM[Z_AXIS], 0, EEPROM::zProbeSpeed(), true, true);
}
// but probe could be outside bed area, to be sure - move it to P0 position
moveTo(probeX, probeY, IGNORE_COORDINATE, IGNORE_COORDINATE, EEPROM::zProbeXYSpeed());
// And check again it's status, it could move from outise the bed so signal before could be invalid
if (digitalRead(Z_PROBE_PIN) == Z_PROBE_ON_HIGH)
{
PrintLine::moveRelativeDistanceInSteps(0, 0, Z_PROBE_BED_DISTANCE * axisStepsPerMM[Z_AXIS], 0, EEPROM::zProbeSpeed(), true, true);
}
// Check probe again, if it's still triggered, this means something is wrong
if (digitalRead(Z_PROBE_PIN) == Z_PROBE_ON_HIGH)
{
Com::printErrorFLN(Com::tZProbeFailed);
return;
}
steps = 2 * (Printer::zMaxSteps - Printer::zMinSteps);
waitForZProbeStart();
stepsRemainingAtZHit = -1;
setZProbingActive(true);
PrintLine::moveRelativeDistanceInSteps(0, 0, -steps, 0, EEPROM::zProbeSpeed(), true, true);
if(stepsRemainingAtZHit < 0)
{
Com::printErrorFLN(Com::tZProbeFailed);
return;
}
setZProbingActive(false);
currentPositionSteps[Z_AXIS] = zMinSteps + (axisStepsPerMM[Z_AXIS] * EEPROM::zProbeZOffset());
moveTo(0, 0, 0, IGNORE_COORDINATE, EEPROM::zProbeXYSpeed());
return;
}