Finish G12, update Nozzle::clean (#14642)

This commit is contained in:
InsanityAutomation
2019-07-17 04:41:04 -04:00
committed by Scott Lahteine
parent 57ed063ba1
commit b8cc61262f
10 changed files with 57 additions and 55 deletions

View File

@ -74,7 +74,6 @@ struct measurements_t {
float nozzle_outer_dimension[2] = {CALIBRATION_NOZZLE_OUTER_DIAMETER, CALIBRATION_NOZZLE_OUTER_DIAMETER};
};
#define TEMPORARY_BED_LEVELING_STATE(enable) TemporaryBedLevelingState tbls(enable)
#define TEMPORARY_SOFT_ENDSTOP_STATE(enable) REMEMBER(tes, soft_endstops_enabled, enable);
#if ENABLED(BACKLASH_GCODE)
@ -89,20 +88,6 @@ struct measurements_t {
#define TEMPORARY_BACKLASH_SMOOTHING(value)
#endif
/**
* A class to save and change the bed leveling state,
* then restore it when it goes out of scope.
*/
class TemporaryBedLevelingState {
bool saved;
public:
TemporaryBedLevelingState(const bool enable) : saved(planner.leveling_active) {
set_bed_leveling_enabled(enable);
}
~TemporaryBedLevelingState() { set_bed_leveling_enabled(saved); }
};
/**
* Move to a particular location. Up to three individual axes
* and their destinations can be specified, in any order.

View File

@ -42,32 +42,25 @@ void GcodeSuite::G12() {
// Don't allow nozzle cleaning without homing first
if (axis_unhomed_error()) return;
const bool seenxyz = parser.seen("XYZ"),
clean_x = !seenxyz || parser.boolval('X'),
clean_y = !seenxyz || parser.boolval('Y');
#if ENABLED(NOZZLE_CLEAN_NO_Z)
static constexpr bool clean_z = false;
#else
const bool clean_z = !seenxyz || parser.boolval('Z');
#endif
const uint8_t pattern = parser.ushortval('P', 0),
strokes = parser.ushortval('S', NOZZLE_CLEAN_STROKES),
objects = parser.ushortval('T', NOZZLE_CLEAN_TRIANGLES);
const float radius = parser.floatval('R', NOZZLE_CLEAN_CIRCLE_RADIUS);
const bool seenxyz = parser.seen("XYZ");
const uint8_t cleans = (!seenxyz || parser.boolval('X') ? _BV(X_AXIS) : 0)
| (!seenxyz || parser.boolval('Y') ? _BV(Y_AXIS) : 0)
#if DISABLED(NOZZLE_CLEAN_NO_Z)
| (!seenxyz || parser.boolval('Z') ? _BV(Z_AXIS) : 0)
#endif
;
#if HAS_LEVELING
const bool was_enabled = planner.leveling_active;
if (clean_z) set_bed_leveling_enabled(false);
// Disable bed leveling if cleaning Z
TEMPORARY_BED_LEVELING_STATE(!TEST(cleans, Z_AXIS) && planner.leveling_active);
#endif
Nozzle::clean(pattern, strokes, radius, objects, clean_x, clean_y, clean_z);
// Re-enable bed level correction if it had been on
#if HAS_LEVELING
if (clean_z) set_bed_leveling_enabled(was_enabled);
#endif
nozzle.clean(pattern, strokes, radius, objects, cleans);
}
#endif // NOZZLE_CLEAN_FEATURE

View File

@ -35,7 +35,7 @@
void GcodeSuite::G27() {
// Don't allow nozzle parking without homing first
if (axis_unhomed_error()) return;
Nozzle::park(parser.ushortval('P'));
nozzle.park(parser.ushortval('P'));
}
#endif // NOZZLE_PARK_FEATURE