|
|
|
@ -51,7 +51,7 @@
|
|
|
|
|
) {
|
|
|
|
|
if (!leveling_is_valid()) return;
|
|
|
|
|
SERIAL_ECHO_START_P(port);
|
|
|
|
|
SERIAL_ECHOLNPGM_P(port, " G29 I 999");
|
|
|
|
|
SERIAL_ECHOLNPGM_P(port, " G29 I99");
|
|
|
|
|
for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
|
|
|
|
|
for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
|
|
|
|
|
if (!isnan(z_values[x][y])) {
|
|
|
|
@ -59,9 +59,7 @@
|
|
|
|
|
SERIAL_ECHOPAIR_P(port, " M421 I", x);
|
|
|
|
|
SERIAL_ECHOPAIR_P(port, " J", y);
|
|
|
|
|
SERIAL_ECHOPGM_P(port, " Z");
|
|
|
|
|
SERIAL_ECHO_F_P(port, z_values[x][y], 6);
|
|
|
|
|
SERIAL_ECHOPAIR_P(port, " ; X", LOGICAL_X_POSITION(mesh_index_to_xpos(x)));
|
|
|
|
|
SERIAL_ECHOPAIR_P(port, ", Y", LOGICAL_Y_POSITION(mesh_index_to_ypos(y)));
|
|
|
|
|
SERIAL_ECHO_F_P(port, z_values[x][y], 2);
|
|
|
|
|
SERIAL_EOL_P(port);
|
|
|
|
|
safe_delay(75); // Prevent Printrun from exploding
|
|
|
|
|
}
|
|
|
|
@ -83,15 +81,6 @@
|
|
|
|
|
safe_delay(50);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void serial_echo_xy(const int16_t x, const int16_t y) {
|
|
|
|
|
SERIAL_CHAR('(');
|
|
|
|
|
SERIAL_ECHO(x);
|
|
|
|
|
SERIAL_CHAR(',');
|
|
|
|
|
SERIAL_ECHO(y);
|
|
|
|
|
SERIAL_CHAR(')');
|
|
|
|
|
safe_delay(10);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if ENABLED(UBL_DEVEL_DEBUGGING)
|
|
|
|
|
|
|
|
|
|
static void debug_echo_axis(const AxisEnum axis) {
|
|
|
|
@ -189,78 +178,109 @@
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// display_map() currently produces three different mesh map types
|
|
|
|
|
// 0 : suitable for PronterFace and Repetier's serial console
|
|
|
|
|
// 1 : .CSV file suitable for importation into various spread sheets
|
|
|
|
|
// 2 : disply of the map data on a RepRap Graphical LCD Panel
|
|
|
|
|
static void serial_echo_xy(const uint8_t sp, const int16_t x, const int16_t y) {
|
|
|
|
|
SERIAL_ECHO_SP(sp);
|
|
|
|
|
SERIAL_CHAR('(');
|
|
|
|
|
if (x < 100) { SERIAL_CHAR(' '); if (x < 10) SERIAL_CHAR(' '); }
|
|
|
|
|
SERIAL_ECHO(x);
|
|
|
|
|
SERIAL_CHAR(',');
|
|
|
|
|
if (y < 100) { SERIAL_CHAR(' '); if (y < 10) SERIAL_CHAR(' '); }
|
|
|
|
|
SERIAL_ECHO(y);
|
|
|
|
|
SERIAL_CHAR(')');
|
|
|
|
|
safe_delay(5);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void serial_echo_column_labels(const uint8_t sp) {
|
|
|
|
|
SERIAL_ECHO_SP(7);
|
|
|
|
|
for (int8_t i = 0; i < GRID_MAX_POINTS_X; i++) {
|
|
|
|
|
if (i < 10) SERIAL_CHAR(' ');
|
|
|
|
|
SERIAL_ECHO(i);
|
|
|
|
|
SERIAL_ECHO_SP(sp);
|
|
|
|
|
}
|
|
|
|
|
safe_delay(10);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Produce one of these mesh maps:
|
|
|
|
|
* 0: Human-readable
|
|
|
|
|
* 1: CSV format for spreadsheet import
|
|
|
|
|
* 2: TODO: Display on Graphical LCD
|
|
|
|
|
* 4: Compact Human-Readable
|
|
|
|
|
*/
|
|
|
|
|
void unified_bed_leveling::display_map(const int map_type) {
|
|
|
|
|
#if HAS_AUTO_REPORTING || ENABLED(HOST_KEEPALIVE_FEATURE)
|
|
|
|
|
suspend_auto_report = true;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
constexpr uint8_t spaces = 8 * (GRID_MAX_POINTS_X - 2);
|
|
|
|
|
constexpr uint8_t eachsp = 1 + 6 + 1, // [-3.567]
|
|
|
|
|
twixt = eachsp * (GRID_MAX_POINTS_X) - 9 * 2; // Leading 4sp, Coordinates 9sp each
|
|
|
|
|
|
|
|
|
|
SERIAL_PROTOCOLPGM("\nBed Topography Report");
|
|
|
|
|
if (map_type == 0) {
|
|
|
|
|
SERIAL_PROTOCOLPGM(":\n\n");
|
|
|
|
|
serial_echo_xy(0, GRID_MAX_POINTS_Y - 1);
|
|
|
|
|
SERIAL_ECHO_SP(spaces + 3);
|
|
|
|
|
serial_echo_xy(GRID_MAX_POINTS_X - 1, GRID_MAX_POINTS_Y - 1);
|
|
|
|
|
SERIAL_EOL();
|
|
|
|
|
serial_echo_xy(MESH_MIN_X, MESH_MAX_Y);
|
|
|
|
|
SERIAL_ECHO_SP(spaces);
|
|
|
|
|
serial_echo_xy(MESH_MAX_X, MESH_MAX_Y);
|
|
|
|
|
const bool human = !(map_type & 0x3), csv = map_type == 1, lcd = map_type == 2, comp = map_type & 0x4;
|
|
|
|
|
|
|
|
|
|
SERIAL_ECHOPGM("\nBed Topography Report");
|
|
|
|
|
if (human) {
|
|
|
|
|
SERIAL_ECHOPGM(":\n\n");
|
|
|
|
|
serial_echo_xy(4, MESH_MIN_X, MESH_MAX_Y);
|
|
|
|
|
serial_echo_xy(twixt, MESH_MAX_X, MESH_MAX_Y);
|
|
|
|
|
SERIAL_EOL();
|
|
|
|
|
serial_echo_column_labels(eachsp - 2);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
SERIAL_PROTOCOLPGM(" for ");
|
|
|
|
|
serialprintPGM(map_type == 1 ? PSTR("CSV:\n\n") : PSTR("LCD:\n\n"));
|
|
|
|
|
SERIAL_ECHOPGM(" for ");
|
|
|
|
|
serialprintPGM(csv ? PSTR("CSV:\n") : PSTR("LCD:\n"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const float current_xi = get_cell_index_x(current_position[X_AXIS] + (MESH_X_DIST) / 2.0),
|
|
|
|
|
current_yi = get_cell_index_y(current_position[Y_AXIS] + (MESH_Y_DIST) / 2.0);
|
|
|
|
|
|
|
|
|
|
if (!lcd) SERIAL_EOL();
|
|
|
|
|
for (int8_t j = GRID_MAX_POINTS_Y - 1; j >= 0; j--) {
|
|
|
|
|
|
|
|
|
|
// Row Label (J index)
|
|
|
|
|
if (human) {
|
|
|
|
|
if (j < 10) SERIAL_CHAR(' ');
|
|
|
|
|
SERIAL_ECHO(j);
|
|
|
|
|
SERIAL_ECHOPGM(" |");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Row Values (I indexes)
|
|
|
|
|
for (uint8_t i = 0; i < GRID_MAX_POINTS_X; i++) {
|
|
|
|
|
|
|
|
|
|
// Opening Brace or Space
|
|
|
|
|
const bool is_current = i == current_xi && j == current_yi;
|
|
|
|
|
if (human) SERIAL_CHAR(is_current ? '[' : ' ');
|
|
|
|
|
|
|
|
|
|
// is the nozzle here? then mark the number
|
|
|
|
|
if (map_type == 0) SERIAL_CHAR(is_current ? '[' : ' ');
|
|
|
|
|
|
|
|
|
|
// Z Value at current I, J
|
|
|
|
|
const float f = z_values[i][j];
|
|
|
|
|
if (isnan(f)) {
|
|
|
|
|
serialprintPGM(map_type == 0 ? PSTR(" . ") : PSTR("NAN"));
|
|
|
|
|
if (lcd) {
|
|
|
|
|
// TODO: Display on Graphical LCD
|
|
|
|
|
}
|
|
|
|
|
else if (map_type <= 1) {
|
|
|
|
|
// if we don't do this, the columns won't line up nicely
|
|
|
|
|
if (map_type == 0 && f >= 0.0) SERIAL_CHAR(' ');
|
|
|
|
|
SERIAL_PROTOCOL_F(f, 3);
|
|
|
|
|
else if (isnan(f))
|
|
|
|
|
serialprintPGM(human ? PSTR(" . ") : PSTR("NAN"));
|
|
|
|
|
else if (human || csv) {
|
|
|
|
|
if (human && f >= 0.0) SERIAL_CHAR(f > 0 ? '+' : ' '); // Space for positive ('-' for negative)
|
|
|
|
|
SERIAL_ECHO_F(f, 3); // Positive: 5 digits, Negative: 6 digits
|
|
|
|
|
}
|
|
|
|
|
idle();
|
|
|
|
|
if (map_type == 1 && i < GRID_MAX_POINTS_X - 1) SERIAL_CHAR(',');
|
|
|
|
|
if (csv && i < GRID_MAX_POINTS_X - 1) SERIAL_CHAR('\t');
|
|
|
|
|
|
|
|
|
|
// Closing Brace or Space
|
|
|
|
|
if (human) SERIAL_CHAR(is_current ? ']' : ' ');
|
|
|
|
|
|
|
|
|
|
SERIAL_FLUSHTX();
|
|
|
|
|
safe_delay(15);
|
|
|
|
|
if (map_type == 0) {
|
|
|
|
|
SERIAL_CHAR(is_current ? ']' : ' ');
|
|
|
|
|
SERIAL_CHAR(' ');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
SERIAL_EOL();
|
|
|
|
|
if (j && map_type == 0) { // we want the (0,0) up tight against the block of numbers
|
|
|
|
|
SERIAL_CHAR(' ');
|
|
|
|
|
SERIAL_EOL();
|
|
|
|
|
idle();
|
|
|
|
|
}
|
|
|
|
|
if (!lcd) SERIAL_EOL();
|
|
|
|
|
|
|
|
|
|
// A blank line between rows (unless compact)
|
|
|
|
|
if (j && human && !comp) SERIAL_ECHOLNPGM(" |");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (map_type == 0) {
|
|
|
|
|
serial_echo_xy(MESH_MIN_X, MESH_MIN_Y);
|
|
|
|
|
SERIAL_ECHO_SP(spaces + 4);
|
|
|
|
|
serial_echo_xy(MESH_MAX_X, MESH_MIN_Y);
|
|
|
|
|
if (human) {
|
|
|
|
|
serial_echo_column_labels(eachsp - 2);
|
|
|
|
|
SERIAL_EOL();
|
|
|
|
|
serial_echo_xy(4, MESH_MIN_X, MESH_MIN_Y);
|
|
|
|
|
serial_echo_xy(twixt, MESH_MAX_X, MESH_MIN_Y);
|
|
|
|
|
SERIAL_EOL();
|
|
|
|
|
serial_echo_xy(0, 0);
|
|
|
|
|
SERIAL_ECHO_SP(spaces + 5);
|
|
|
|
|
serial_echo_xy(GRID_MAX_POINTS_X - 1, 0);
|
|
|
|
|
SERIAL_EOL();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|