Minor G12 tweaks and point_t struct extension

This commit is contained in:
João Brázio 2016-07-14 00:07:36 +01:00
parent 021544f572
commit 4937f9ada4
4 changed files with 58 additions and 27 deletions

View file

@ -2717,18 +2717,15 @@ inline void gcode_G4() {
#endif //FWRETRACT
#if ENABLED(CLEAN_NOZZLE_FEATURE) && ENABLED(AUTO_BED_LEVELING_FEATURE)
#if ENABLED(NOZZLE_CLEAN_FEATURE) && ENABLED(AUTO_BED_LEVELING_FEATURE)
#include "nozzle.h"
inline void gcode_G12() {
// Don't allow nozzle cleaning without homing first
if (!axis_homed[X_AXIS] || !axis_homed[Y_AXIS] || !axis_homed[Z_AXIS]) {
axis_unhomed_error(true);
return;
}
if (axis_unhomed_error(true, true, true)) { return; }
uint8_t const pattern = code_seen('P') ? code_value_ushort() : 0;
uint8_t const strokes = code_seen('S') ? code_value_ushort() : CLEAN_NOZZLE_STROKES;
uint8_t const strokes = code_seen('S') ? code_value_ushort() : NOZZLE_CLEAN_STROKES;
uint8_t const objects = code_seen('T') ? code_value_ushort() : 3;
Nozzle::clean(pattern, strokes, objects);
@ -6796,11 +6793,11 @@ void process_next_command() {
break;
#endif // FWRETRACT
#if ENABLED(CLEAN_NOZZLE_FEATURE) && ENABLED(AUTO_BED_LEVELING_FEATURE)
#if ENABLED(NOZZLE_CLEAN_FEATURE) && HAS_BED_PROBE
case 12:
gcode_G12(); // G12: Clean Nozzle
break;
#endif // CLEAN_NOZZLE_FEATURE
#endif // NOZZLE_CLEAN_FEATURE
#if ENABLED(INCH_MODE_SUPPORT)
case 20: //G20: Inch Mode

View file

@ -649,8 +649,8 @@
/**
* Nozzle cleaning
*/
#if ENABLED(CLEAN_NOZZLE_FEATURE) && DISABLED(AUTO_BED_LEVELING_FEATURE)
#error You must enable AUTO_BED_LEVELING_FEATURE for CLEAN_NOZZLE_FEATURE to work
#if ENABLED(NOZZLE_CLEAN_FEATURE) && !HAS_BED_PROBE
#error Due to internal dependencies you must have a bed probe for NOZZLE_CLEAN_FEATURE to work
#endif
#endif //SANITYCHECK_H

View file

@ -20,8 +20,8 @@
*
*/
#ifndef __CLEAN_NOZZLE_H__
#define __CLEAN_NOZZLE_H__
#ifndef __NOZZLE_H__
#define __NOZZLE_H__
#include "Marlin.h"
#include "point_t.h"
@ -30,7 +30,7 @@
* @brief Nozzle class
*
* @todo: Do not ignore the end.z value and allow XYZ movements
* @todo: Currently this feature needs AUTO_BED_LEVELING_FEATURE to be active
* @todo: Currently this feature needs HAS_BED_PROBE to be active
* due to the do_blocking_move_to*() functions.
*/
class Nozzle {
@ -45,6 +45,17 @@ class Nozzle {
*/
static void stroke(point_t const &start, point_t const &end, uint8_t const &strokes)
__attribute__ ((optimize ("Os"))) {
#if ENABLED(NOZZLE_CLEAN_PARK)
// Store the current coords
point_t const initial = {
current_position[X_AXIS],
current_position[Y_AXIS],
current_position[Z_AXIS],
current_position[E_AXIS]
};
#endif
// Move to the starting point
do_blocking_move_to_xy(start.x, start.y);
do_blocking_move_to_z(start.z);
@ -54,6 +65,12 @@ class Nozzle {
do_blocking_move_to_xy(end.x, end.y);
do_blocking_move_to_xy(start.x, start.y);
}
#if ENABLED(NOZZLE_CLEAN_PARK)
// Move the nozzle to the initial point
do_blocking_move_to_z(initial.z);
do_blocking_move_to_xy(initial.x, initial.y);
#endif
}
/**
@ -74,13 +91,15 @@ class Nozzle {
// Don't allow impossible triangles
if (A <= 0.0f || P <= 0.0f ) return;
// Store the current coords
point_t const home = {
current_position[X_AXIS],
current_position[Y_AXIS],
current_position[Z_AXIS],
current_position[E_AXIS]
};
#if ENABLED(NOZZLE_CLEAN_PARK)
// Store the current coords
point_t const initial = {
current_position[X_AXIS],
current_position[Y_AXIS],
current_position[Z_AXIS],
current_position[E_AXIS]
};
#endif
for (uint8_t j = 0; j < strokes; j++) {
for (uint8_t i = 0; i < (objects << 1); i++) {
@ -99,9 +118,11 @@ class Nozzle {
}
}
// Move to home/start position
do_blocking_move_to_z(home.z);
do_blocking_move_to_xy(home.x, home.y);
#if ENABLED(NOZZLE_CLEAN_PARK)
// Move the nozzle to the initial point
do_blocking_move_to_z(initial.z);
do_blocking_move_to_xy(initial.x, initial.y);
#endif
}
public:
@ -118,14 +139,14 @@ class Nozzle {
switch (pattern) {
case 1:
Nozzle::zigzag(
CLEAN_NOZZLE_START_PT,
CLEAN_NOZZLE_END_PT, strokes, objects);
NOZZLE_CLEAN_START_PT,
NOZZLE_CLEAN_END_PT, strokes, objects);
break;
default:
Nozzle::stroke(
CLEAN_NOZZLE_START_PT,
CLEAN_NOZZLE_END_PT, strokes);
NOZZLE_CLEAN_START_PT,
NOZZLE_CLEAN_END_PT, strokes);
}
}
};

View file

@ -28,6 +28,19 @@ struct point_t {
float y;
float z;
float e;
point_t(float const x, float const y)
: point_t(x, y, NAN, NAN) {}
point_t(float const x, float const y, float const z)
: point_t(x, y, z, NAN) {}
point_t(float const x, float const y, float const z, float const e) {
this->x = x;
this->y = y;
this->z = z;
this->e = e;
}
};
#endif