diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp
index d58b2dc37e479ac3c1861b575a53efd8637b27be..7803a72c4ab7ccaa3e3d1e0ca5b746fe1e90986d 100644
--- a/Marlin/ultralcd.cpp
+++ b/Marlin/ultralcd.cpp
@@ -2192,51 +2192,51 @@ void kill_screen(const char* lcd_msg) {
if (!(axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] && axis_known_position[Z_AXIS]))
return lcd_goto_screen(_lcd_ubl_map_homing);
- if (lcd_clicked) return _lcd_ubl_map_lcd_edit_cmd();
- ENCODER_DIRECTION_NORMAL();
+ if (lcd_clicked) return _lcd_ubl_map_lcd_edit_cmd();
+ ENCODER_DIRECTION_NORMAL();
- if (encoderPosition) {
- step_scaler += (int32_t)encoderPosition;
- x_plot += step_scaler / (ENCODER_STEPS_PER_MENU_ITEM);
- if (abs(step_scaler) >= ENCODER_STEPS_PER_MENU_ITEM)
- step_scaler = 0;
- refresh_cmd_timeout();
+ if (encoderPosition) {
+ step_scaler += (int32_t)encoderPosition;
+ x_plot += step_scaler / (ENCODER_STEPS_PER_MENU_ITEM);
+ if (abs(step_scaler) >= ENCODER_STEPS_PER_MENU_ITEM)
+ step_scaler = 0;
+ refresh_cmd_timeout();
- encoderPosition = 0;
- lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
- }
+ encoderPosition = 0;
+ lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
+ }
- // Encoder to the right (++)
- if (x_plot >= GRID_MAX_POINTS_X) { x_plot = 0; y_plot++; }
- if (y_plot >= GRID_MAX_POINTS_Y) y_plot = 0;
+ // Encoder to the right (++)
+ if (x_plot >= GRID_MAX_POINTS_X) { x_plot = 0; y_plot++; }
+ if (y_plot >= GRID_MAX_POINTS_Y) y_plot = 0;
- // Encoder to the left (--)
- if (x_plot <= GRID_MAX_POINTS_X - (GRID_MAX_POINTS_X + 1)) { x_plot = GRID_MAX_POINTS_X - 1; y_plot--; }
- if (y_plot <= GRID_MAX_POINTS_Y - (GRID_MAX_POINTS_Y + 1)) y_plot = GRID_MAX_POINTS_Y - 1;
+ // Encoder to the left (--)
+ if (x_plot <= GRID_MAX_POINTS_X - (GRID_MAX_POINTS_X + 1)) { x_plot = GRID_MAX_POINTS_X - 1; y_plot--; }
+ if (y_plot <= GRID_MAX_POINTS_Y - (GRID_MAX_POINTS_Y + 1)) y_plot = GRID_MAX_POINTS_Y - 1;
- // Prevent underrun/overrun of plot numbers
- x_plot = constrain(x_plot, GRID_MAX_POINTS_X - (GRID_MAX_POINTS_X + 1), GRID_MAX_POINTS_X + 1);
- y_plot = constrain(y_plot, GRID_MAX_POINTS_Y - (GRID_MAX_POINTS_Y + 1), GRID_MAX_POINTS_Y + 1);
+ // Prevent underrun/overrun of plot numbers
+ x_plot = constrain(x_plot, GRID_MAX_POINTS_X - (GRID_MAX_POINTS_X + 1), GRID_MAX_POINTS_X + 1);
+ y_plot = constrain(y_plot, GRID_MAX_POINTS_Y - (GRID_MAX_POINTS_Y + 1), GRID_MAX_POINTS_Y + 1);
- // Determine number of points to edit
- #if IS_KINEMATIC
- n_edit_pts = 9; //TODO: Delta accessible edit points
- #else
- const bool xc = WITHIN(x_plot, 1, GRID_MAX_POINTS_X - 2),
- yc = WITHIN(y_plot, 1, GRID_MAX_POINTS_Y - 2);
- n_edit_pts = yc ? (xc ? 9 : 6) : (xc ? 6 : 4); // Corners
- #endif
+ // Determine number of points to edit
+ #if IS_KINEMATIC
+ n_edit_pts = 9; //TODO: Delta accessible edit points
+ #else
+ const bool xc = WITHIN(x_plot, 1, GRID_MAX_POINTS_X - 2),
+ yc = WITHIN(y_plot, 1, GRID_MAX_POINTS_Y - 2);
+ n_edit_pts = yc ? (xc ? 9 : 6) : (xc ? 6 : 4); // Corners
+ #endif
- if (lcdDrawUpdate) {
- lcd_implementation_ubl_plot(x_plot, y_plot);
+ if (lcdDrawUpdate) {
+ lcd_implementation_ubl_plot(x_plot, y_plot);
- ubl_map_move_to_xy(); // Move to current location
+ ubl_map_move_to_xy(); // Move to current location
- if (planner.movesplanned() > 1) { // if the nozzle is moving, cancel the move. There is a new location
- quickstop_stepper();
- ubl_map_move_to_xy(); // Move to new location
- }
+ if (planner.movesplanned() > 1) { // if the nozzle is moving, cancel the move. There is a new location
+ quickstop_stepper();
+ ubl_map_move_to_xy(); // Move to new location
}
+ }
}
/**
diff --git a/Marlin/ultralcd_impl_HD44780.h b/Marlin/ultralcd_impl_HD44780.h
index 24280f7889c2fd7f7aa05f34e59b2014f1b53063..40187f79a80294cee8318407ac9873c3450c0d3c 100644
--- a/Marlin/ultralcd_impl_HD44780.h
+++ b/Marlin/ultralcd_impl_HD44780.h
@@ -1085,151 +1085,151 @@ static void lcd_implementation_status_screen() {
#if ENABLED(AUTO_BED_LEVELING_UBL)
- /*
- * These are just basic data for the 20x4 LCD work that
- * is coming up very soon.
- * Soon this will morph into a map code.
- */
+ /*
+ * These are just basic data for the 20x4 LCD work that
+ * is coming up very soon.
+ * Soon this will morph into a map code.
+ */
+
+ /**
+ Possible map screens:
+
+ 16x2 |X000.00 Y000.00|
+ |(00,00) Z00.000|
+
+ 20x2 | X:000.00 Y:000.00 |
+ | (00,00) Z:00.000 |
+
+ 16x4 |+-------+(00,00)|
+ || |X000.00|
+ || |Y000.00|
+ |+-------+Z00.000|
+
+ 20x4 | +-------+ (00,00) |
+ | | | X:000.00|
+ | | | Y:000.00|
+ | +-------+ Z:00.000|
+ */
+
+ void lcd_set_ubl_map_plot_chars() {
+ #if LCD_HEIGHT > 3
+ //#include "_ubl_lcd_map_characters.h"
+ const static byte _lcd_box_top[8] PROGMEM = {
+ B11111,
+ B00000,
+ B00000,
+ B00000,
+ B00000,
+ B00000,
+ B00000,
+ B00000
+ };
+ const static byte _lcd_box_bottom[8] PROGMEM = {
+ B00000,
+ B00000,
+ B00000,
+ B00000,
+ B00000,
+ B00000,
+ B00000,
+ B11111
+ };
+ createChar_P(LCD_UBL_BOXTOP_CHAR, _lcd_box_top);
+ createChar_P(LCD_UBL_BOXBOT_CHAR, _lcd_box_bottom);
+ #endif
+ }
- /**
- Possible map screens:
-
- 16x2 |X000.00 Y000.00|
- |(00,00) Z00.000|
-
- 20x2 | X:000.00 Y:000.00 |
- | (00,00) Z:00.000 |
-
- 16x4 |+-------+(00,00)|
- || |X000.00|
- || |Y000.00|
- |+-------+Z00.000|
-
- 20x4 | +-------+ (00,00) |
- | | | X:000.00|
- | | | Y:000.00|
- | +-------+ Z:00.000|
- */
-
- void lcd_set_ubl_map_plot_chars() {
- #if LCD_HEIGHT > 3
- //#include "_ubl_lcd_map_characters.h"
- const static byte _lcd_box_top[8] PROGMEM = {
- B11111,
- B00000,
- B00000,
- B00000,
- B00000,
- B00000,
- B00000,
- B00000
- };
- const static byte _lcd_box_bottom[8] PROGMEM = {
- B00000,
- B00000,
- B00000,
- B00000,
- B00000,
- B00000,
- B00000,
- B11111
- };
- createChar_P(LCD_UBL_BOXTOP_CHAR, _lcd_box_top);
- createChar_P(LCD_UBL_BOXBOT_CHAR, _lcd_box_bottom);
- #endif
- }
+ void lcd_implementation_ubl_plot(const uint8_t x_plot, const uint8_t y_plot) {
- void lcd_implementation_ubl_plot(const uint8_t x_plot, const uint8_t y_plot) {
+ #if LCD_WIDTH >= 20
+ #define _LCD_W_POS 12
+ #define _PLOT_X 1
+ #define _MAP_X 3
+ #define _LABEL(C,X,Y) lcd.setCursor(X, Y); lcd.print(C)
+ #define _XLABEL(X,Y) _LABEL("X:",X,Y)
+ #define _YLABEL(X,Y) _LABEL("Y:",X,Y)
+ #define _ZLABEL(X,Y) _LABEL("Z:",X,Y)
+ #else
+ #define _LCD_W_POS 8
+ #define _PLOT_X 0
+ #define _MAP_X 1
+ #define _LABEL(X,Y,C) lcd.setCursor(X, Y); lcd.write(C)
+ #define _XLABEL(X,Y) _LABEL('X',X,Y)
+ #define _YLABEL(X,Y) _LABEL('Y',X,Y)
+ #define _ZLABEL(X,Y) _LABEL('Z',X,Y)
+ #endif
- #if LCD_WIDTH >= 20
- #define _LCD_W_POS 12
- #define _PLOT_X 1
- #define _MAP_X 3
- #define _LABEL(C,X,Y) lcd.setCursor(X, Y); lcd.print(C)
- #define _XLABEL(X,Y) _LABEL("X:",X,Y)
- #define _YLABEL(X,Y) _LABEL("Y:",X,Y)
- #define _ZLABEL(X,Y) _LABEL("Z:",X,Y)
- #else
- #define _LCD_W_POS 8
- #define _PLOT_X 0
- #define _MAP_X 1
- #define _LABEL(X,Y,C) lcd.setCursor(X, Y); lcd.write(C)
- #define _XLABEL(X,Y) _LABEL('X',X,Y)
- #define _YLABEL(X,Y) _LABEL('Y',X,Y)
- #define _ZLABEL(X,Y) _LABEL('Z',X,Y)
- #endif
+ #if LCD_HEIGHT <= 3 // 16x2 or 20x2 display
- #if LCD_HEIGHT <= 3 // 16x2 or 20x2 display
+ /**
+ * Show X and Y positions
+ */
+ _XLABEL(_PLOT_X, 0);
+ lcd.print(ftostr32(LOGICAL_X_POSITION(pgm_read_float(&ubl._mesh_index_to_xpos[x_plot]))));
- /**
- * Show X and Y positions
- */
- _XLABEL(_PLOT_X, 0);
- lcd.print(ftostr32(LOGICAL_X_POSITION(pgm_read_float(&ubl._mesh_index_to_xpos[x_plot]))));
+ _YLABEL(_LCD_W_POS, 0);
+ lcd.print(ftostr32(LOGICAL_Y_POSITION(pgm_read_float(&ubl._mesh_index_to_ypos[y_plot]))));
- _YLABEL(_LCD_W_POS, 0);
- lcd.print(ftostr32(LOGICAL_Y_POSITION(pgm_read_float(&ubl._mesh_index_to_ypos[y_plot]))));
+ lcd.setCursor(_PLOT_X, 0);
- lcd.setCursor(_PLOT_X, 0);
+ #else // 16x4 or 20x4 display
- #else // 16x4 or 20x4 display
+ /**
+ * Draw the Mesh Map Box
+ */
+ uint8_t m;
+ lcd.setCursor(_MAP_X, 0); for (m = 0; m < 5; m++) lcd.write(LCD_UBL_BOXTOP_CHAR); // Top
+ lcd.setCursor(_MAP_X, 3); for (m = 0; m < 5; m++) lcd.write(LCD_UBL_BOXBOT_CHAR); // Bottom
+ for (m = 0; m <= 3; m++) {
+ lcd.setCursor(2, m); lcd.write('|'); // Left
+ lcd.setCursor(8, m); lcd.write('|'); // Right
+ }
- /**
- * Draw the Mesh Map Box
- */
- uint8_t m;
- lcd.setCursor(_MAP_X, 0); for (m = 0; m < 5; m++) lcd.write(LCD_UBL_BOXTOP_CHAR); // Top
- lcd.setCursor(_MAP_X, 3); for (m = 0; m < 5; m++) lcd.write(LCD_UBL_BOXBOT_CHAR); // Bottom
- for (m = 0; m <= 3; m++) {
- lcd.setCursor(2, m); lcd.write('|'); // Left
- lcd.setCursor(8, m); lcd.write('|'); // Right
- }
+ lcd.setCursor(_LCD_W_POS, 0);
- lcd.setCursor(_LCD_W_POS, 0);
+ #endif
- #endif
+ /**
+ * Print plot position
+ */
+ lcd.write('(');
+ lcd.print(x_plot);
+ lcd.write(',');
+ lcd.print(y_plot);
+ lcd.write(')');
+
+ #if LCD_HEIGHT <= 3 // 16x2 or 20x2 display
/**
- * Print plot position
+ * Print Z values
*/
- lcd.write('(');
- lcd.print(x_plot);
- lcd.write(',');
- lcd.print(y_plot);
- lcd.write(')');
-
- #if LCD_HEIGHT <= 3 // 16x2 or 20x2 display
-
- /**
- * Print Z values
- */
- _ZLABEL(_LCD_W_POS, 1);
- if (!isnan(ubl.z_values[x_plot][y_plot]))
- lcd.print(ftostr43sign(ubl.z_values[x_plot][y_plot]));
- else
- lcd_printPGM(PSTR(" -----"));
-
- #else // 16x4 or 20x4 display
-
- /**
- * Show all values at right of screen
- */
- _XLABEL(_LCD_W_POS, 1);
- lcd.print(ftostr32(LOGICAL_X_POSITION(pgm_read_float(&ubl._mesh_index_to_xpos[x_plot]))));
- _YLABEL(_LCD_W_POS, 2);
- lcd.print(ftostr32(LOGICAL_Y_POSITION(pgm_read_float(&ubl._mesh_index_to_ypos[y_plot]))));
-
- /**
- * Show the location value
- */
- _ZLABEL(_LCD_W_POS, 3);
- if (!isnan(ubl.z_values[x_plot][y_plot]))
- lcd.print(ftostr43sign(ubl.z_values[x_plot][y_plot]));
- else
- lcd_printPGM(PSTR(" -----"));
+ _ZLABEL(_LCD_W_POS, 1);
+ if (!isnan(ubl.z_values[x_plot][y_plot]))
+ lcd.print(ftostr43sign(ubl.z_values[x_plot][y_plot]));
+ else
+ lcd_printPGM(PSTR(" -----"));
- #endif // LCD_HEIGHT > 3
- }
+ #else // 16x4 or 20x4 display
+
+ /**
+ * Show all values at right of screen
+ */
+ _XLABEL(_LCD_W_POS, 1);
+ lcd.print(ftostr32(LOGICAL_X_POSITION(pgm_read_float(&ubl._mesh_index_to_xpos[x_plot]))));
+ _YLABEL(_LCD_W_POS, 2);
+ lcd.print(ftostr32(LOGICAL_Y_POSITION(pgm_read_float(&ubl._mesh_index_to_ypos[y_plot]))));
+
+ /**
+ * Show the location value
+ */
+ _ZLABEL(_LCD_W_POS, 3);
+ if (!isnan(ubl.z_values[x_plot][y_plot]))
+ lcd.print(ftostr43sign(ubl.z_values[x_plot][y_plot]));
+ else
+ lcd_printPGM(PSTR(" -----"));
+
+ #endif // LCD_HEIGHT > 3
+ }
#endif // AUTO_BED_LEVELING_UBL