Start of process to get UBL running again.

The wait_for_user change totally broke UBL.   But there is stuff wrong
now in the thermal code and/or LCD Panel code.
master
Roxy-3D 8 years ago committed by Roxy-3D
parent b47eaf14ae
commit aec85ad45a

@ -199,6 +199,7 @@
set_current_to_destination();
}
ubl_has_control_of_lcd_panel = true; // Take control of the LCD Panel!
if (turn_on_heaters()) // Turn on the heaters, leave the command if anything
goto LEAVE; // has gone wrong.
@ -233,19 +234,30 @@
move_to(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], 0.0);
move_to(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], ooze_amount);
ubl_has_control_of_lcd_panel++; // Take control of the LCD Panel!
ubl_has_control_of_lcd_panel = true; // Take control of the LCD Panel!
debug_current_and_destination((char*)"Starting G26 Mesh Validation Pattern.");
wait_for_user = true;
/**
* Declare and generate a sin() & cos() table to be used during the circle drawing. This will lighten
* the CPU load and make the arc drawing faster and more smooth
*/
float sin_table[360 / 30 + 1], cos_table[360 / 30 + 1];
for (i = 0; i <= 360 / 30; i++) {
cos_table[i] = SIZE_OF_INTERSECTION_CIRCLES * cos(RADIANS(valid_trig_angle(i * 30.0)));
sin_table[i] = SIZE_OF_INTERSECTION_CIRCLES * sin(RADIANS(valid_trig_angle(i * 30.0)));
}
do {
if (!wait_for_user) { // Check if the user wants to stop the Mesh Validation
if (ubl_lcd_clicked()) { // Check if the user wants to stop the Mesh Validation
strcpy(lcd_status_message, "Mesh Validation Stopped."); // We can't do lcd_setstatus() without having it continue;
#if ENABLED(ULTRA_LCD)
lcd_setstatus("Mesh Validation Stopped.", true);
lcd_quick_feedback();
#endif
while (ubl_lcd_clicked()) { // Wait until the user is done pressing the
idle(); // Encoder Wheel if that is why we are leaving
}
goto LEAVE;
}
@ -309,16 +321,6 @@
end_angle = 360.0;
}
/**
* Declare and generate a sin() & cos() table to be used during the circle drawing. This will lighten
* the CPU load and make the arc drawing faster and more smooth
*/
float sin_table[360 / 30 + 1], cos_table[360 / 30 + 1];
for (i = 0; i <= 360 / 30; i++) {
cos_table[i] = SIZE_OF_INTERSECTION_CIRCLES * cos(RADIANS(valid_trig_angle(i * 30.0)));
sin_table[i] = SIZE_OF_INTERSECTION_CIRCLES * sin(RADIANS(valid_trig_angle(i * 30.0)));
}
for (tmp = start_angle; tmp < end_angle - 0.1; tmp += 30.0) {
int tmp_div_30 = tmp / 30.0;
if (tmp_div_30 < 0) tmp_div_30 += 360 / 30;
@ -351,13 +353,16 @@
}
print_line_from_here_to_there(x, y, layer_height, xe, ye, layer_height);
}
lcd_init_counter++;
if (lcd_init_counter > 10) {
lcd_init_counter = 0;
lcd_init(); // Some people's LCD Displays are locking up. This might help them
}
// lcd_init_counter++;
// if (lcd_init_counter > 10) {
// lcd_init_counter = 0;
// lcd_init(); // Some people's LCD Displays are locking up. This might help them
// ubl_has_control_of_lcd_panel = true; // Make sure UBL still is controlling the LCD Panel
// }
// If the end point of the line is closer to the nozzle, we are going to
debug_current_and_destination((char*)"Looking for lines to connect.");
look_for_lines_to_connect();
debug_current_and_destination((char*)"Done with line connect.");
@ -365,21 +370,24 @@
debug_current_and_destination((char*)"Done with current circle.");
// If the end point of the line is closer to the nozzle, we are going to
}
while (location.x_index >= 0 && location.y_index >= 0);
LEAVE:
wait_for_user = false;
while (ubl_lcd_clicked()) { // Wait until the user is done pressing the
idle(); // Encoder Wheel if that is why we are leaving
}
retract_filament();
destination[Z_AXIS] = Z_CLEARANCE_BETWEEN_PROBES; // Raise the nozzle
debug_current_and_destination((char*)"ready to do Z-Raise.");
move_to( destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], 0); // Raise the nozzle
move_to( destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], 0); // Raise the nozzle
debug_current_and_destination((char*)"done doing Z-Raise.");
destination[X_AXIS] = x_pos; // Move back to the starting position
destination[X_AXIS] = x_pos; // Move back to the starting position
destination[Y_AXIS] = y_pos;
destination[Z_AXIS] = Z_CLEARANCE_BETWEEN_PROBES; // Keep the nozzle where it is
@ -538,6 +546,8 @@
float feed_value;
static float last_z = -999.99;
bool has_xy_component = (x != current_position[X_AXIS] || y != current_position[Y_AXIS]); // Check if X or Y is involved in the movement.
if (g26_debug_flag) {
@ -591,6 +601,7 @@
stepper.synchronize();
set_destination_to_current();
}
void retract_filament() {
@ -658,16 +669,23 @@
if (g26_debug_flag)
SERIAL_ECHOLNPGM(" filament retracted.");
}
// If the end point of the line is closer to the nozzle, we are going to
move_to(sx, sy, sz, 0.0); // Get to the starting point with no extrusion
// If the end point of the line is closer to the nozzle, we are going to
float e_pos_delta = Line_Length * g26_e_axis_feedrate * extrusion_multiplier;
un_retract_filament();
// If the end point of the line is closer to the nozzle, we are going to
if (g26_debug_flag) {
SERIAL_ECHOLNPGM(" doing printing move.");
debug_current_and_destination((char*)"doing final move_to() inside print_line_from_here_to_there()");
}
move_to(ex, ey, ez, e_pos_delta); // Get to the ending point with an appropriate amount of extrusion
// If the end point of the line is closer to the nozzle, we are going to
}
/**
@ -815,18 +833,18 @@
lcd_setstatus("G26 Heating Bed.", true);
lcd_quick_feedback();
#endif
ubl_has_control_of_lcd_panel++;
ubl_has_control_of_lcd_panel = true;
thermalManager.setTargetBed(bed_temp);
wait_for_user = true;
while (abs(thermalManager.degBed() - bed_temp) > 3) {
if (!wait_for_user) {
if (ubl_lcd_clicked()) {
strcpy(lcd_status_message, "Leaving G26"); // We can't do lcd_setstatus() without having it continue;
lcd_setstatus("Leaving G26", true); // Now we do it right.
while (ubl_lcd_clicked()) // Debounce Encoder Wheel
idle();
return UBL_ERR;
}
idle();
}
wait_for_user = false;
#if ENABLED(ULTRA_LCD)
}
lcd_setstatus("G26 Heating Nozzle.", true);
@ -836,16 +854,16 @@
// Start heating the nozzle and wait for it to reach temperature.
thermalManager.setTargetHotend(hotend_temp, 0);
wait_for_user = true;
while (abs(thermalManager.degHotend(0) - hotend_temp) > 3) {
if (!wait_for_user) {
if (ubl_lcd_clicked()) {
strcpy(lcd_status_message, "Leaving G26"); // We can't do lcd_setstatus() without having it continue;
lcd_setstatus("Leaving G26", true); // Now we do it right.
while (ubl_lcd_clicked()) // Debounce Encoder Wheel
idle();
return UBL_ERR;
}
idle();
}
wait_for_user = false;
#if ENABLED(ULTRA_LCD)
lcd_setstatus("", true);
@ -869,9 +887,7 @@
un_retract_filament(); // Lets make sure the G26 command doesn't think the filament is
// retracted(). We are here because we want to prime the nozzle.
// So let's just unretract just to be sure.
wait_for_user = true;
while (wait_for_user) {
while (!ubl_lcd_clicked()) {
chirp_at_user();
destination[E_AXIS] += 0.25;
#ifdef PREVENT_LENGTHY_EXTRUDE
@ -894,9 +910,10 @@
strcpy(lcd_status_message, "Done Priming"); // We can't do lcd_setstatus() without having it continue;
// So... We cheat to get a message up.
while (ubl_lcd_clicked()) // Debounce Encoder Wheel
idle();
#if ENABLED(ULTRA_LCD)
ubl_has_control_of_lcd_panel = false;
lcd_setstatus("Done Priming", true); // Now we do it right.
lcd_quick_feedback();
#endif
@ -917,6 +934,7 @@
set_destination_to_current();
retract_filament();
}
return UBL_OK;
}

@ -175,8 +175,13 @@
current_xi = ubl.get_cell_index_x(current_position[X_AXIS] + (MESH_X_DIST) / 2.0);
current_yi = ubl.get_cell_index_y(current_position[Y_AXIS] + (MESH_Y_DIST) / 2.0);
for (i = 0; i < UBL_MESH_NUM_X_POINTS - 1; i++)
SERIAL_ECHOPGM(" ");
for (i = 0; i < UBL_MESH_NUM_X_POINTS - 1; i++) {
SERIAL_ECHOPGM(" ");
#if TX_BUFFER_SIZE>0
MYSERIAL.flushTX();
#endif
delay(15);
}
SERIAL_ECHOPAIR("(", UBL_MESH_NUM_X_POINTS - 1);
SERIAL_ECHOPAIR(",", UBL_MESH_NUM_Y_POINTS - 1);
@ -188,8 +193,13 @@
SERIAL_ECHOPAIR(",", UBL_MESH_MAX_Y);
SERIAL_CHAR(')');
for (i = 0; i < UBL_MESH_NUM_X_POINTS - 1; i++)
SERIAL_ECHOPGM(" ");
for (i = 0; i < UBL_MESH_NUM_X_POINTS - 1; i++) {
SERIAL_ECHOPGM(" ");
#if TX_BUFFER_SIZE>0
MYSERIAL.flushTX();
#endif
delay(15);
}
SERIAL_ECHOPAIR("(", UBL_MESH_MAX_X);
SERIAL_ECHOPAIR(",", UBL_MESH_MAX_Y);
@ -205,13 +215,17 @@
SERIAL_CHAR(i == current_xi && j == current_yi ? '[' : ' ');
if (isnan(f))
SERIAL_PROTOCOLPGM(" . ");
SERIAL_PROTOCOLPGM(" . ");
else {
// if we don't do this, the columns won't line up nicely
if (f >= 0.0) SERIAL_CHAR(' ');
SERIAL_PROTOCOL_F(f, 5);
SERIAL_PROTOCOL_F(f, 3);
idle();
}
#if TX_BUFFER_SIZE>0
MYSERIAL.flushTX();
#endif
delay(15);
if (i == current_xi && j == current_yi) // is the nozzle here? if so, finish marking the number
SERIAL_CHAR(']');
else
@ -231,27 +245,34 @@
SERIAL_ECHOPAIR(",", int(UBL_MESH_MIN_Y));
SERIAL_ECHOPGM(") ");
for (i = 0; i < UBL_MESH_NUM_X_POINTS - 1; i++)
SERIAL_ECHOPGM(" ");
for (i = 0; i < UBL_MESH_NUM_X_POINTS - 1; i++) {
SERIAL_ECHOPGM(" ");
#if TX_BUFFER_SIZE>0
MYSERIAL.flushTX();
#endif
delay(15);
}
SERIAL_ECHOPAIR("(", int(UBL_MESH_MAX_X));
SERIAL_ECHOPAIR(",", int(UBL_MESH_MIN_Y));
SERIAL_CHAR(')');
// }
SERIAL_EOL;
SERIAL_ECHOPAIR("(", 0);
SERIAL_ECHOPAIR(",", 0);
SERIAL_ECHOPGM(") ");
for (i = 0; i < UBL_MESH_NUM_X_POINTS - 1; i++)
SERIAL_ECHOPGM(" ");
for (i = 0; i < UBL_MESH_NUM_X_POINTS - 1; i++) {
SERIAL_ECHOPGM(" ");
#if TX_BUFFER_SIZE>0
MYSERIAL.flushTX();
#endif
delay(15);
}
SERIAL_ECHOPAIR("(", UBL_MESH_NUM_X_POINTS-1);
SERIAL_ECHOPAIR(",", 0);
SERIAL_CHAR(')');
SERIAL_CHAR(' ');
SERIAL_EOL;
SERIAL_ECHOLNPGM(")");
}
bool unified_bed_leveling::sanity_check() {

@ -594,18 +594,18 @@
save_ubl_active_state_and_disable();
//measured_z = probe_pt(x_pos + X_PROBE_OFFSET_FROM_EXTRUDER, y_pos + Y_PROBE_OFFSET_FROM_EXTRUDER, ProbeDeployAndStow, g29_verbose_level);
ubl_has_control_of_lcd_panel = true;// Grab the LCD Hardware
measured_z = 1.5;
do_blocking_move_to_z(measured_z); // Get close to the bed, but leave some space so we don't damage anything
// The user is not going to be locking in a new Z-Offset very often so
// it won't be that painful to spin the Encoder Wheel for 1.5mm
lcd_implementation_clear();
lcd_z_offset_edit_setup(measured_z);
wait_for_user = true;
do {
measured_z = lcd_z_offset_edit();
idle();
do_blocking_move_to_z(measured_z);
} while (wait_for_user);
} while (!ubl_lcd_clicked());
ubl_has_control_of_lcd_panel++; // There is a race condition for the Encoder Wheel getting clicked.
// It could get detected in lcd_mesh_edit (actually _lcd_mesh_fine_tune)
@ -707,14 +707,17 @@
save_ubl_active_state_and_disable(); // we don't do bed level correction because we want the raw data when we probe
DEPLOY_PROBE();
wait_for_user = true;
do {
if (!wait_for_user) {
SERIAL_PROTOCOLLNPGM("\nMesh only partially populated.");
if (ubl_lcd_clicked()) {
SERIAL_PROTOCOLLNPGM("\nMesh only partially populated.\n");
lcd_quick_feedback();
ubl_has_control_of_lcd_panel = false;
STOW_PROBE();
while (ubl_lcd_clicked() ) {
idle();
}
ubl_has_control_of_lcd_panel = false;
restore_ubl_active_state_and_leave();
delay(50); // Debounce the Encoder wheel
return;
}
@ -737,7 +740,6 @@
LEAVE:
wait_for_user = false;
STOW_PROBE();
restore_ubl_active_state_and_leave();
@ -813,8 +815,7 @@
}
float use_encoder_wheel_to_measure_point() {
wait_for_user = true;
while (wait_for_user) { // we need the loop to move the nozzle based on the encoder wheel here!
while (!ubl_lcd_clicked()) { // we need the loop to move the nozzle based on the encoder wheel here!
idle();
if (ubl_encoderDiff) {
do_blocking_move_to_z(current_position[Z_AXIS] + 0.01 * float(ubl_encoderDiff));
@ -891,8 +892,8 @@
last_x = xProbe;
last_y = yProbe;
wait_for_user = true;
while (wait_for_user) { // we need the loop to move the nozzle based on the encoder wheel here!
ubl_has_control_of_lcd_panel = true;
while (!ubl_lcd_clicked) { // we need the loop to move the nozzle based on the encoder wheel here!
idle();
if (ubl_encoderDiff) {
do_blocking_move_to_z(current_position[Z_AXIS] + float(ubl_encoderDiff) / 100.0);

Loading…
Cancel
Save