Remove requirement for LCD when UBL is used. (#6971)

* Remove requirement for LCD when UBL is used.

* fix previous oversights

* further refinement - error messages for P2 & P4

* require R on G26 when not using LCD; default to all points
master
bgort 8 years ago committed by GitHub
parent 2c2b991b59
commit 82e662fc69

@ -99,7 +99,8 @@
* will be purged before continuing. If no amount is specified the command will start
* purging filament until the user provides an LCD Click and then it will continue with
* printing the Mesh. You can carefully remove the spent filament with a needle nose
* pliers while holding the LCD Click wheel in a depressed state.
* pliers while holding the LCD Click wheel in a depressed state. If you do not have
* an LCD, you must specify a value if you use P.
*
* Q # Multiplier Retraction Multiplier. Normally not needed. Retraction defaults to 1.0mm and
* un-retraction is at 1.2mm These numbers will be scaled by the specified amount
@ -108,6 +109,11 @@
* If a parameter isn't given, every point will be printed unless G26 is interrupted.
* This works the same way that the UBL G29 P4 R parameter works.
*
* NOTE: If you do not have an LCD, you -must- specify R. This is to ensure that you are
* aware that there's some risk associated with printing without the ability to abort in
* cases where mesh point Z value may be inaccurate. As above, if you do not include a
* parameter, every point will be printed.
*
* S # Nozzle Used to control the size of nozzle diameter. If not specified, a .4mm nozzle is assumed.
*
* U # Random Randomize the order that the circles are drawn on the bed. The search for the closest
@ -131,9 +137,11 @@
void set_destination_to_current();
void set_current_to_destination();
void prepare_move_to_destination();
void lcd_setstatusPGM(const char* const message, const int8_t level);
void sync_plan_position_e();
#if ENABLED(NEWPANEL)
void lcd_setstatusPGM(const char* const message, const int8_t level);
void chirp_at_user();
#endif
// Private functions
@ -173,6 +181,7 @@
feedrate_mm_s = save_feedrate; // restore global feed rate
}
#if ENABLED(NEWPANEL)
/**
* Detect ubl_lcd_clicked, debounce it, and return true for cancel
*/
@ -195,6 +204,7 @@
return true;
}
#endif
/**
* G26: Mesh Validation Pattern generation.
@ -310,7 +320,9 @@
for (tmp = start_angle; tmp < end_angle - 0.1; tmp += 30.0) {
#if ENABLED(NEWPANEL)
if (user_canceled()) goto LEAVE; // Check if the user wants to stop the Mesh Validation
#endif
int tmp_div_30 = tmp / 30.0;
if (tmp_div_30 < 0) tmp_div_30 += 360 / 30;
@ -426,7 +438,9 @@
for (uint8_t i = 0; i < GRID_MAX_POINTS_X; i++) {
for (uint8_t j = 0; j < GRID_MAX_POINTS_Y; j++) {
#if ENABLED(NEWPANEL)
if (user_canceled()) return true; // Check if the user wants to stop the Mesh Validation
#endif
if (i < GRID_MAX_POINTS_X) { // We can't connect to anything to the right than GRID_MAX_POINTS_X.
// This is already a half circle because we are at the edge of the bed.
@ -663,9 +677,14 @@
}
if (parser.seen('P')) {
if (!parser.has_value())
if (!parser.has_value()) {
#if ENABLED(NEWPANEL)
g26_prime_flag = -1;
else {
#else
SERIAL_PROTOCOLLNPGM("?Prime length must be specified when not using an LCD.");
return UBL_ERR;
#endif
} else {
g26_prime_flag++;
g26_prime_length = parser.value_linear_units();
if (!WITHIN(g26_prime_length, 0.0, 25.0)) {
@ -702,7 +721,14 @@
random_deviation = parser.has_value() ? parser.value_float() : 50.0;
}
g26_repeats = parser.seen('R') ? (parser.has_value() ? parser.value_int() : GRID_MAX_POINTS + 1) : GRID_MAX_POINTS + 1;
#if ENABLED(NEWPANEL)
g26_repeats = parser.seen('R') && parser.has_value() ? parser.value_int() : GRID_MAX_POINTS + 1;
#else
if (!parser.seen('R')) {
SERIAL_PROTOCOLLNPGM("?(R)epeat must be specified when not using an LCD.");
return UBL_ERR;
} else g26_repeats = parser.has_value() ? parser.value_int() : GRID_MAX_POINTS + 1;
#endif
if (g26_repeats < 1) {
SERIAL_PROTOCOLLNPGM("?(R)epeat value not plausible; must be at least 1.");
return UBL_ERR;
@ -723,11 +749,13 @@
return UBL_OK;
}
#if ENABLED(NEWPANEL)
bool unified_bed_leveling::exit_from_g26() {
lcd_setstatusPGM(PSTR("Leaving G26"), -1);
while (ubl_lcd_clicked()) idle();
return UBL_ERR;
}
#endif
/**
* Turn on the bed and nozzle heat and
@ -744,7 +772,11 @@
has_control_of_lcd_panel = true;
thermalManager.setTargetBed(g26_bed_temp);
while (abs(thermalManager.degBed() - g26_bed_temp) > 3) {
#if ENABLED(NEWPANEL)
if (ubl_lcd_clicked()) return exit_from_g26();
#endif
if (PENDING(millis(), next)) {
next = millis() + 5000UL;
print_heaterstates();
@ -761,7 +793,11 @@
// Start heating the nozzle and wait for it to reach temperature.
thermalManager.setTargetHotend(g26_hotend_temp, 0);
while (abs(thermalManager.degHotend(0) - g26_hotend_temp) > 3) {
#if ENABLED(NEWPANEL)
if (ubl_lcd_clicked()) return exit_from_g26();
#endif
if (PENDING(millis(), next)) {
next = millis() + 5000UL;
print_heaterstates();
@ -781,12 +817,13 @@
* Prime the nozzle if needed. Return true on error.
*/
bool unified_bed_leveling::prime_nozzle() {
#if ENABLED(NEWPANEL)
float Total_Prime = 0.0;
if (g26_prime_flag == -1) { // The user wants to control how much filament gets purged
has_control_of_lcd_panel = true;
lcd_setstatusPGM(PSTR("User-Controlled Prime"), 99);
chirp_at_user();
@ -824,6 +861,9 @@
}
else {
#else
{
#endif
#if ENABLED(ULTRA_LCD)
lcd_setstatusPGM(PSTR("Fixed Length Prime."), 99);
lcd_quick_feedback();

@ -468,8 +468,6 @@ static_assert(1 >= 0
#if ENABLED(AUTO_BED_LEVELING_UBL)
#if IS_SCARA
#error "AUTO_BED_LEVELING_UBL does not yet support SCARA printers."
#elif DISABLED(NEWPANEL)
#error "AUTO_BED_LEVELING_UBL requires an LCD controller."
#endif
#endif

@ -40,11 +40,14 @@
extern float destination[XYZE], current_position[XYZE];
#if ENABLED(NEWPANEL)
void lcd_return_to_status();
void lcd_mesh_edit_setup(float initial);
float lcd_mesh_edit();
void lcd_z_offset_edit_setup(float);
float lcd_z_offset_edit();
#endif
extern float meshedit_done;
extern long babysteps_done;
extern float probe_pt(const float &x, const float &y, bool, int);
@ -149,9 +152,10 @@
* parameter can be given to prioritize where the command should be trying to measure points.
* If the X and Y parameters are not specified the current probe position is used.
* P1 accepts a 'T' (Topology) parameter so you can observe mesh generation.
* P1 also watches for the LCD Panel Encoder Switch to be held down, and will suspend
* generation of the Mesh in that case. (Note: This check is only done between probe points,
* so you must press and hold the switch until the Phase 1 command detects it.)
* P1 also watches for the LCD Panel Encoder Switch to be held down (assuming you have one),
* and will suspend generation of the Mesh in that case. (Note: This check is only done
* between probe points, so you must press and hold the switch until the Phase 1 command
* detects it.)
*
* P2 Phase 2 Probe areas of the Mesh that can't be automatically handled. Phase 2 respects an H
* parameter to control the height between Mesh points. The default height for movement
@ -187,6 +191,8 @@
* Phase 2 allows the T (Map) parameter to be specified. This helps the user see the progression
* of the Mesh being built.
*
* NOTE: P2 is not available unless you have LCD support enabled!
*
* P3 Phase 3 Fill the unpopulated regions of the Mesh with a fixed value. There are two different paths the
* user can go down. If the user specifies the value using the C parameter, the closest invalid
* mesh points to the nozzle will be filled. The user can specify a repeat count using the R
@ -204,8 +210,9 @@
* numbers. You should use some scrutiny and caution.
*
* P4 Phase 4 Fine tune the Mesh. The Delta Mesh Compensation System assume the existence of
* an LCD Panel. It is possible to fine tune the mesh without the use of an LCD Panel.
* (More work and details on doing this later!)
* an LCD Panel. It is possible to fine tune the mesh without the use of an LCD Panel using
* G42 and M421; see the UBL documentation for further details.
*
* The System will search for the closest Mesh Point to the nozzle. It will move the
* nozzle to this location. The user can use the LCD Panel to carefully adjust the nozzle
* so it is just barely touching the bed. When the user clicks the control, the System
@ -228,6 +235,7 @@
* LOWER the Mesh Point at the location. If you did not get good adheasion, you want to
* RAISE the Mesh Point at that location.
*
* NOTE: P4 is not available unless you have LCD support enabled!
*
* P5 Phase 5 Find Mean Mesh Height and Standard Deviation. Typically, it is easier to use and
* work with the Mesh if it is Mean Adjusted. You can specify a C parameter to
@ -452,6 +460,7 @@
break;
case 2: {
#if ENABLED(NEWPANEL)
//
// Manually Probe Mesh in areas that can't be reached by the probe
//
@ -498,6 +507,10 @@
manually_probe_remaining_mesh(g29_x_pos, g29_y_pos, height, g29_card_thickness, parser.seen('T'));
SERIAL_PROTOCOLLNPGM("G29 P2 finished.");
#else
SERIAL_PROTOCOLLNPGM("?P2 is only available when an LCD is present.");
return;
#endif
} break;
case 3: {
@ -557,11 +570,13 @@
break;
}
case 4:
//
// Fine Tune (i.e., Edit) the Mesh
//
case 4: // Fine Tune (i.e., Edit) the Mesh
#if ENABLED(NEWPANEL)
fine_tune_mesh(g29_x_pos, g29_y_pos, parser.seen('T'));
#else
SERIAL_PROTOCOLLNPGM("?P4 is only available when an LCD is present.");
return;
#endif
break;
case 5: find_mean_mesh_height(); break;
@ -716,11 +731,15 @@
LEAVE:
#if ENABLED(NEWPANEL)
lcd_reset_alert_level();
LCD_MESSAGEPGM("");
lcd_quick_feedback();
has_control_of_lcd_panel = false;
#endif
return;
}
void unified_bed_leveling::find_mean_mesh_height() {
@ -782,6 +801,7 @@
uint16_t max_iterations = GRID_MAX_POINTS;
do {
#if ENABLED(NEWPANEL)
if (ubl_lcd_clicked()) {
SERIAL_PROTOCOLLNPGM("\nMesh only partially populated.\n");
lcd_quick_feedback();
@ -792,6 +812,7 @@
safe_delay(50); // Debounce the Encoder wheel
return;
}
#endif
location = find_closest_mesh_point_of_type(INVALID, lx, ly, USE_PROBE_AS_REFERENCE, NULL, close_or_far);
@ -920,6 +941,7 @@
}
}
#if ENABLED(NEWPANEL)
float unified_bed_leveling::measure_point_with_encoder() {
while (ubl_lcd_clicked()) delay(50); // wait for user to release encoder wheel
@ -985,11 +1007,13 @@
void unified_bed_leveling::manually_probe_remaining_mesh(const float &lx, const float &ly, const float &z_clearance, const float &thick, const bool do_ubl_mesh_map) {
has_control_of_lcd_panel = true;
save_ubl_active_state_and_disable(); // we don't do bed level correction because we want the raw data when we probe
do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
do_blocking_move_to_xy(lx, ly);
lcd_return_to_status();
mesh_index_pair location;
do {
location = find_closest_mesh_point_of_type(INVALID, lx, ly, USE_NOZZLE_AS_REFERENCE, NULL, false);
@ -1039,9 +1063,13 @@
if (ELAPSED(millis(), nxt)) {
SERIAL_PROTOCOLLNPGM("\nMesh only partially populated.");
do_blocking_move_to_z(Z_CLEARANCE_DEPLOY_PROBE);
#if ENABLED(NEWPANEL)
lcd_quick_feedback();
while (ubl_lcd_clicked()) idle();
has_control_of_lcd_panel = false;
#endif
KEEPALIVE_STATE(IN_HANDLER);
restore_ubl_active_state_and_leave();
return;
@ -1063,12 +1091,15 @@
do_blocking_move_to_z(Z_CLEARANCE_DEPLOY_PROBE);
do_blocking_move_to_xy(lx, ly);
}
#endif
bool unified_bed_leveling::g29_parameter_parsing() {
bool err_flag = false;
#if ENABLED(NEWPANEL)
LCD_MESSAGEPGM("Doing G29 UBL!"); // TODO: Make translatable string
lcd_quick_feedback();
#endif
g29_constant = 0.0;
g29_repetition_cnt = 0;
@ -1174,8 +1205,12 @@
ubl_state_recursion_chk++;
if (ubl_state_recursion_chk != 1) {
SERIAL_ECHOLNPGM("save_ubl_active_state_and_disabled() called multiple times in a row.");
#if ENABLED(NEWPANEL)
LCD_MESSAGEPGM("save_UBL_active() error"); // TODO: Make translatable string
lcd_quick_feedback();
#endif
return;
}
ubl_state_at_invocation = state.active;
@ -1185,8 +1220,12 @@
void unified_bed_leveling::restore_ubl_active_state_and_leave() {
if (--ubl_state_recursion_chk) {
SERIAL_ECHOLNPGM("restore_ubl_active_state_and_leave() called too many times.");
#if ENABLED(NEWPANEL)
LCD_MESSAGEPGM("restore_UBL_active() error"); // TODO: Make translatable string
lcd_quick_feedback();
#endif
return;
}
set_bed_leveling_enabled(ubl_state_at_invocation);
@ -1420,6 +1459,7 @@
return out_mesh;
}
#if ENABLED(NEWPANEL)
void unified_bed_leveling::fine_tune_mesh(const float &lx, const float &ly, const bool do_ubl_mesh_map) {
if (!parser.seen('R')) // fine_tune_mesh() is special. If no repetition count flag is specified
g29_repetition_cnt = 1; // do exactly one mesh location. Otherwise use what the parser decided.
@ -1528,6 +1568,7 @@
LCD_MESSAGEPGM("Done Editing Mesh"); // TODO: Make translatable string
SERIAL_ECHOLNPGM("Done Editing Mesh");
}
#endif
/**
* 'Smart Fill': Scan from the outward edges of the mesh towards the center.

Loading…
Cancel
Save