Move debug code
This commit is contained in:
parent
3db5303bfe
commit
3d796d8040
|
@ -55,6 +55,59 @@
|
||||||
safe_delay(10);
|
safe_delay(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ENABLED(UBL_DEVEL_DEBUGGING)
|
||||||
|
|
||||||
|
static void debug_echo_axis(const AxisEnum axis) {
|
||||||
|
if (current_position[axis] == destination[axis])
|
||||||
|
SERIAL_ECHOPGM("-------------");
|
||||||
|
else
|
||||||
|
SERIAL_ECHO_F(destination[X_AXIS], 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
void debug_current_and_destination(const char *title) {
|
||||||
|
|
||||||
|
// if the title message starts with a '!' it is so important, we are going to
|
||||||
|
// ignore the status of the g26_debug_flag
|
||||||
|
if (*title != '!' && !g26_debug_flag) return;
|
||||||
|
|
||||||
|
const float de = destination[E_AXIS] - current_position[E_AXIS];
|
||||||
|
|
||||||
|
if (de == 0.0) return; // Printing moves only
|
||||||
|
|
||||||
|
const float dx = destination[X_AXIS] - current_position[X_AXIS],
|
||||||
|
dy = destination[Y_AXIS] - current_position[Y_AXIS],
|
||||||
|
xy_dist = HYPOT(dx, dy);
|
||||||
|
|
||||||
|
if (xy_dist == 0.0) return;
|
||||||
|
|
||||||
|
SERIAL_ECHOPGM(" fpmm=");
|
||||||
|
const float fpmm = de / xy_dist;
|
||||||
|
SERIAL_ECHO_F(fpmm, 6);
|
||||||
|
|
||||||
|
SERIAL_ECHOPGM(" current=( ");
|
||||||
|
SERIAL_ECHO_F(current_position[X_AXIS], 6);
|
||||||
|
SERIAL_ECHOPGM(", ");
|
||||||
|
SERIAL_ECHO_F(current_position[Y_AXIS], 6);
|
||||||
|
SERIAL_ECHOPGM(", ");
|
||||||
|
SERIAL_ECHO_F(current_position[Z_AXIS], 6);
|
||||||
|
SERIAL_ECHOPGM(", ");
|
||||||
|
SERIAL_ECHO_F(current_position[E_AXIS], 6);
|
||||||
|
SERIAL_ECHOPGM(" ) destination=( ");
|
||||||
|
debug_echo_axis(X_AXIS);
|
||||||
|
SERIAL_ECHOPGM(", ");
|
||||||
|
debug_echo_axis(Y_AXIS);
|
||||||
|
SERIAL_ECHOPGM(", ");
|
||||||
|
debug_echo_axis(Z_AXIS);
|
||||||
|
SERIAL_ECHOPGM(", ");
|
||||||
|
debug_echo_axis(E_AXIS);
|
||||||
|
SERIAL_ECHOPGM(" ) ");
|
||||||
|
SERIAL_ECHO(title);
|
||||||
|
SERIAL_EOL();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // UBL_DEVEL_DEBUGGING
|
||||||
|
|
||||||
int8_t unified_bed_leveling::storage_slot;
|
int8_t unified_bed_leveling::storage_slot;
|
||||||
|
|
||||||
float unified_bed_leveling::z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
|
float unified_bed_leveling::z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
|
||||||
|
@ -178,7 +231,7 @@
|
||||||
uint8_t error_flag = 0;
|
uint8_t error_flag = 0;
|
||||||
|
|
||||||
if (settings.calc_num_meshes() < 1) {
|
if (settings.calc_num_meshes() < 1) {
|
||||||
SERIAL_PROTOCOLLNPGM("?Insufficient EEPROM storage for a mesh of this size.");
|
SERIAL_PROTOCOLLNPGM("?Mesh too big for EEPROM.");
|
||||||
error_flag++;
|
error_flag++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
#ifndef UNIFIED_BED_LEVELING_H
|
#ifndef UNIFIED_BED_LEVELING_H
|
||||||
#define UNIFIED_BED_LEVELING_H
|
#define UNIFIED_BED_LEVELING_H
|
||||||
|
|
||||||
|
//#define UBL_DEVEL_DEBUGGING
|
||||||
|
|
||||||
#include "../bedlevel.h"
|
#include "../bedlevel.h"
|
||||||
#include "../../../module/planner.h"
|
#include "../../../module/planner.h"
|
||||||
#include "../../../module/motion.h"
|
#include "../../../module/motion.h"
|
||||||
|
@ -37,7 +39,11 @@
|
||||||
|
|
||||||
// ubl_motion.cpp
|
// ubl_motion.cpp
|
||||||
|
|
||||||
void debug_current_and_destination(const char * const title);
|
#if ENABLED(UBL_DEVEL_DEBUGGING)
|
||||||
|
void debug_current_and_destination(const char * const title);
|
||||||
|
#else
|
||||||
|
FORCE_INLINE void debug_current_and_destination(const char * const title) { UNUSED(title); }
|
||||||
|
#endif
|
||||||
|
|
||||||
// ubl_G29.cpp
|
// ubl_G29.cpp
|
||||||
|
|
||||||
|
@ -217,9 +223,9 @@ class unified_bed_leveling {
|
||||||
const float xratio = (rx0 - mesh_index_to_xpos(x1_i)) * (1.0 / (MESH_X_DIST)),
|
const float xratio = (rx0 - mesh_index_to_xpos(x1_i)) * (1.0 / (MESH_X_DIST)),
|
||||||
z1 = z_values[x1_i][yi];
|
z1 = z_values[x1_i][yi];
|
||||||
|
|
||||||
return z1 + xratio * (z_values[min(x1_i, GRID_MAX_POINTS_X - 2) + 1][yi] - z1); // Don't allow x1_i+1 to be past the end of the array
|
return z1 + xratio * (z_values[min(x1_i, GRID_MAX_POINTS_X - 2) + 1][yi] - z1); // Don't allow x1_i+1 to be past the end of the array
|
||||||
// If it is, it is clamped to the last element of the
|
// If it is, it is clamped to the last element of the
|
||||||
// z_values[][] array and no correction is applied.
|
// z_values[][] array and no correction is applied.
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -243,9 +249,9 @@ class unified_bed_leveling {
|
||||||
const float yratio = (ry0 - mesh_index_to_ypos(y1_i)) * (1.0 / (MESH_Y_DIST)),
|
const float yratio = (ry0 - mesh_index_to_ypos(y1_i)) * (1.0 / (MESH_Y_DIST)),
|
||||||
z1 = z_values[xi][y1_i];
|
z1 = z_values[xi][y1_i];
|
||||||
|
|
||||||
return z1 + yratio * (z_values[xi][min(y1_i, GRID_MAX_POINTS_Y - 2) + 1] - z1); // Don't allow y1_i+1 to be past the end of the array
|
return z1 + yratio * (z_values[xi][min(y1_i, GRID_MAX_POINTS_Y - 2) + 1] - z1); // Don't allow y1_i+1 to be past the end of the array
|
||||||
// If it is, it is clamped to the last element of the
|
// If it is, it is clamped to the last element of the
|
||||||
// z_values[][] array and no correction is applied.
|
// z_values[][] array and no correction is applied.
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -35,63 +35,12 @@
|
||||||
#include "../../../Marlin.h"
|
#include "../../../Marlin.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
extern float destination[XYZE];
|
|
||||||
|
|
||||||
#if AVR_AT90USB1286_FAMILY // Teensyduino & Printrboard IDE extensions have compile errors without this
|
#if AVR_AT90USB1286_FAMILY // Teensyduino & Printrboard IDE extensions have compile errors without this
|
||||||
inline void set_current_from_destination() { COPY(current_position, destination); }
|
inline void set_current_from_destination() { COPY(current_position, destination); }
|
||||||
#else
|
#else
|
||||||
extern void set_current_from_destination();
|
extern void set_current_from_destination();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void debug_echo_axis(const AxisEnum axis) {
|
|
||||||
if (current_position[axis] == destination[axis])
|
|
||||||
SERIAL_ECHOPGM("-------------");
|
|
||||||
else
|
|
||||||
SERIAL_ECHO_F(destination[X_AXIS], 6);
|
|
||||||
}
|
|
||||||
|
|
||||||
void debug_current_and_destination(const char *title) {
|
|
||||||
|
|
||||||
// if the title message starts with a '!' it is so important, we are going to
|
|
||||||
// ignore the status of the g26_debug_flag
|
|
||||||
if (*title != '!' && !g26_debug_flag) return;
|
|
||||||
|
|
||||||
const float de = destination[E_AXIS] - current_position[E_AXIS];
|
|
||||||
|
|
||||||
if (de == 0.0) return; // Printing moves only
|
|
||||||
|
|
||||||
const float dx = destination[X_AXIS] - current_position[X_AXIS],
|
|
||||||
dy = destination[Y_AXIS] - current_position[Y_AXIS],
|
|
||||||
xy_dist = HYPOT(dx, dy);
|
|
||||||
|
|
||||||
if (xy_dist == 0.0) return;
|
|
||||||
|
|
||||||
SERIAL_ECHOPGM(" fpmm=");
|
|
||||||
const float fpmm = de / xy_dist;
|
|
||||||
SERIAL_ECHO_F(fpmm, 6);
|
|
||||||
|
|
||||||
SERIAL_ECHOPGM(" current=( ");
|
|
||||||
SERIAL_ECHO_F(current_position[X_AXIS], 6);
|
|
||||||
SERIAL_ECHOPGM(", ");
|
|
||||||
SERIAL_ECHO_F(current_position[Y_AXIS], 6);
|
|
||||||
SERIAL_ECHOPGM(", ");
|
|
||||||
SERIAL_ECHO_F(current_position[Z_AXIS], 6);
|
|
||||||
SERIAL_ECHOPGM(", ");
|
|
||||||
SERIAL_ECHO_F(current_position[E_AXIS], 6);
|
|
||||||
SERIAL_ECHOPGM(" ) destination=( ");
|
|
||||||
debug_echo_axis(X_AXIS);
|
|
||||||
SERIAL_ECHOPGM(", ");
|
|
||||||
debug_echo_axis(Y_AXIS);
|
|
||||||
SERIAL_ECHOPGM(", ");
|
|
||||||
debug_echo_axis(Z_AXIS);
|
|
||||||
SERIAL_ECHOPGM(", ");
|
|
||||||
debug_echo_axis(E_AXIS);
|
|
||||||
SERIAL_ECHOPGM(" ) ");
|
|
||||||
SERIAL_ECHO(title);
|
|
||||||
SERIAL_EOL();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void unified_bed_leveling::line_to_destination_cartesian(const float &feed_rate, const uint8_t extruder) {
|
void unified_bed_leveling::line_to_destination_cartesian(const float &feed_rate, const uint8_t extruder) {
|
||||||
/**
|
/**
|
||||||
* Much of the nozzle movement will be within the same cell. So we will do as little computation
|
* Much of the nozzle movement will be within the same cell. So we will do as little computation
|
||||||
|
@ -123,7 +72,7 @@
|
||||||
SERIAL_ECHOPAIR(", ee=", end[E_AXIS]);
|
SERIAL_ECHOPAIR(", ee=", end[E_AXIS]);
|
||||||
SERIAL_CHAR(')');
|
SERIAL_CHAR(')');
|
||||||
SERIAL_EOL();
|
SERIAL_EOL();
|
||||||
debug_current_and_destination(PSTR("Start of ubl.line_to_destination()"));
|
debug_current_and_destination(PSTR("Start of ubl.line_to_destination_cartesian()"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cell_start_xi == cell_dest_xi && cell_start_yi == cell_dest_yi) { // if the whole move is within the same cell,
|
if (cell_start_xi == cell_dest_xi && cell_start_yi == cell_dest_yi) { // if the whole move is within the same cell,
|
||||||
|
@ -143,7 +92,7 @@
|
||||||
set_current_from_destination();
|
set_current_from_destination();
|
||||||
|
|
||||||
if (g26_debug_flag)
|
if (g26_debug_flag)
|
||||||
debug_current_and_destination(PSTR("out of bounds in ubl.line_to_destination()"));
|
debug_current_and_destination(PSTR("out of bounds in ubl.line_to_destination_cartesian()"));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -186,7 +135,7 @@
|
||||||
planner.buffer_segment(end[X_AXIS], end[Y_AXIS], end[Z_AXIS] + z0, end[E_AXIS], feed_rate, extruder);
|
planner.buffer_segment(end[X_AXIS], end[Y_AXIS], end[Z_AXIS] + z0, end[E_AXIS], feed_rate, extruder);
|
||||||
|
|
||||||
if (g26_debug_flag)
|
if (g26_debug_flag)
|
||||||
debug_current_and_destination(PSTR("FINAL_MOVE in ubl.line_to_destination()"));
|
debug_current_and_destination(PSTR("FINAL_MOVE in ubl.line_to_destination_cartesian()"));
|
||||||
|
|
||||||
set_current_from_destination();
|
set_current_from_destination();
|
||||||
return;
|
return;
|
||||||
|
@ -292,7 +241,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g26_debug_flag)
|
if (g26_debug_flag)
|
||||||
debug_current_and_destination(PSTR("vertical move done in ubl.line_to_destination()"));
|
debug_current_and_destination(PSTR("vertical move done in ubl.line_to_destination_cartesian()"));
|
||||||
|
|
||||||
//
|
//
|
||||||
// Check if we are at the final destination. Usually, we won't be, but if it is on a Y Mesh Line, we are done.
|
// Check if we are at the final destination. Usually, we won't be, but if it is on a Y Mesh Line, we are done.
|
||||||
|
@ -356,7 +305,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g26_debug_flag)
|
if (g26_debug_flag)
|
||||||
debug_current_and_destination(PSTR("horizontal move done in ubl.line_to_destination()"));
|
debug_current_and_destination(PSTR("horizontal move done in ubl.line_to_destination_cartesian()"));
|
||||||
|
|
||||||
if (current_position[X_AXIS] != end[X_AXIS] || current_position[Y_AXIS] != end[Y_AXIS])
|
if (current_position[X_AXIS] != end[X_AXIS] || current_position[Y_AXIS] != end[Y_AXIS])
|
||||||
goto FINAL_MOVE;
|
goto FINAL_MOVE;
|
||||||
|
@ -450,7 +399,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g26_debug_flag)
|
if (g26_debug_flag)
|
||||||
debug_current_and_destination(PSTR("generic move done in ubl.line_to_destination()"));
|
debug_current_and_destination(PSTR("generic move done in ubl.line_to_destination_cartesian()"));
|
||||||
|
|
||||||
if (current_position[X_AXIS] != end[X_AXIS] || current_position[Y_AXIS] != end[Y_AXIS])
|
if (current_position[X_AXIS] != end[X_AXIS] || current_position[Y_AXIS] != end[Y_AXIS])
|
||||||
goto FINAL_MOVE;
|
goto FINAL_MOVE;
|
||||||
|
|
Loading…
Reference in a new issue