Improve UBL mesh report. Add M420 T, M421 N

This commit is contained in:
Scott Lahteine 2018-04-15 21:02:09 -05:00
parent 6786101c64
commit c0f6eebded
3 changed files with 87 additions and 66 deletions

View File

@ -9912,6 +9912,7 @@ void quickstop_stepper() {
* With AUTO_BED_LEVELING_UBL only: * With AUTO_BED_LEVELING_UBL only:
* *
* L[index] Load UBL mesh from index (0 is default) * L[index] Load UBL mesh from index (0 is default)
* T[map] 0:Human-readable 1:CSV 2:"LCD" 4:Compact
*/ */
inline void gcode_M420() { inline void gcode_M420() {
@ -9950,7 +9951,7 @@ void quickstop_stepper() {
// L to load a mesh from the EEPROM // L to load a mesh from the EEPROM
if (parser.seen('L') || parser.seen('V')) { if (parser.seen('L') || parser.seen('V')) {
ubl.display_map(0); // Currently only supports one map type ubl.display_map(parser.byteval('T')); // 0=
SERIAL_ECHOLNPAIR("ubl.mesh_is_valid = ", ubl.mesh_is_valid()); SERIAL_ECHOLNPAIR("ubl.mesh_is_valid = ", ubl.mesh_is_valid());
SERIAL_ECHOLNPAIR("ubl.storage_slot = ", ubl.storage_slot); SERIAL_ECHOLNPAIR("ubl.storage_slot = ", ubl.storage_slot);
} }
@ -10081,6 +10082,7 @@ void quickstop_stepper() {
* Usage: * Usage:
* M421 I<xindex> J<yindex> Z<linear> * M421 I<xindex> J<yindex> Z<linear>
* M421 I<xindex> J<yindex> Q<offset> * M421 I<xindex> J<yindex> Q<offset>
* M421 I<xindex> J<yindex> N
* M421 C Z<linear> * M421 C Z<linear>
* M421 C Q<offset> * M421 C Q<offset>
*/ */
@ -10089,6 +10091,7 @@ void quickstop_stepper() {
const bool hasI = ix >= 0, const bool hasI = ix >= 0,
hasJ = iy >= 0, hasJ = iy >= 0,
hasC = parser.seen('C'), hasC = parser.seen('C'),
hasN = parser.seen('N'),
hasZ = parser.seen('Z'), hasZ = parser.seen('Z'),
hasQ = !hasZ && parser.seen('Q'); hasQ = !hasZ && parser.seen('Q');
@ -10098,7 +10101,7 @@ void quickstop_stepper() {
iy = location.y_index; iy = location.y_index;
} }
if (int(hasC) + int(hasI && hasJ) != 1 || !(hasZ || hasQ)) { if (int(hasC) + int(hasI && hasJ) != 1 || !(hasZ || hasQ || hasN)) {
SERIAL_ERROR_START(); SERIAL_ERROR_START();
SERIAL_ERRORLNPGM(MSG_ERR_M421_PARAMETERS); SERIAL_ERRORLNPGM(MSG_ERR_M421_PARAMETERS);
} }
@ -10107,7 +10110,7 @@ void quickstop_stepper() {
SERIAL_ERRORLNPGM(MSG_ERR_MESH_XY); SERIAL_ERRORLNPGM(MSG_ERR_MESH_XY);
} }
else else
ubl.z_values[ix][iy] = parser.value_linear_units() + (hasQ ? ubl.z_values[ix][iy] : 0); ubl.z_values[ix][iy] = hasN ? NAN : parser.value_linear_units() + (hasQ ? ubl.z_values[ix][iy] : 0);
} }
#endif // AUTO_BED_LEVELING_UBL #endif // AUTO_BED_LEVELING_UBL

View File

@ -48,9 +48,7 @@
SERIAL_ECHOPAIR(" M421 I", x); SERIAL_ECHOPAIR(" M421 I", x);
SERIAL_ECHOPAIR(" J", y); SERIAL_ECHOPAIR(" J", y);
SERIAL_ECHOPGM(" Z"); SERIAL_ECHOPGM(" Z");
SERIAL_ECHO_F(z_values[x][y], 6); SERIAL_ECHO_F(z_values[x][y], 2);
SERIAL_ECHOPAIR(" ; X ", LOGICAL_X_POSITION(mesh_index_to_xpos(x)));
SERIAL_ECHOPAIR(", Y ", LOGICAL_Y_POSITION(mesh_index_to_ypos(y)));
SERIAL_EOL(); SERIAL_EOL();
} }
} }
@ -63,15 +61,6 @@
safe_delay(50); 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) #if ENABLED(UBL_DEVEL_DEBUGGING)
static void debug_echo_axis(const AxisEnum axis) { static void debug_echo_axis(const AxisEnum axis) {
@ -169,81 +158,112 @@
} }
} }
// display_map() currently produces three different mesh map types static void serial_echo_xy(const uint8_t sp, const int16_t x, const int16_t y) {
// 0 : suitable for PronterFace and Repetier's serial console SERIAL_ECHO_SP(sp);
// 1 : .CSV file suitable for importation into various spread sheets SERIAL_CHAR('(');
// 2 : disply of the map data on a RepRap Graphical LCD Panel 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) { void unified_bed_leveling::display_map(const int map_type) {
#if HAS_AUTO_REPORTING || ENABLED(HOST_KEEPALIVE_FEATURE) #if HAS_AUTO_REPORTING || ENABLED(HOST_KEEPALIVE_FEATURE)
suspend_auto_report = true; suspend_auto_report = true;
#endif #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"); const bool human = !(map_type & 0x3), csv = map_type == 1, lcd = map_type == 2, comp = map_type & 0x4;
if (map_type == 0) {
SERIAL_PROTOCOLPGM(":\n\n"); SERIAL_ECHOPGM("\nBed Topography Report");
serial_echo_xy(0, GRID_MAX_POINTS_Y - 1); if (human) {
SERIAL_ECHO_SP(spaces + 3); SERIAL_ECHOPGM(":\n\n");
serial_echo_xy(GRID_MAX_POINTS_X - 1, GRID_MAX_POINTS_Y - 1); serial_echo_xy(4, MESH_MIN_X, MESH_MAX_Y);
SERIAL_EOL(); serial_echo_xy(twixt, MESH_MAX_X, MESH_MAX_Y);
serial_echo_xy(MESH_MIN_X, MESH_MAX_Y);
SERIAL_ECHO_SP(spaces);
serial_echo_xy(MESH_MAX_X, MESH_MAX_Y);
SERIAL_EOL(); SERIAL_EOL();
serial_echo_column_labels(eachsp - 2);
} }
else { else {
SERIAL_PROTOCOLPGM(" for "); SERIAL_ECHOPGM(" for ");
serialprintPGM(map_type == 1 ? PSTR("CSV:\n\n") : PSTR("LCD:\n\n")); 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), 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); 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--) { for (int8_t j = GRID_MAX_POINTS_Y - 1; j >= 0; j--) {
for (uint8_t i = 0; i < GRID_MAX_POINTS_X; i++) {
const bool is_current = i == current_xi && j == current_yi;
// is the nozzle here? then mark the number // Row Label (J index)
if (map_type == 0) SERIAL_CHAR(is_current ? '[' : ' '); if (human) {
if (j < 10) SERIAL_CHAR(' ');
const float f = z_values[i][j]; SERIAL_ECHO(j);
if (isnan(f)) { SERIAL_ECHOPGM(" |");
serialprintPGM(map_type == 0 ? PSTR(" . ") : PSTR("NAN"));
} }
else if (map_type <= 1) {
// if we don't do this, the columns won't line up nicely // Row Values (I indexes)
if (map_type == 0 && f >= 0.0) SERIAL_CHAR(' '); for (uint8_t i = 0; i < GRID_MAX_POINTS_X; i++) {
SERIAL_PROTOCOL_F(f, 3);
// Opening Brace or Space
const bool is_current = i == current_xi && j == current_yi;
if (human) SERIAL_CHAR(is_current ? '[' : ' ');
// Z Value at current I, J
const float f = z_values[i][j];
if (lcd) {
// TODO: Display on Graphical LCD
}
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(); 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 ? ']' : ' ');
#if TX_BUFFER_SIZE > 0 #if TX_BUFFER_SIZE > 0
SERIAL_FLUSHTX(); SERIAL_FLUSHTX();
#endif #endif
safe_delay(15); safe_delay(5);
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();
} }
if (!lcd) SERIAL_EOL();
// A blank line between rows (unless compact)
if (j && human && !comp) SERIAL_ECHOLNPGM(" |");
} }
if (map_type == 0) { if (human) {
serial_echo_xy(MESH_MIN_X, MESH_MIN_Y); serial_echo_column_labels(eachsp - 2);
SERIAL_ECHO_SP(spaces + 4); SERIAL_EOL();
serial_echo_xy(MESH_MAX_X, MESH_MIN_Y); serial_echo_xy(4, MESH_MIN_X, MESH_MIN_Y);
serial_echo_xy(twixt, MESH_MAX_X, MESH_MIN_Y);
SERIAL_EOL(); SERIAL_EOL();
serial_echo_xy(0, 0);
SERIAL_ECHO_SP(spaces + 5);
serial_echo_xy(GRID_MAX_POINTS_X - 1, 0);
SERIAL_EOL(); SERIAL_EOL();
} }

View File

@ -247,9 +247,7 @@
* for subsequent Load and Store operations. Valid storage slot numbers begin at 0 and * for subsequent Load and Store operations. Valid storage slot numbers begin at 0 and
* extend to a limit related to the available EEPROM storage. * extend to a limit related to the available EEPROM storage.
* *
* S -1 Store Store the current Mesh as a print out that is suitable to be feed back into the system * S -1 Store Print the current Mesh as G-code that can be used to restore the mesh anytime.
* at a later date. The GCode output can be saved and later replayed by the host software
* to reconstruct the current mesh on another machine.
* *
* T Topology Display the Mesh Map Topology. * T Topology Display the Mesh Map Topology.
* 'T' can be used alone (e.g., G29 T) or in combination with most of the other commands. * 'T' can be used alone (e.g., G29 T) or in combination with most of the other commands.