From abd6ba62b4a13f24bbdbfc2a358b43b43d3f50d4 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 1 Jul 2017 18:34:52 -0500 Subject: [PATCH] Some cleanups for ubl lcd mesh map --- Marlin/Conditionals_LCD.h | 6 ++++++ Marlin/ultralcd.cpp | 29 +++++++---------------------- Marlin/ultralcd_impl_HD44780.h | 8 ++++---- 3 files changed, 17 insertions(+), 26 deletions(-) diff --git a/Marlin/Conditionals_LCD.h b/Marlin/Conditionals_LCD.h index 791a41d28c..7aa96deae4 100644 --- a/Marlin/Conditionals_LCD.h +++ b/Marlin/Conditionals_LCD.h @@ -273,6 +273,12 @@ #define LCD_FEEDRATE_CHAR 0x06 #define LCD_CLOCK_CHAR 0x07 #define LCD_STR_ARROW_RIGHT ">" /* from the default character set */ + + #if ENABLED(AUTO_BED_LEVELING_UBL) + #define LCD_UBL_BOXTOP_CHAR 0x01 + #define LCD_UBL_BOXBOT_CHAR 0x02 + #endif + #endif /** diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index c9168db977..d58b2dc37e 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -2188,28 +2188,24 @@ void kill_screen(const char* lcd_msg) { void _lcd_ubl_output_map_lcd() { static int16_t step_scaler = 0; - int32_t signed_enc_pos; - defer_return_to_status = true; + 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 (axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] && axis_known_position[Z_AXIS]) { - - if (lcd_clicked) { return _lcd_ubl_map_lcd_edit_cmd(); } + if (lcd_clicked) return _lcd_ubl_map_lcd_edit_cmd(); ENCODER_DIRECTION_NORMAL(); if (encoderPosition) { - signed_enc_pos = (int32_t)encoderPosition; - step_scaler += signed_enc_pos; + 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; - // 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; @@ -2236,22 +2232,11 @@ void kill_screen(const char* lcd_msg) { 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 - #define ENABLE_STEPPER_DRIVER_INTERRUPT() SBI(TIMSK1, OCIE1A) - #define DISABLE_STEPPER_DRIVER_INTERRUPT() CBI(TIMSK1, OCIE1A) - DISABLE_STEPPER_DRIVER_INTERRUPT(); - while (planner.blocks_queued()) planner.discard_current_block(); - stepper.current_block = NULL; - planner.clear_block_buffer_runtime(); - ENABLE_STEPPER_DRIVER_INTERRUPT(); - set_current_from_steppers_for_axis(ALL_AXES); - sync_plan_position(); + 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 } } - safe_delay(10); - } - else lcd_goto_screen(_lcd_ubl_map_homing); } /** diff --git a/Marlin/ultralcd_impl_HD44780.h b/Marlin/ultralcd_impl_HD44780.h index 2824ed0882..24280f7889 100644 --- a/Marlin/ultralcd_impl_HD44780.h +++ b/Marlin/ultralcd_impl_HD44780.h @@ -1134,8 +1134,8 @@ static void lcd_implementation_status_screen() { B00000, B11111 }; - createChar_P(1, _lcd_box_top); - createChar_P(2, _lcd_box_bottom); + createChar_P(LCD_UBL_BOXTOP_CHAR, _lcd_box_top); + createChar_P(LCD_UBL_BOXBOT_CHAR, _lcd_box_bottom); #endif } @@ -1178,8 +1178,8 @@ static void lcd_implementation_status_screen() { * Draw the Mesh Map Box */ uint8_t m; - lcd.setCursor(_MAP_X, 0); for (m = 0; m < 5; m++) lcd.write(1); // Top - lcd.setCursor(_MAP_X, 3); for (m = 0; m < 5; m++) lcd.write(2); // Bottom + 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