Merge pull request #7204 from thinkyhead/bf_update_ubl_lcd

UBL radar map corrections
2.0.x
Scott Lahteine 7 years ago committed by GitHub
commit 3e78a01262

@ -273,6 +273,12 @@
#define LCD_FEEDRATE_CHAR 0x06 #define LCD_FEEDRATE_CHAR 0x06
#define LCD_CLOCK_CHAR 0x07 #define LCD_CLOCK_CHAR 0x07
#define LCD_STR_ARROW_RIGHT ">" /* from the default character set */ #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 #endif
/** /**

@ -333,7 +333,6 @@
#if ENABLED(AUTO_BED_LEVELING_UBL) #if ENABLED(AUTO_BED_LEVELING_UBL)
#include "ubl.h" #include "ubl.h"
extern bool defer_return_to_status; extern bool defer_return_to_status;
extern bool ubl_lcd_map_control;
unified_bed_leveling ubl; unified_bed_leveling ubl;
#define UBL_MESH_VALID !( ( ubl.z_values[0][0] == ubl.z_values[0][1] && ubl.z_values[0][1] == ubl.z_values[0][2] \ #define UBL_MESH_VALID !( ( ubl.z_values[0][0] == ubl.z_values[0][1] && ubl.z_values[0][1] == ubl.z_values[0][2] \
&& ubl.z_values[1][0] == ubl.z_values[1][1] && ubl.z_values[1][1] == ubl.z_values[1][2] \ && ubl.z_values[1][0] == ubl.z_values[1][1] && ubl.z_values[1][1] == ubl.z_values[1][2] \
@ -7742,11 +7741,9 @@ inline void gcode_M18_M84() {
#endif #endif
} }
#if ENABLED(AUTO_BED_LEVELING_UBL) && ENABLED(ULTRA_LCD) //only needed if have an LCD #if ENABLED(AUTO_BED_LEVELING_UBL) && ENABLED(ULTRA_LCD) // Only needed with an LCD
ubl_lcd_map_control = false; ubl_lcd_map_control = defer_return_to_status = false;
defer_return_to_status = false;
#endif #endif
} }
} }
@ -12637,9 +12634,8 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) {
#if ENABLED(DISABLE_INACTIVE_E) #if ENABLED(DISABLE_INACTIVE_E)
disable_e_steppers(); disable_e_steppers();
#endif #endif
#if ENABLED(AUTO_BED_LEVELING_UBL) && ENABLED(ULTRA_LCD) //only needed if have an LCD #if ENABLED(AUTO_BED_LEVELING_UBL) && ENABLED(ULTRA_LCD) // Only needed with an LCD
ubl_lcd_map_control = false; ubl_lcd_map_control = defer_return_to_status = false;
defer_return_to_status = false;
#endif #endif
} }

@ -45,9 +45,7 @@
void lcd_mesh_edit_setup(float initial); void lcd_mesh_edit_setup(float initial);
float lcd_mesh_edit(); float lcd_mesh_edit();
void lcd_z_offset_edit_setup(float); void lcd_z_offset_edit_setup(float);
#if ENABLED(DOGLCD)
extern void _lcd_ubl_output_map_lcd(); extern void _lcd_ubl_output_map_lcd();
#endif
float lcd_z_offset_edit(); float lcd_z_offset_edit();
#endif #endif
@ -56,7 +54,6 @@
extern float probe_pt(const float &x, const float &y, bool, int); extern float probe_pt(const float &x, const float &y, bool, int);
extern bool set_probe_deployed(bool); extern bool set_probe_deployed(bool);
extern void set_bed_leveling_enabled(bool); extern void set_bed_leveling_enabled(bool);
extern bool ubl_lcd_map_control;
typedef void (*screenFunc_t)(); typedef void (*screenFunc_t)();
extern void lcd_goto_screen(screenFunc_t screen, const uint32_t encoder = 0); extern void lcd_goto_screen(screenFunc_t screen, const uint32_t encoder = 0);
@ -1522,7 +1519,7 @@
idle(); idle();
} while (!ubl_lcd_clicked()); } while (!ubl_lcd_clicked());
lcd_return_to_status(); if (!ubl_lcd_map_control) lcd_return_to_status();
// The technique used here generates a race condition for the encoder click. // The technique used here generates a race condition for the encoder click.
// It could get detected in lcd_mesh_edit (actually _lcd_mesh_fine_tune) or here. // It could get detected in lcd_mesh_edit (actually _lcd_mesh_fine_tune) or here.
@ -1569,12 +1566,10 @@
LCD_MESSAGEPGM(MSG_UBL_DONE_EDITING_MESH); LCD_MESSAGEPGM(MSG_UBL_DONE_EDITING_MESH);
SERIAL_ECHOLNPGM("Done Editing Mesh"); SERIAL_ECHOLNPGM("Done Editing Mesh");
if (ubl_lcd_map_control) { if (ubl_lcd_map_control)
#if ENABLED(DOGLCD)
lcd_goto_screen(_lcd_ubl_output_map_lcd); lcd_goto_screen(_lcd_ubl_output_map_lcd);
#endif else
} lcd_return_to_status();
else lcd_return_to_status();
} }
#endif // NEWPANEL #endif // NEWPANEL

@ -470,8 +470,14 @@ uint16_t max_display_update_time = 0;
screen_history_depth = 0; screen_history_depth = 0;
} }
lcd_implementation_clear(); lcd_implementation_clear();
// Re-initialize custom characters that may be re-used
#if DISABLED(DOGLCD) && ENABLED(AUTO_BED_LEVELING_UBL)
if (!ubl_lcd_map_control) lcd_set_custom_characters(
#if ENABLED(LCD_PROGRESS_BAR) #if ENABLED(LCD_PROGRESS_BAR)
// For LCD_PROGRESS_BAR re-initialize custom characters screen == lcd_status_screen
#endif
);
#elif ENABLED(LCD_PROGRESS_BAR)
lcd_set_custom_characters(screen == lcd_status_screen); lcd_set_custom_characters(screen == lcd_status_screen);
#endif #endif
lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT; lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
@ -2142,6 +2148,7 @@ void kill_screen(const char* lcd_msg) {
void _lcd_ubl_output_map_lcd(); void _lcd_ubl_output_map_lcd();
void _lcd_ubl_map_homing() { void _lcd_ubl_map_homing() {
defer_return_to_status = true;
if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_HOMING), NULL); if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_HOMING), NULL);
lcdDrawUpdate = LCDVIEW_CALL_NO_REDRAW; lcdDrawUpdate = LCDVIEW_CALL_NO_REDRAW;
if (axis_homed[X_AXIS] && axis_homed[Y_AXIS] && axis_homed[Z_AXIS]) { if (axis_homed[X_AXIS] && axis_homed[Y_AXIS] && axis_homed[Z_AXIS]) {
@ -2158,8 +2165,6 @@ void kill_screen(const char* lcd_msg) {
void _lcd_ubl_map_lcd_edit_cmd() { void _lcd_ubl_map_lcd_edit_cmd() {
char ubl_lcd_gcode [50], str[10], str2[10]; char ubl_lcd_gcode [50], str[10], str2[10];
ubl_lcd_map_control = true; // Used for returning to the map screen
dtostrf(pgm_read_float(&ubl._mesh_index_to_xpos[x_plot]), 0, 2, str); dtostrf(pgm_read_float(&ubl._mesh_index_to_xpos[x_plot]), 0, 2, str);
dtostrf(pgm_read_float(&ubl._mesh_index_to_ypos[y_plot]), 0, 2, str2); dtostrf(pgm_read_float(&ubl._mesh_index_to_ypos[y_plot]), 0, 2, str2);
snprintf_P(ubl_lcd_gcode, sizeof(ubl_lcd_gcode), PSTR("G29 P4 X%s Y%s R%i"), str, str2, n_edit_pts); snprintf_P(ubl_lcd_gcode, sizeof(ubl_lcd_gcode), PSTR("G29 P4 X%s Y%s R%i"), str, str2, n_edit_pts);
@ -2183,28 +2188,24 @@ void kill_screen(const char* lcd_msg) {
void _lcd_ubl_output_map_lcd() { void _lcd_ubl_output_map_lcd() {
static int16_t step_scaler = 0; 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]) { 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(); } if (lcd_clicked) return _lcd_ubl_map_lcd_edit_cmd();
ENCODER_DIRECTION_NORMAL(); ENCODER_DIRECTION_NORMAL();
if (encoderPosition) { if (encoderPosition) {
signed_enc_pos = (int32_t)encoderPosition; step_scaler += (int32_t)encoderPosition;
step_scaler += signed_enc_pos;
x_plot += step_scaler / (ENCODER_STEPS_PER_MENU_ITEM); x_plot += step_scaler / (ENCODER_STEPS_PER_MENU_ITEM);
if (abs(step_scaler) >= ENCODER_STEPS_PER_MENU_ITEM) if (abs(step_scaler) >= ENCODER_STEPS_PER_MENU_ITEM)
step_scaler = 0; step_scaler = 0;
refresh_cmd_timeout(); refresh_cmd_timeout();
encoderPosition = 0;
lcdDrawUpdate = LCDVIEW_REDRAW_NOW; lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
} }
encoderPosition = 0;
// Encoder to the right (++) // Encoder to the right (++)
if (x_plot >= GRID_MAX_POINTS_X) { x_plot = 0; y_plot++; } if (x_plot >= GRID_MAX_POINTS_X) { x_plot = 0; y_plot++; }
if (y_plot >= GRID_MAX_POINTS_Y) y_plot = 0; if (y_plot >= GRID_MAX_POINTS_Y) y_plot = 0;
@ -2232,27 +2233,17 @@ void kill_screen(const char* lcd_msg) {
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 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) quickstop_stepper();
#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();
ubl_map_move_to_xy(); // Move to new location ubl_map_move_to_xy(); // Move to new location
} }
} }
safe_delay(10);
}
else lcd_goto_screen(_lcd_ubl_map_homing);
} }
/** /**
* UBL Homing before LCD map * UBL Homing before LCD map
*/ */
void _lcd_ubl_output_map_lcd_cmd() { void _lcd_ubl_output_map_lcd_cmd() {
ubl_lcd_map_control = true; // Return to the map screen (and don't restore the character set)
if (!(axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] && axis_known_position[Z_AXIS])) if (!(axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] && axis_known_position[Z_AXIS]))
enqueue_and_echo_commands_P(PSTR("G28")); enqueue_and_echo_commands_P(PSTR("G28"));
lcd_goto_screen(_lcd_ubl_map_homing); lcd_goto_screen(_lcd_ubl_map_homing);
@ -2393,6 +2384,8 @@ void kill_screen(const char* lcd_msg) {
if (!g29_in_progress) if (!g29_in_progress)
#endif #endif
MENU_ITEM(submenu, MSG_BED_LEVELING, lcd_bed_leveling); MENU_ITEM(submenu, MSG_BED_LEVELING, lcd_bed_leveling);
#elif PLANNER_LEVELING
MENU_ITEM(gcode, MSG_BED_LEVELING, PSTR("G28\nG29"));
#endif #endif
#if HAS_M206_COMMAND #if HAS_M206_COMMAND

@ -188,6 +188,7 @@
void lcd_reset_status(); void lcd_reset_status();
#if ENABLED(AUTO_BED_LEVELING_UBL) #if ENABLED(AUTO_BED_LEVELING_UBL)
extern bool ubl_lcd_map_control;
void lcd_mesh_edit_setup(float initial); void lcd_mesh_edit_setup(float initial);
float lcd_mesh_edit(); float lcd_mesh_edit();
void lcd_z_offset_edit_setup(float); void lcd_z_offset_edit_setup(float);

@ -1134,8 +1134,8 @@ static void lcd_implementation_status_screen() {
B00000, B00000,
B11111 B11111
}; };
createChar_P(1, _lcd_box_top); createChar_P(LCD_UBL_BOXTOP_CHAR, _lcd_box_top);
createChar_P(2, _lcd_box_bottom); createChar_P(LCD_UBL_BOXBOT_CHAR, _lcd_box_bottom);
#endif #endif
} }
@ -1178,8 +1178,8 @@ static void lcd_implementation_status_screen() {
* Draw the Mesh Map Box * Draw the Mesh Map Box
*/ */
uint8_t m; uint8_t m;
lcd.setCursor(_MAP_X, 0); for (m = 0; m < 5; m++) lcd.write(1); // Top 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(2); // Bottom lcd.setCursor(_MAP_X, 3); for (m = 0; m < 5; m++) lcd.write(LCD_UBL_BOXBOT_CHAR); // Bottom
for (m = 0; m <= 3; m++) { for (m = 0; m <= 3; m++) {
lcd.setCursor(2, m); lcd.write('|'); // Left lcd.setCursor(2, m); lcd.write('|'); // Left
lcd.setCursor(8, m); lcd.write('|'); // Right lcd.setCursor(8, m); lcd.write('|'); // Right

Loading…
Cancel
Save